forked from tinystruct/tinystruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·50 lines (41 loc) · 1.17 KB
/
build.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# Build script for tinystruct native image using POSIX sh
# Usage: ./build.sh
set -eu
# Enable debugging output
set -x
# Ensure GRAALVM_HOME is set
if [ -z "${GRAALVM_HOME:-}" ]; then
echo "Error: GRAALVM_HOME is not set."
echo "Please set it to your GraalVM installation directory."
exit 1
fi
# Clean and build the project
./mvnw clean install
# Reload profile if exists
if [ -f "$HOME/.profile" ]; then
. "$HOME/.profile"
elif [ -f "$HOME/.bash_profile" ]; then
. "$HOME/.bash_profile"
fi
# Define variables
TARGET_JAR="./target/tinystruct-1.7.16.jar"
NATIVE_NAME="dispatcher-native"
MAIN_CLASS="org.tinystruct.system.Dispatcher"
CONFIG_DIR="./bin/.metadata"
# Verify target JAR exists
if [ ! -f "$TARGET_JAR" ]; then
echo "Error: Target JAR not found at $TARGET_JAR"
exit 1
fi
# Build native image
"$GRAALVM_HOME/bin/native-image" \
-H:ConfigurationFileDirectories="$CONFIG_DIR" \
--no-fallback \
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED \
-cp "$TARGET_JAR" \
-H:Name="$NATIVE_NAME" \
-H:Class="$MAIN_CLASS" \
-H:+ReportExceptionStackTraces \
-H:+ReportUnsupportedElementsAtRuntime
echo "Native image '$NATIVE_NAME' successfully built!"