diff --git a/.github/workflows/github-pull-request-build.yml b/.github/workflows/github-pull-request-build.yml index 61b15391..ab074256 100644 --- a/.github/workflows/github-pull-request-build.yml +++ b/.github/workflows/github-pull-request-build.yml @@ -6,8 +6,6 @@ on: branches: - main -env: - CHROME_BIN: "chrome" jobs: Build-And-Test-Linux: runs-on: ubuntu-latest @@ -20,7 +18,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - uses: browser-actions/setup-chrome@v1 - - run: ./linuxBuild.sh + - run: CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }} ./linuxBuild.sh Build-And-Test-Mac: runs-on: macos-latest steps: @@ -32,7 +30,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 - uses: browser-actions/setup-chrome@v1 - - run: ./macBuild.sh + id: setup-chrome + - run: CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }} ./macBuild.sh Build-And-Test-Windows: runs-on: windows-latest steps: @@ -45,6 +44,7 @@ jobs: uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 - uses: browser-actions/setup-chrome@v1 + id: setup-chrome - shell: msys2 {0} run: | ./windowsBuild.sh \ No newline at end of file diff --git a/README.md b/README.md index 7ef2da53..327a36c9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ and bug-fixing. ### WASM -WASM platform is experimental, use with caution. Note that currently wasm returns a value after converting to IEEE-754 number, unlike +WASM platform is experimental, use with caution, tests for wasm are not run on Windows and Mac at the moment. Note that currently wasm returns a value after converting to IEEE-754 number, unlike other platforms (JVM, JS, Native), so if you use: ```kotlin val a = BigDecimal.fromFloat(0.000000000000123f) diff --git a/bignum-serialization-kotlinx/build.gradle.kts b/bignum-serialization-kotlinx/build.gradle.kts index 9b7712f5..10fc3770 100644 --- a/bignum-serialization-kotlinx/build.gradle.kts +++ b/bignum-serialization-kotlinx/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest +import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest plugins { kotlin(PluginsDeps.multiplatform) @@ -28,8 +29,10 @@ val primaryDevelopmentOs: HostOs = if (bignumPrimaryDevelopmentOs != null) { "linux" -> HostOs.LINUX "windows" -> HostOs.WINDOWS "mac" -> HostOs.MAC - else -> throw org.gradle.api.GradleException("Invalid development enviromoment OS selecte: " + - "$bignumPrimaryDevelopmentOs. Only linux, windows and mac are supported at the moment") + else -> throw org.gradle.api.GradleException( + "Invalid development enviromoment OS selecte: " + + "$bignumPrimaryDevelopmentOs. Only linux, windows and mac are supported at the moment" + ) } } else { HostOs.LINUX @@ -66,74 +69,78 @@ signing { } kotlin { - - val hostOs = getHostOsName() - if (hostOs == primaryDevelopmentOs) { - jvm() - js(IR) { + jvm() + js { + compilations { + this.forEach { + it.compileTaskProvider.configure { + kotlinOptions.sourceMap = true + kotlinOptions.metaInfo = true + if (it.name == "main") { + kotlinOptions.main = "call" + } + } + } nodejs() - browser() - } - wasmJs { - browser() + browser() { + testTask { + useKarma { + useChromeHeadless() + } + } + } } } - if (hostOs == HostOs.LINUX) { - linuxX64() -// linuxArm32Hfp() Not supported by kotlinx serialization -// linuxArm64() Not supported by kotlinx serialization - } + linuxX64() + linuxArm64() + androidNativeX64() + androidNativeX86() + androidNativeArm32() + androidNativeArm64() iosX64() iosArm64() iosSimulatorArm64() macosX64() macosArm64() - tvos() + tvosArm64() tvosSimulatorArm64() - watchos() + tvosX64() + watchosArm32() + watchosArm64() + watchosDeviceArm64() + watchosX64() watchosSimulatorArm64() -// mingwX86() Not supported by kotlinx serialization mingwX64() + wasmJs { + browser() + } + wasmWasi() sourceSets { - val commonMain by getting { - dependencies { - implementation(kotlin(Deps.Common.stdLib)) - implementation(project(Deps.Project.bignum)) - implementation(Deps.Common.kotlinxSerialization) - } + commonMain.dependencies { + implementation(kotlin(Deps.Common.stdLib)) + implementation(project(Deps.Project.bignum)) + implementation(Deps.Common.kotlinxSerialization) } - val commonTest by getting { - dependencies { - implementation(kotlin(Deps.Common.test)) - implementation(kotlin(Deps.Common.testAnnotation)) - implementation(Deps.Common.coroutines) - } + commonTest.dependencies { + implementation(kotlin(Deps.Common.test)) + implementation(kotlin(Deps.Common.testAnnotation)) + implementation(Deps.Common.coroutines) } - if (hostOs == primaryDevelopmentOs) { - val jvmTest by getting { - dependencies { - implementation(kotlin(Deps.Jvm.test)) - implementation(kotlin(Deps.Jvm.testJUnit)) - implementation(kotlin(Deps.Jvm.reflection)) - } - } - - val jsTest by getting { - dependencies { - implementation(kotlin(Deps.Js.test)) - } - } - - val wasmJsTest by getting { - dependencies { - implementation(kotlin(Deps.WasmJs.test)) - } + jvmTest.dependencies { + implementation(kotlin(Deps.Jvm.test)) + implementation(kotlin(Deps.Jvm.testJUnit)) + implementation(kotlin(Deps.Jvm.reflection)) + } + jsTest.dependencies { + implementation(kotlin(Deps.Js.test)) + } + val wasmJsTest by getting { + dependencies { + implementation(kotlin(Deps.WasmJs.test)) } } - - } } @@ -163,37 +170,23 @@ tasks { } } - val jsNodeTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { + val jsNodeTest by getting(KotlinJsTest::class) { testLogging { events("PASSED", "FAILED", "SKIPPED") } } - val jsBrowserTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { + val jsBrowserTest by getting(KotlinJsTest::class) { testLogging { events("PASSED", "FAILED", "SKIPPED") } } } -// val jsLegacyNodeTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// } -// } -// -// val jsLegacyBrowserTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// } -// } - - if (hostOs == HostOs.LINUX) { - val linuxX64Test by getting(KotlinNativeTest::class) { - testLogging { - events("PASSED", "FAILED", "SKIPPED") - // showStandardStreams = true - } + val linuxX64Test by getting(KotlinNativeTest::class) { + testLogging { + events("PASSED", "FAILED", "SKIPPED") + // showStandardStreams = true } } } diff --git a/bignum/build.gradle.kts b/bignum/build.gradle.kts index 7afc1693..1553f6d3 100644 --- a/bignum/build.gradle.kts +++ b/bignum/build.gradle.kts @@ -72,77 +72,56 @@ fun getHostOsName(): HostOs { } kotlin { - - val hostOs = getHostOsName() - println("Host os name $hostOs") - - if (ideaActive) { - when (hostOs) { - HostOs.LINUX -> linuxX64("native") - HostOs.MAC -> macosX64("native") - HostOs.WINDOWS -> mingwX64("native") - } - } - if (hostOs == primaryDevelopmentOs) { - jvm() - - js { - compilations { - this.forEach { - it.compileKotlinTask.kotlinOptions.sourceMap = true - it.compileKotlinTask.kotlinOptions.metaInfo = true - + jvm() + js { + compilations { + this.forEach { + it.compileTaskProvider.configure { + kotlinOptions.sourceMap = true + kotlinOptions.metaInfo = true if (it.name == "main") { - it.compileKotlinTask.kotlinOptions.main = "call" + kotlinOptions.main = "call" } - println("Compilation name ${it.name} set") - println("Destination dir ${it.compileKotlinTask.destinationDirectory}") } - nodejs() - browser() { - testTask { - useKarma { - useChromeHeadless() - } + } + nodejs() + browser() { + testTask { + useKarma { + useChromeHeadless() } } } } - - wasmJs { - browser() - } - } - - if (hostOs == HostOs.LINUX) { - linuxX64("linux") - if (ideaActive.not()) { - linuxArm64() - androidNativeX64() - androidNativeX86() - androidNativeArm32() - androidNativeArm64() - } } - + linuxX64() + linuxArm64() + androidNativeX64() + androidNativeX86() + androidNativeArm32() + androidNativeArm64() iosX64() iosArm64() iosSimulatorArm64() macosX64() macosArm64() - tvos() + tvosArm64() tvosSimulatorArm64() - if (ideaActive.not()) { - watchos() - watchosSimulatorArm64() - } + tvosX64() + watchosArm32() + watchosArm64() + watchosDeviceArm64() + watchosX64() + watchosSimulatorArm64() mingwX64() + wasmJs { + browser() + } + wasmWasi() sourceSets { - val commonMain by getting { - dependencies { - implementation(kotlin(Deps.Common.stdLib)) - } + commonMain.dependencies { + implementation(kotlin(Deps.Common.stdLib)) } val commonTest by getting { dependencies { @@ -153,191 +132,30 @@ kotlin { } } - val nativeMain = if (ideaActive) { - val nativeMain by getting { - dependsOn(commonMain) - } - nativeMain - } else { - val nativeMain by creating { - dependsOn(commonMain) - } - nativeMain - } - val nativeTest = if (ideaActive) { - val nativeTest by getting { - dependsOn(commonTest) - } - nativeTest - } else { - val nativeTest by creating { - dependsOn(commonTest) - } - nativeTest - } - - if (hostOs == primaryDevelopmentOs) { - val jvmMain by getting { - dependencies { - implementation(kotlin(Deps.Jvm.stdLib)) - } - } - val jvmTest by getting { - dependencies { - implementation(kotlin(Deps.Jvm.test)) - implementation(kotlin(Deps.Jvm.testJUnit)) - implementation(kotlin(Deps.Jvm.reflection)) - } - } - - val jsMain by getting { - dependencies { - implementation(kotlin(Deps.Js.stdLib)) - } - } - val jsTest by getting { - dependencies { - implementation(kotlin(Deps.Js.test)) - } - } - - val wasmJsMain by getting { - dependencies { - implementation(kotlin(Deps.WasmJs.stdLib)) - } - } - val wasmJsTest by getting { - dependencies { - implementation(kotlin(Deps.WasmJs.test)) - } - } - } - - if (hostOs == HostOs.LINUX) { - - val linuxMain by getting { - dependsOn(nativeMain) - } - val linuxTest by getting { - dependsOn(nativeTest) - } - - if (ideaActive.not()) { - - val linuxArm64Main by getting { - dependsOn(nativeMain) - } - - val linuxArm64Test by getting { - dependsOn(nativeTest) - } - - val androidNativeX64Main by getting { - dependsOn(nativeMain) - } - - val androidNativeX64Test by getting { - dependsOn(nativeTest) - } - - val androidNativeX86Main by getting { - dependsOn(nativeMain) - } - - val androidNativeX86Test by getting { - dependsOn(nativeTest) - } - - val androidNativeArm32Main by getting { - dependsOn(nativeMain) - } - - val androidNativeArm32Test by getting { - dependsOn(nativeTest) - } - - val androidNativeArm64Main by getting { - dependsOn(nativeMain) - } - - val androidNativeArm64Test by getting { - dependsOn(nativeTest) - } - } - } - - val iosX64Main by getting { - dependsOn(nativeMain) + jvmMain.dependencies { + implementation(kotlin(Deps.Jvm.stdLib)) } - val iosX64Test by getting { - dependsOn(nativeTest) + jvmTest.dependencies { + implementation(kotlin(Deps.Jvm.test)) + implementation(kotlin(Deps.Jvm.testJUnit)) + implementation(kotlin(Deps.Jvm.reflection)) } - - val iosArm64Main by getting { - dependsOn(nativeMain) + jsMain.dependencies { + implementation(kotlin(Deps.Js.stdLib)) } - val iosArm64Test by getting { - dependsOn(nativeTest) + jsTest.dependencies { + implementation(kotlin(Deps.Js.test)) } - val macosX64Main by getting { - dependsOn(nativeMain) - } - val macosX64Test by getting { - dependsOn(nativeTest) - } - - val tvosMain by getting { - dependsOn(nativeMain) - } - val tvosTest by getting { - dependsOn(nativeTest) - } - - val iosSimulatorArm64Main by sourceSets.getting - val iosSimulatorArm64Test by sourceSets.getting - - iosSimulatorArm64Main.dependsOn(nativeMain) - iosSimulatorArm64Test.dependsOn(nativeTest) - - val macosArm64Main by sourceSets.getting - val macosArm64Test by sourceSets.getting - - macosArm64Main.dependsOn(nativeMain) - macosArm64Test.dependsOn(nativeTest) - - val tvosSimulatorArm64Main by sourceSets.getting - val tvosSimulatorArm64Test by sourceSets.getting - - tvosSimulatorArm64Main.dependsOn(nativeMain) - tvosSimulatorArm64Test.dependsOn(nativeTest) - - if (ideaActive.not()) { - val watchosMain by getting { - dependsOn(nativeMain) - } - - val watchosTest by getting { - dependsOn(nativeTest) + val wasmJsTest by getting { + dependencies { + implementation(kotlin(Deps.WasmJs.test)) } - - val watchosSimulatorArm64Main by sourceSets.getting - val watchosSimulatorArm64Test by sourceSets.getting - - watchosSimulatorArm64Main.dependsOn(nativeMain) - watchosSimulatorArm64Test.dependsOn(nativeTest) - } - - val mingwX64Main by getting { - dependsOn(nativeMain) - } - - val mingwX64Test by getting { - dependsOn(nativeTest) } all { languageSettings.enableLanguageFeature("InlineClasses") + languageSettings.optIn("expect-actual-classes") languageSettings.optIn("kotlin.ExperimentalUnsignedTypes") languageSettings.optIn("kotlin.ExperimentalStdlibApi") } @@ -358,7 +176,6 @@ tasks { } dokkaHtml { - println("Dokka !") dokkaSourceSets { } } @@ -369,40 +186,7 @@ tasks { exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL } } - -// val jsIrNodeTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// } -// } -// -// val jsIrBrowserTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// } -// } -// -// val jsLegacyNodeTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// } -// } -// -// val jsLegacyBrowserTest by getting(org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// } -// } } -// -// if (hostOsName == HostOs.LINUX) { -// val linuxTest by getting(KotlinNativeTest::class) { -// testLogging { -// events("PASSED", "FAILED", "SKIPPED") -// // showStandardStreams = true -// } -// } -// } } spotless { diff --git a/bignum/src/wasmWasiMain/kotlin/com/ionspin/kotlin/bignum/integer/PlatformWorkarounds.wasmWasi.kt b/bignum/src/wasmWasiMain/kotlin/com/ionspin/kotlin/bignum/integer/PlatformWorkarounds.wasmWasi.kt new file mode 100644 index 00000000..30f38167 --- /dev/null +++ b/bignum/src/wasmWasiMain/kotlin/com/ionspin/kotlin/bignum/integer/PlatformWorkarounds.wasmWasi.kt @@ -0,0 +1,8 @@ +package com.ionspin.kotlin.bignum.integer + +actual object RuntimePlatform { + /** + * We need to know if we are running on a platform that doesn't know how to tell decimal and integer apart. + */ + actual fun currentPlatform(): Platform = Platform.WASMJS +} diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index a994010f..5772ab9b 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -106,6 +106,11 @@ + + + + + @@ -124,12 +129,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macBuild.sh b/macBuild.sh index 820485ea..07a7bbef 100755 --- a/macBuild.sh +++ b/macBuild.sh @@ -1,9 +1,9 @@ if [[ -n "$GITHUB_ACTION" ]]; then echo "Running without verification" - ./gradlew build --dependency-verification lenient -x watchosX64Test || exit 1 + ./gradlew build --dependency-verification lenient -x watchosX64Test -x jsBrowserTest -x wasmJsBrowserTest || exit 1 else echo "Running with verification" -./gradlew build -x watchosX64Test || exit 1 +./gradlew build -x watchosX64Test -x jsBrowserTest -x wasmJsBrowserTest || exit 1 fi exit 0 diff --git a/macBuildAndPublish.sh b/macBuildAndPublish.sh index 576b773d..165fb985 100755 --- a/macBuildAndPublish.sh +++ b/macBuildAndPublish.sh @@ -4,5 +4,5 @@ publishTvosArm64PublicationToSnapshotRepository publishTvosX64PublicationToSnaps publishWatchosArm32PublicationToSnapshotRepository publishWatchosArm64PublicationToSnapshotRepository \ publishWatchosX64PublicationToSnapshotRepository \ publishMacosArm64PublicationToSnapshotRepository publishIosSimulatorArm64PublicationToSnapshotRepository \ -publishTvosSimulatorArm64PublicationToSnapshotRepository publishWatchosSimulatorArm64PublicationToSnapshotRepository || exit 1 +publishTvosSimulatorArm64PublicationToSnapshotRepository publishWatchosSimulatorArm64PublicationToSnapshotRepository -x jsBrowserTest -x wasmJsBrowserTest || exit 1 exit 0 diff --git a/macPublishToMaven.sh b/macPublishToMaven.sh index 8e30a44a..0aa35191 100644 --- a/macPublishToMaven.sh +++ b/macPublishToMaven.sh @@ -4,4 +4,4 @@ publishTvosArm64PublicationToMavenRepository publishTvosX64PublicationToMavenRep publishWatchosArm32PublicationToMavenRepository publishWatchosArm64PublicationToMavenRepository \ publishWatchosX64PublicationToMavenRepository \ publishMacosArm64PublicationToMavenRepository publishIosSimulatorArm64PublicationToMavenRepository \ -publishTvosSimulatorArm64PublicationToMavenRepository publishWatchosSimulatorArm64PublicationToMavenRepository +publishTvosSimulatorArm64PublicationToMavenRepository publishWatchosSimulatorArm64PublicationToMavenRepository -x jsBrowserTest -x wasmJsBrowserTest diff --git a/windowsBuild.sh b/windowsBuild.sh index 2f13215e..61b54e6f 100755 --- a/windowsBuild.sh +++ b/windowsBuild.sh @@ -1,9 +1,9 @@ if [[ -n "$GITHUB_ACTION" ]]; then echo "Running without verification" - ./gradlew build --dependency-verification lenient -x spotlessKotlinCheck -x spotlessKotlinGradleCheck || exit 1 + ./gradlew build --dependency-verification lenient -x spotlessKotlinCheck -x spotlessKotlinGradleCheck -x jsBrowserTest -x wasmJsBrowserTest || exit 1 else echo "Running with verification" - ./gradlew build -x spotlessKotlinCheck -x spotlessKotlinGradleCheck || exit 1 + ./gradlew build -x spotlessKotlinCheck -x spotlessKotlinGradleCheck -x jsBrowserTest -x wasmJsBrowserTest || exit 1 fi ./gradlew --stop diff --git a/windowsBuildAndPublish.sh b/windowsBuildAndPublish.sh index 6fd7f87e..e88e084d 100755 --- a/windowsBuildAndPublish.sh +++ b/windowsBuildAndPublish.sh @@ -1,4 +1,4 @@ -./gradlew --no-daemon build bignum:publishMingwX64PublicationToSnapshotRepository -x spotlessKotlinCheck -x spotlessKotlinGradleCheck || exit 1 -./gradlew --no-daemon bignum-serialization-kotlinx:publishMingwX64PublicationToSnapshotRepository -x spotlessKotlinCheck -x spotlessKotlinGradleCheck || exit 1 +./gradlew --no-daemon build bignum:publishMingwX64PublicationToSnapshotRepository -x spotlessKotlinCheck -x spotlessKotlinGradleCheck -x jsBrowserTest -x wasmJsBrowserTest || exit 1 +./gradlew --no-daemon bignum-serialization-kotlinx:publishMingwX64PublicationToSnapshotRepository -x spotlessKotlinCheck -x spotlessKotlinGradleCheck -x jsBrowserTest -x wasmJsBrowserTest || exit 1 ./gradlew --stop exit 0 diff --git a/windowsPublishToMaven.sh b/windowsPublishToMaven.sh index 423b09fa..a6fc945d 100644 --- a/windowsPublishToMaven.sh +++ b/windowsPublishToMaven.sh @@ -1,2 +1,2 @@ -./gradlew --no-daemon publishMingwX64PublicationToMavenRepository -x spotlessKotlinCheck -x spotlessKotlinGradleCheck +./gradlew --no-daemon publishMingwX64PublicationToMavenRepository -x spotlessKotlinCheck -x spotlessKotlinGradleCheck -x jsBrowserTest -x wasmJsBrowserTest ./gradlew --stop