Skip to content

Commit

Permalink
Cross-build for Native
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Sep 9, 2022
1 parent 240a0b4 commit c47bce0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ jobs:
os: [ubuntu-latest]
scala: [2.13.8, 2.12.16, 3.1.3]
java: [temurin@8, temurin@11]
project: [rootJS, rootJVM]
project: [rootJS, rootJVM, rootNative]
exclude:
- scala: 2.12.16
java: temurin@11
- scala: 3.1.3
java: temurin@11
- project: rootJS
java: temurin@11
- project: rootNative
java: temurin@11
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -100,6 +102,10 @@ jobs:
if: matrix.project == 'rootJS'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/scalaJSLinkerResult

- name: nativeLink
if: matrix.project == 'rootNative'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' Test/nativeLink

- name: Test
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test

Expand All @@ -113,11 +119,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target
run: mkdir -p testing/jvm/target noop/jvm/target target .js/target core/native/target site/target testing/native/target noop/native/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar testing/jvm/target noop/jvm/target target .js/target site/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target
run: tar cf targets.tar testing/jvm/target noop/jvm/target target .js/target core/native/target site/target testing/native/target noop/native/target core/js/target testing/js/target noop/js/target core/jvm/target .jvm/target .native/target slf4j/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down Expand Up @@ -206,6 +212,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.8, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative

- name: Inflate target directories (2.13.8, rootNative)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.16, rootJS)
uses: actions/download-artifact@v2
with:
Expand All @@ -226,6 +242,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.16, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootNative

- name: Inflate target directories (2.12.16, rootNative)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.1.3, rootJS)
uses: actions/download-artifact@v2
with:
Expand All @@ -246,6 +272,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.1.3, rootNative)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootNative

- name: Inflate target directories (3.1.3, rootNative)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -di | gpg --import
Expand Down
19 changes: 13 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.te
ThisBuild / tlVersionIntroduced := Map("3" -> "2.1.1")

val catsV = "2.8.0"
val catsEffectV = "3.3.14"
val catsEffectV = "3.3.14-1-5d11fe9"
val slf4jV = "1.7.36"
val munitCatsEffectV = "1.0.7"
val munitCatsEffectV = "2.0-5e03bfc"
val logbackClassicV = "1.2.11"

Global / onChangedBuildSource := ReloadOnSourceChanges
Expand All @@ -41,7 +41,7 @@ lazy val docs = project
.enablePlugins(TypelevelSitePlugin)
.dependsOn(slf4j)

lazy val core = crossProject(JSPlatform, JVMPlatform)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(commonSettings)
.settings(
name := "log4cats-core",
Expand All @@ -58,8 +58,9 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
libraryDependencies += ("org.scala-js" %%% "scalajs-java-securerandom" % "1.0.0")
.cross(CrossVersion.for3Use2_13)
)
.nativeSettings(commonNativeSettings)

lazy val testing = crossProject(JSPlatform, JVMPlatform)
lazy val testing = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(commonSettings)
.dependsOn(core)
.settings(
Expand All @@ -69,13 +70,15 @@ lazy val testing = crossProject(JSPlatform, JVMPlatform)
"ch.qos.logback" % "logback-classic" % logbackClassicV % Test
)
)
.nativeSettings(commonNativeSettings)

lazy val noop = crossProject(JSPlatform, JVMPlatform)
lazy val noop = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(commonSettings)
.dependsOn(core)
.settings(
name := "log4cats-noop"
)
.nativeSettings(commonNativeSettings)

lazy val slf4j = project
.settings(commonSettings)
Expand All @@ -95,6 +98,10 @@ lazy val slf4j = project

lazy val commonSettings = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test
"org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test
)
)

lazy val commonNativeSettings = Seq(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "2.4.1").toMap
)
6 changes: 4 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
val sbtTypelevelVersion = "0.4.13"
addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion)
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion)

0 comments on commit c47bce0

Please sign in to comment.