Added GraalVM configuration to create a native binary (#452)

* Initial GraalVM configuration

* graalvm reflection changes for v0.7.4

* graalvm removed unneeded options for native-image

* updated gradle plugin org.mikeneck.graalvm-native-image to 1.1.0

* moved from gradle graalvm-native-image plugin to native-build.sh

* added missing graalvm reflection config for receive

* refactored native-build.sh to a gradle task buildNativeBinary
This commit is contained in:
Michael Kebe 2021-01-23 11:11:50 +01:00 committed by GitHub
parent cb596c15f1
commit a709447536
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 1590 additions and 0 deletions

View file

@ -83,6 +83,20 @@ dependencies. If you have a recent gradle version installed, you can replace `./
./gradlew distTar
### Building a native binary with GraalVM
It is possible to build a native binary with [GraalVM](https://www.graalvm.org).
1. [Install GraalVM and setup the enviroment](https://www.graalvm.org/docs/getting-started/#install-graalvm)
2. [Install prerequisites](https://www.graalvm.org/reference-manual/native-image/#prerequisites)
2. Execute Gradle:
./gradle nativeImage
The binary is available at
build/native-image/signal-cli
## Troubleshooting
If you use a version of the Oracle JRE and get an InvalidKeyException you need to enable unlimited strength crypto. See https://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters for instructions.

View file

@ -74,3 +74,39 @@ task checkLibVersions {
}
}
}
task buildNativeBinary {
dependsOn("build")
doLast {
def graalVMHome = System.getenv("GRAALVM_HOME")
if (!graalVMHome) {
throw new GradleException('Required GRAALVM_HOME environment variable not set.')
}
def nativeBinaryOutputPath = "$buildDir/native-image"
def nativeBinaryName = "signal-cli"
mkdir nativeBinaryOutputPath
exec {
workingDir "."
commandLine "$graalVMHome/bin/native-image",
"-H:Path=$nativeBinaryOutputPath",
"-H:Name=$nativeBinaryName",
"-H:JNIConfigurationFiles=",
"-H:DynamicProxyConfigurationFiles=",
"-H:ReflectionConfigurationFiles=",
"-H:ResourceConfigurationFiles=",
"--no-fallback",
"--allow-incomplete-classpath",
"--report-unsupported-elements-at-runtime",
"--enable-url-protocols=http,https",
"--enable-https",
"--enable-all-security-services",
"-H:ResourceConfigurationFiles=graalvm-config-dir/resource-config.json",
"-H:ReflectionConfigurationFiles=graalvm-config-dir/reflect-config.json",
"-cp",
sourceSets.main.runtimeClasspath.asPath,
project.mainClassName
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
{
"resources":{
"includes":[
{"pattern":"com/google/i18n/phonenumbers/data/.*"},
{"pattern":"libzkgroup.so"},
{"pattern":"org/asamk/signal/manager/ias.store"},
{"pattern":"org/asamk/signal/manager/whisper.store"},
{"pattern":"org/slf4j/impl/StaticLoggerBinder.class"}
]},
"bundles":[{"name":"net.sourceforge.argparse4j.internal.ArgumentParserImpl"}]
}