Skip to content

Commit

Permalink
Add build with musl libc (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurinderu authored Jun 23, 2020
1 parent 3f083c3 commit a324995
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 27 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
tags:
- '*'
pull_request:

jobs:
test:
strategy:
Expand Down Expand Up @@ -40,17 +40,35 @@ jobs:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
libc: [default, musl]
exclude:
- os: macOS-latest
libc: musl
include:
- os: macOS-latest
url: https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.0.0/graalvm-ce-java11-darwin-amd64-20.0.0.tar.gz
artifact: scalafmt-macos
- os: ubuntu-latest
url: https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.0.0/graalvm-ce-java11-linux-amd64-20.0.0.tar.gz
artifact: scalafmt-linux
libc: default
artifact: scalafmt-linux-glibc
env:
- NATIVE_IMAGE_STATIC: true
- os: ubuntu-latest
libc: musl
artifact: scalafmt-linux-musl
env:
- NATIVE_IMAGE_STATIC: true
- NATIVE_IMAGE_MUSL: ${GITHUB_WORKSPACE}/bundle
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v6
- run: jabba install [email protected]=tgz+${{ matrix.url }}
- uses: olafurpg/setup-scala@v7
with:
java-version: [email protected]
- if: matrix.libc == 'musl'
name: Install musl bundle
run: |
wget https://github.com/gradinac/musl-bundle-example/releases/download/v1.0/musl.tar.gz
tar xvf musl.tar.gz
- run: bin/build-native-image.sh
env:
CI: true
Expand Down
3 changes: 0 additions & 3 deletions bin/build-native-image.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
set -eux
# NOTE(olafur): for some reason `jabba use ...` doesn't seem to work on GH Actions
export JAVA_HOME=$(jabba which --home [email protected])
export PATH=$JAVA_HOME/bin:$PATH
echo $JAVA_HOME
which gu
gu install native-image
sbt cli/graalvm-native-image:packageBin
Expand Down
28 changes: 10 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,16 @@ lazy val cli = project
scalacOptions ++= scalacJvmOptions.value,
mainClass in GraalVMNativeImage := Some("org.scalafmt.cli.Cli"),
graalVMNativeImageOptions ++= {
val reflectionFile =
Keys.sourceDirectory.in(Compile).value./("graal")./("reflection.json")
assert(reflectionFile.exists, "no such file: " + reflectionFile)
List(
"-H:+ReportUnsupportedElementsAtRuntime",
"-Dscalafmt.native-image=true",
"--initialize-at-build-time",
"--no-server",
"--enable-http",
"--enable-https",
"-H:EnableURLProtocols=http,https",
"--enable-all-security-services",
"--no-fallback",
s"-H:ReflectionConfigurationFiles=$reflectionFile",
"--allow-incomplete-classpath",
"-H:+ReportExceptionStackTraces"
//"--initialize-at-build-time=scala.Function1"
)
sys.env
.get("NATIVE_IMAGE_MUSL")
.map(path => s"-H:UseMuslC=$path")
.toSeq ++
sys.env
.get("NATIVE_IMAGE_STATIC")
.map(_.toBoolean)
.filter(identity)
.map(_ => "--static")
.toSeq
}
)
.dependsOn(coreJVM, dynamic)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Args=--no-server \
-Dscalafmt.native-image=true \
--no-fallback \
--enable-http \
--enable-https \
--enable-all-security-services \
--install-exit-handlers \
--initialize-at-build-time \
--verbose \
-H:EnableURLProtocols=http,https \
-H:+TraceClassInitialization \
-H:+RemoveSaturatedTypeFlows \
-H:+ReportExceptionStackTraces
File renamed without changes.

0 comments on commit a324995

Please sign in to comment.