From c13fd89ee3143f3a1c82199a0c378e1f29491178 Mon Sep 17 00:00:00 2001 From: asr2003 <162500856+asr2003@users.noreply.github.com> Date: Sat, 31 Aug 2024 01:52:32 +0530 Subject: [PATCH 1/3] Update build.sbt --- build.sbt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.sbt b/build.sbt index 478857687..385d56cf4 100644 --- a/build.sbt +++ b/build.sbt @@ -127,6 +127,7 @@ lazy val zioSchemaMacros = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings(macroDefinitionSettings) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -157,6 +158,7 @@ lazy val zioSchema = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -212,6 +214,7 @@ lazy val zioSchemaDerivation = crossProject(JSPlatform, JVMPlatform, NativePlatf ) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -241,6 +244,7 @@ lazy val zioSchemaJson = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -268,6 +272,7 @@ lazy val zioSchemaProtobuf = crossProject(JSPlatform, JVMPlatform, NativePlatfor .settings(buildInfoSettings("zio.schema.protobuf")) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -359,6 +364,7 @@ lazy val zioSchemaOptics = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -389,6 +395,7 @@ lazy val zioSchemaExamples = crossProject(JSPlatform, JVMPlatform, NativePlatfor ) .nativeSettings(Test / fork := false) .nativeSettings( + nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) From 3d535f1d2bd79a121c7e4c6f6379001bab368bfb Mon Sep 17 00:00:00 2001 From: asr2003 <162500856+asr2003@users.noreply.github.com> Date: Sat, 31 Aug 2024 01:54:49 +0530 Subject: [PATCH 2/3] Update build.sbt --- build.sbt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build.sbt b/build.sbt index 385d56cf4..478857687 100644 --- a/build.sbt +++ b/build.sbt @@ -127,7 +127,6 @@ lazy val zioSchemaMacros = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings(macroDefinitionSettings) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -158,7 +157,6 @@ lazy val zioSchema = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -214,7 +212,6 @@ lazy val zioSchemaDerivation = crossProject(JSPlatform, JVMPlatform, NativePlatf ) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -244,7 +241,6 @@ lazy val zioSchemaJson = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -272,7 +268,6 @@ lazy val zioSchemaProtobuf = crossProject(JSPlatform, JVMPlatform, NativePlatfor .settings(buildInfoSettings("zio.schema.protobuf")) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -364,7 +359,6 @@ lazy val zioSchemaOptics = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) @@ -395,7 +389,6 @@ lazy val zioSchemaExamples = crossProject(JSPlatform, JVMPlatform, NativePlatfor ) .nativeSettings(Test / fork := false) .nativeSettings( - nativeSettings, libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion ) From ae5ebb52247e415a615fdb04dae02d9573a56c89 Mon Sep 17 00:00:00 2001 From: asr2003 <162500856+asr2003@users.noreply.github.com> Date: Sat, 31 Aug 2024 05:29:04 +0530 Subject: [PATCH 3/3] feat: upgrade scala native to latest and enable multithreading --- .github/workflows/ci.yml | 4 ++-- build.sbt | 11 ++++++++++- project/BuildHelper.scala | 17 ++++++++++++++--- project/plugins.sbt | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3d76f4aa..7cf4b163c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,9 +49,9 @@ jobs: jvm: ${{ matrix.java }} - name: Cache scala dependencies uses: coursier/cache-action@v6 - - name: Install libuv + - name: Install Bohem GC if: matrix.platform == 'Native' - run: sudo apt-get update && sudo apt-get install -y libuv1-dev + run: sudo apt-get update && sudo apt-get install -y libgc-dev - name: Run tests run: sbt ++${{ matrix.scala }}! test${{ matrix.platform }} diff --git a/build.sbt b/build.sbt index 478857687..7f0e5aff8 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ import sbtcrossproject.CrossPlugin.autoImport._ -import BuildHelper.{ crossProjectSettings, _ } +import BuildHelper.* import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ Global / onChangedBuildSource := ReloadOnSourceChanges @@ -113,6 +113,7 @@ lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings(crossProjectSettings) .settings(buildInfoSettings("zio.schema")) .settings(testDeps) + .nativeSettings(nativeSettings) lazy val testsJS = tests.js .settings(scalaJSUseMainModuleInitializer := true) @@ -126,6 +127,7 @@ lazy val zioSchemaMacros = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings(buildInfoSettings("zio.schema")) .settings(macroDefinitionSettings) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -156,6 +158,7 @@ lazy val zioSchema = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) ) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -211,6 +214,7 @@ lazy val zioSchemaDerivation = crossProject(JSPlatform, JVMPlatform, NativePlatf } ) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -240,6 +244,7 @@ lazy val zioSchemaJson = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) ) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -267,6 +272,7 @@ lazy val zioSchemaProtobuf = crossProject(JSPlatform, JVMPlatform, NativePlatfor .settings(crossProjectSettings) .settings(buildInfoSettings("zio.schema.protobuf")) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -358,6 +364,7 @@ lazy val zioSchemaOptics = crossProject(JSPlatform, JVMPlatform, NativePlatform) ) ) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -388,6 +395,7 @@ lazy val zioSchemaExamples = crossProject(JSPlatform, JVMPlatform, NativePlatfor scalacOptions -= "-Xfatal-warnings" ) .nativeSettings(Test / fork := false) + .nativeSettings(nativeSettings) .nativeSettings( libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion @@ -412,6 +420,7 @@ lazy val zioSchemaZioTest = crossProject(JSPlatform, JVMPlatform, NativePlatform .settings(stdSettings("zio-schema-zio-test")) .settings(crossProjectSettings) .settings(buildInfoSettings("zio.schema.test")) + .nativeSettings(nativeSettings) .settings( libraryDependencies ++= Seq( "dev.zio" %%% "zio-test" % zioVersion diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index eda8731f6..4800ed52a 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -6,7 +6,8 @@ import BuildInfoKeys.* import scalafix.sbt.ScalafixPlugin.autoImport.* import scalanativecrossproject.NativePlatform -import scala.scalanative.sbtplugin.ScalaNativePlugin.autoImport.nativeConfig +import scala.scalanative.build.{ GC, Mode } +import scala.scalanative.sbtplugin.ScalaNativePlugin.autoImport.* object BuildHelper { @@ -27,7 +28,7 @@ object BuildHelper { val Scala213: String = versions("2.13") val Scala3: String = versions("3.3") - val zioVersion = "2.1.7" + val zioVersion = "2.1.9" val zioJsonVersion = "0.7.2" val zioPreludeVersion = "1.0.0-RC28" val zioOpticsVersion = "0.2.2" @@ -187,8 +188,18 @@ object BuildHelper { "test", baseDirectory.value ) + } + ) + + def nativeSettings = Seq( + nativeConfig ~= { cfg => + val os = System.getProperty("os.name").toLowerCase + // For some unknown reason, we can't run the test suites in debug mode on MacOS + if (os.contains("mac")) cfg.withMode(Mode.releaseFast) + else cfg.withGC(GC.boehm) // See https://github.com/scala-native/scala-native/issues/4032 }, - nativeConfig ~= { _.withMultithreading(false) } + scalacOptions += "-P:scalanative:genStaticForwardersForNonTopLevelObjects", + Test / fork := crossProjectPlatform.value == JVMPlatform // set fork to `true` on JVM to improve log readability, JS and Native need `false` ) def buildInfoSettings(packageName: String) = Seq( diff --git a/project/plugins.sbt b/project/plugins.sbt index c55a5cc1f..d8ea37172 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,7 +6,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.3") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.5") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6") addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.4.0-alpha.22")