Skip to content

Commit f74d13f

Browse files
authored
Merge pull request #42 from http4s/pr/native
Cross-build for Native
2 parents b2c33cd + 5f6414f commit f74d13f

File tree

5 files changed

+55
-8
lines changed

5 files changed

+55
-8
lines changed

.github/workflows/ci.yml

+41-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
os: [ubuntu-latest]
3232
scala: [2.12.16, 3.1.3, 2.13.8]
3333
java: [temurin@8, temurin@11]
34-
project: [rootJS, rootJVM]
34+
project: [rootJS, rootJVM, rootNative]
3535
sjsStage: [FastOptStage, FullOptStage]
3636
exclude:
3737
- scala: 2.12.16
@@ -40,8 +40,12 @@ jobs:
4040
java: temurin@11
4141
- project: rootJS
4242
java: temurin@11
43+
- project: rootNative
44+
java: temurin@11
4345
- project: rootJVM
4446
sjsStage: FullOptStage
47+
- project: rootNative
48+
sjsStage: FullOptStage
4549
runs-on: ${{ matrix.os }}
4650
steps:
4751
- name: Checkout current branch (full)
@@ -104,6 +108,10 @@ jobs:
104108
if: matrix.project == 'rootJS'
105109
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global/scalaJSStage := ${{ matrix.sjsStage }}'' Test/scalaJSLinkerResult'
106110

111+
- name: nativeLink
112+
if: matrix.project == 'rootNative'
113+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global/scalaJSStage := ${{ matrix.sjsStage }}'' Test/nativeLink'
114+
107115
- name: Test
108116
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global/scalaJSStage := ${{ matrix.sjsStage }}'' test'
109117

@@ -125,11 +133,11 @@ jobs:
125133

126134
- name: Make target directories
127135
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
128-
run: mkdir -p target .js/target hpack/jvm/target .jvm/target .native/target hpack/js/target project/target
136+
run: mkdir -p target .js/target hpack/jvm/target hpack/native/target .jvm/target .native/target hpack/js/target project/target
129137

130138
- name: Compress target directories
131139
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
132-
run: tar cf targets.tar target .js/target hpack/jvm/target .jvm/target .native/target hpack/js/target project/target
140+
run: tar cf targets.tar target .js/target hpack/jvm/target hpack/native/target .jvm/target .native/target hpack/js/target project/target
133141

134142
- name: Upload target directories
135143
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
@@ -218,6 +226,16 @@ jobs:
218226
tar xf targets.tar
219227
rm targets.tar
220228
229+
- name: Download target directories (2.12.16, rootNative, FastOptStage)
230+
uses: actions/download-artifact@v2
231+
with:
232+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-rootNative-FastOptStage
233+
234+
- name: Inflate target directories (2.12.16, rootNative, FastOptStage)
235+
run: |
236+
tar xf targets.tar
237+
rm targets.tar
238+
221239
- name: Download target directories (3.1.3, rootJS, FastOptStage)
222240
uses: actions/download-artifact@v2
223241
with:
@@ -238,6 +256,16 @@ jobs:
238256
tar xf targets.tar
239257
rm targets.tar
240258
259+
- name: Download target directories (3.1.3, rootNative, FastOptStage)
260+
uses: actions/download-artifact@v2
261+
with:
262+
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.3-rootNative-FastOptStage
263+
264+
- name: Inflate target directories (3.1.3, rootNative, FastOptStage)
265+
run: |
266+
tar xf targets.tar
267+
rm targets.tar
268+
241269
- name: Download target directories (2.13.8, rootJS, FastOptStage)
242270
uses: actions/download-artifact@v2
243271
with:
@@ -258,6 +286,16 @@ jobs:
258286
tar xf targets.tar
259287
rm targets.tar
260288
289+
- name: Download target directories (2.13.8, rootNative, FastOptStage)
290+
uses: actions/download-artifact@v2
291+
with:
292+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative-FastOptStage
293+
294+
- name: Inflate target directories (2.13.8, rootNative, FastOptStage)
295+
run: |
296+
tar xf targets.tar
297+
rm targets.tar
298+
261299
- name: Import signing key
262300
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
263301
run: echo $PGP_SECRET | base64 -di | gpg --import

build.sbt

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ ThisBuild / tlFatalWarningsInCi := false
99

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

1617
lazy val root = tlCrossRootProject.aggregate(hpack)
1718

18-
lazy val hpack = crossProject(JVMPlatform, JSPlatform)
19+
lazy val hpack = crossProject(JVMPlatform, JSPlatform, NativePlatform)
1920
.in(file("hpack"))
2021
.settings(
2122
name := "hpack",
@@ -34,5 +35,11 @@ lazy val hpack = crossProject(JVMPlatform, JSPlatform)
3435
.jsSettings(
3536
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
3637
)
38+
.nativeSettings(
39+
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "1.0.4").toMap,
40+
unusedCompileDependenciesTest := {},
41+
nativeConfig ~= (_.withEmbedResources(true)),
42+
)
3743
.jvmEnablePlugins(NoPublishPlugin)
3844
.jsEnablePlugins(ScalaJSJUnitPlugin)
45+
.nativeEnablePlugins(ScalaNativeJUnitPlugin)

hpack/jvm/src/test/scala/org/http4s/hpack/TestCasePlatform.scala hpack/jvm-native/src/test/scala/org/http4s/hpack/TestCasePlatform.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ package org.http4s.hpack
3333

3434
import io.circe.jawn
3535

36-
import java.io.File
36+
import scala.io.Source
3737

3838
trait TestCasePlatform {
3939

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

4545
}

project/plugins.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.14.4")
22
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")
3+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.7")
4+
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")

0 commit comments

Comments
 (0)