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 10, 2022
1 parent 109392b commit fdf67f2
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 9 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
os: [ubuntu-latest]
scala: [2.12.16, 3.1.3, 2.13.8]
java: [temurin@8, temurin@11]
project: [rootJS, rootJVM]
project: [rootJS, rootJVM, rootNative]
sjsStage: [FastOptStage, FullOptStage]
exclude:
- scala: 2.12.16
Expand All @@ -40,8 +40,12 @@ jobs:
java: temurin@11
- project: rootJS
java: temurin@11
- project: rootNative
java: temurin@11
- project: rootJVM
sjsStage: FullOptStage
- project: rootNative
sjsStage: FullOptStage
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand Down Expand Up @@ -104,6 +108,10 @@ jobs:
if: matrix.project == 'rootJS'
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global/scalaJSStage := ${{ matrix.sjsStage }}'' Test/scalaJSLinkerResult'

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

- name: Test
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global/scalaJSStage := ${{ matrix.sjsStage }}'' test'

Expand All @@ -125,11 +133,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 target .js/target hpack/jvm/target .jvm/target .native/target hpack/js/target project/target
run: mkdir -p target .js/target hpack/jvm/target hpack/native/target .jvm/target .native/target hpack/js/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 target .js/target hpack/jvm/target .jvm/target .native/target hpack/js/target project/target
run: tar cf targets.tar target .js/target hpack/jvm/target hpack/native/target .jvm/target .native/target hpack/js/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 @@ -218,6 +226,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.16, rootNative, FastOptStage)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootNative-FastOptStage

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

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

- name: Inflate target directories (2.13.8, rootNative, FastOptStage)
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
15 changes: 11 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ ThisBuild / tlFatalWarningsInCi := false

ThisBuild / githubWorkflowJavaVersions := List("8", "11").map(JavaSpec.temurin(_))
ThisBuild / githubWorkflowBuildMatrixAdditions += "sjsStage" -> List("FastOptStage", "FullOptStage")
ThisBuild / githubWorkflowBuildMatrixExclusions +=
MatrixExclude(Map("project" -> "rootJVM", "sjsStage" -> "FullOptStage"))
ThisBuild / githubWorkflowBuildMatrixExclusions ++= List("rootJVM", "rootNative").map { project =>
MatrixExclude(Map("project" -> project, "sjsStage" -> "FullOptStage"))
}
ThisBuild / githubWorkflowBuildSbtStepPreamble += "set Global/scalaJSStage := ${{ matrix.sjsStage }}"

lazy val root = tlCrossRootProject.aggregate(hpack)

lazy val hpack = crossProject(JVMPlatform, JSPlatform)
lazy val hpack = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.in(file("hpack"))
.settings(
name := "hpack",
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.8.0" % Test,
"io.circe" %%% "circe-parser" % "0.14.2" % Test,
"com.armanbilge" %%% "circe-parser" % "0.14.2-158-f15be0d" % Test,
"com.lihaoyi" %%% "sourcecode" % "0.3.0" % Test,
),
)
Expand All @@ -34,5 +35,11 @@ lazy val hpack = crossProject(JVMPlatform, JSPlatform)
.jsSettings(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
)
.nativeSettings(
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "1.0.4").toMap,
unusedCompileDependenciesTest := {},
nativeConfig ~= (_.withEmbedResources(true)),
)
.jvmEnablePlugins(NoPublishPlugin)
.jsEnablePlugins(ScalaJSJUnitPlugin)
.nativeEnablePlugins(ScalaNativeJUnitPlugin)
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ package org.http4s.hpack

import io.circe.jawn

import java.io.File
import scala.io.Source

trait TestCasePlatform {

def load(fileName: String): TestCase =
jawn
.decodeFile[TestCase](new File(getClass.getResource(fileName).toURI()))
.decode[TestCase](Source.fromInputStream(getClass.getResourceAsStream(fileName)).mkString)
.fold(throw _, identity(_))

}
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.4")
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")

0 comments on commit fdf67f2

Please sign in to comment.