Migrate GraalVM configuration to jar (#973)

This commit is contained in:
Eric Dallo 2021-08-22 18:19:28 -03:00 committed by GitHub
parent ef0af1244d
commit 72d3afa698
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 89 deletions

View file

@ -85,20 +85,11 @@ jobs:
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- name: Reflection artifact
run: |
cp reflection.json babashka-${{ steps.babashka-version.outputs.version }}-reflection.json
- uses: actions/upload-artifact@v1
with:
name: jar
path: target/babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
- uses: actions/upload-artifact@v1
with:
name: reflection.json
path: babashka-${{ steps.babashka-version.outputs.version }}-reflection.json
linux:
if: "!contains(github.event.head_commit.message, 'skip ci')"
needs: [jvm]
@ -115,11 +106,6 @@ jobs:
name: jar
path: .
- uses: actions/download-artifact@v1
with:
name: reflection.json
path: .
- name: Cache deps
uses: actions/cache@v1
id: cache-deps
@ -157,7 +143,6 @@ jobs:
export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
export BABASHKA_XMX="-J-Xmx6g"
export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0"
cp babashka-${{ steps.babashka-version.outputs.version }}-reflection.json reflection.json
script/compile
- name: Test binary
@ -196,11 +181,6 @@ jobs:
name: jar
path: .
- uses: actions/download-artifact@v1
with:
name: reflection.json
path: .
- name: Cache deps
uses: actions/cache@v1
id: cache-deps
@ -239,7 +219,6 @@ jobs:
export BABASHKA_XMX="-J-Xmx6g"
export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0"
export BABASHKA_STATIC=true
cp babashka-${{ steps.babashka-version.outputs.version }}-reflection.json reflection.json
script/compile
- name: Test binary
@ -279,11 +258,6 @@ jobs:
name: jar
path: .
- uses: actions/download-artifact@v1
with:
name: reflection.json
path: .
- name: Cache GraalVM
uses: actions/cache@v1
id: cache-graalvm
@ -312,7 +286,6 @@ jobs:
export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
export BABASHKA_XMX="-J-Xmx6g"
export GRAALVM_HOME="$HOME/graalvm-ce-java11-21.1.0/Contents/Home"
cp babashka-${{ steps.babashka-version.outputs.version }}-reflection.json reflection.json
script/compile
- name: Test binary

2
.gitignore vendored
View file

@ -16,7 +16,7 @@ pom.xml.asc
!test-resources/babashka/src_for_classpath_test/foo.jar
!test-resources/pom.xml
.cpcache
*reflection.json
*reflect-config.json
/tmp
/reports
*.dylib

View file

@ -87,6 +87,7 @@
com.grammarly/omniconf {:mvn/version "0.4.3"}
crispin/crispin {:mvn/version "0.3.8"}
org.clojure/data.json {:mvn/version "2.4.0"}
clj-commons/multigrep {:mvn/version "0.5.0"}
amperity/vault-clj {:mvn/version "1.0.4"}}
:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil

View file

@ -0,0 +1,23 @@
ImageName=bb
Args=-H:+ReportExceptionStackTraces \
-J-Dborkdude.dynaload.aot=true \
-H:IncludeResources=BABASHKA_VERSION \
-H:IncludeResources=META-INF/babashka/.* \
-H:IncludeResources=SCI_VERSION \
--initialize-at-build-time \
-H:Log=registerResource: \
-H:EnableURLProtocols=http,https,jar \
--enable-all-security-services \
-H:+JNI \
--no-server \
--report-unsupported-elements-at-runtime \
--initialize-at-run-time=org.postgresql.sspi.SSPIClient \
--initialize-at-run-time=org.httpkit.client.ClientSslEngineFactory\$SSLHolder \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileReader \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileReader \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.MixerProvider \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.FormatConversionProvider \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileWriter \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiDeviceProvider \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.SoundbankReader \
-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileWriter

View file

@ -38,41 +38,18 @@ fi
BABASHKA_BINARY=${BABASHKA_BINARY:-"bb"}
args=( "-jar" "$BABASHKA_JAR"
args=("-jar" "$BABASHKA_JAR"
"-H:Name=$BABASHKA_BINARY"
"-H:+ReportExceptionStackTraces"
"-J-Dborkdude.dynaload.aot=true"
"-H:IncludeResources=BABASHKA_VERSION"
"-H:IncludeResources=META-INF/babashka/.*"
"-H:IncludeResources=SCI_VERSION"
"-H:ReflectionConfigurationFiles=reflection.json"
"--initialize-at-build-time"
#"-H:+PrintAnalysisCallTree"
# "-H:+PrintAnalysisCallTree"
# "-H:+DashboardAll"
# "-H:DashboardDump=reports/dump"
# "-H:+DashboardPretty"
# "-H:+DashboardJson"
"-H:Log=registerResource:"
"-H:EnableURLProtocols=http,https,jar"
"--enable-all-security-services"
"-H:+JNI"
"--verbose"
"--no-fallback"
"--no-server"
"--report-unsupported-elements-at-runtime"
"--initialize-at-run-time=org.postgresql.sspi.SSPIClient"
"--initialize-at-run-time=org.httpkit.client.ClientSslEngineFactory\$SSLHolder"
"--native-image-info"
"--verbose"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileReader"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileReader"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.MixerProvider"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.FormatConversionProvider"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileWriter"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiDeviceProvider"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.SoundbankReader"
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileWriter"
"$BABASHKA_XMX" )
"$BABASHKA_XMX")
BABASHKA_STATIC=${BABASHKA_STATIC:-}
BABASHKA_MUSL=${BABASHKA_MUSL:-}

View file

@ -27,30 +27,8 @@ call %GRAALVM_HOME%\bin\native-image.cmd ^
"-jar" "target/babashka-%BABASHKA_VERSION%-standalone.jar" ^
"-H:Name=bb" ^
"-H:+ReportExceptionStackTraces" ^
"-J-Dclojure.spec.skip-macros=true" ^
"-J-Dclojure.compiler.direct-linking=true" ^
"-H:IncludeResources=BABASHKA_VERSION" ^
"-H:IncludeResources=SCI_VERSION" ^
"-H:IncludeResources=META-INF/babashka/.*" ^
"-H:ReflectionConfigurationFiles=reflection.json" ^
"--initialize-at-build-time" ^
"--initialize-at-run-time=org.postgresql.sspi.SSPIClient" ^
"--initialize-at-run-time=org.httpkit.client.ClientSslEngineFactory$SSLHolder" ^
"-H:EnableURLProtocols=http,https,jar" ^
"--enable-all-security-services" ^
"-H:+JNI" ^
"-H:Log=registerResource:" ^
"--no-fallback" ^
"--verbose" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileReader" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileReader" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.MixerProvider" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.FormatConversionProvider" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.sampled.spi.AudioFileWriter" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiDeviceProvider" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.SoundbankReader" ^
"-H:ServiceLoaderFeatureExcludeServices=javax.sound.midi.spi.MidiFileWriter" ^
"-H:ServiceLoaderFeatureExcludeServices=java.awt.Toolkit" ^
"--no-fallback" ^
"%BABASHKA_XMX%"
if %errorlevel% neq 0 exit /b %errorlevel%

View file

@ -6,4 +6,4 @@
(def version (str/trim (slurp (io/file "resources" "BABASHKA_VERSION"))))
(sh "lein" "with-profiles" "+reflection" "run")
(io/copy (io/file "reflection.json") (io/file (str "babashka-" version "-reflection.json")))
(io/copy (io/file "resources/META-INF/native-image/babashka/babashka/reflect-config.json") (io/file (str "babashka-" version "-reflection.json")))

View file

@ -474,12 +474,12 @@
all-entries))
(defn generate-reflection-file
"Generate reflection.json file"
"Generate reflect-config.json file"
[& args]
(let [all-entries (reflection-file-entries)]
(spit (or
(first args)
"reflection.json") (json/generate-string all-entries {:pretty true}))))
"resources/META-INF/native-image/babashka/babashka/reflect-config.json") (json/generate-string all-entries {:pretty true}))))
(defn public-declared-method? [c m]
(and (= c (.getDeclaringClass m))