Skip to content

Commit

Permalink
added script to build native using graalvm
Browse files Browse the repository at this point in the history
  • Loading branch information
erdos committed Mar 13, 2019
1 parent bbeb111 commit 6ebb36e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
38 changes: 38 additions & 0 deletions build-native-image.sh
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# Compiles a standalone stencil application to a native executable using GraalVM.

set -e

# cd to script dir
cd "$(dirname "$0")"

# check if native-image command is available
hash native-image 2>/dev/null || { echo >&2 "Missing native-image command. Aborting."; exit 1; }

# check if strip command is available
hash strip 2>/dev/null || { echo >&2 "Missing strip command. Aborting."; exit 2; }

# check if uberjar has been compiled so far
TARGET_JAR=$(echo target/*-standalone.jar)

if [ ! -f "$TARGET_JAR" ]
then
echo "Stencil standalone is not compiled. Compile it first!"
exit 4
fi

OUTPUT=stencil-native

# build it
native-image \
-jar $TARGET_JAR \
-H:ReflectionConfigurationFiles=./reflectconfig \
-H:IncludeResources='.*.txt$' \
--report-unsupported-elements-at-runtime \
$OUTPUT

# remove unused symbols and sections
strip $OUTPUT

echo "Generated $OUTPUT file!"
14 changes: 14 additions & 0 deletions reflectconfig
@@ -0,0 +1,14 @@
[
{
"name" : "com.sun.xml.internal.stream.XMLInputFactoryImpl",
"methods" : [
{ "name" : "<init>", "parameterTypes" : [] }
]
},
{
"name" : "com.sun.xml.internal.stream.XMLOutputFactoryImpl",
"methods" : [
{ "name" : "<init>", "parameterTypes" : [] }
]
}
]

0 comments on commit 6ebb36e

Please sign in to comment.