@@ -3,14 +3,13 @@ set -euo pipefail
33
44#
55# Build script for GraalVM native image of nf-language-server
6- # Supports: linux/amd64, linux/arm64, darwin /arm64 (Apple Silicon)
6+ # Supports: linux/amd64, linux/arm64, macos/amd64, macos /arm64 (Apple Silicon)
77#
88# Usage:
99# ./build-native.sh [options]
1010#
1111# Options:
1212# --skip-test Skip testing the native binary
13- # --skip-package Skip packaging the binary
1413# --help, -h Show this help message
1514#
1615
@@ -86,49 +85,27 @@ check_requirements() {
8685# Detect platform
8786detect_platform () {
8887 OS=" $( uname -s | tr ' [:upper:]' ' [:lower:]' ) "
89- ARCH=" $( uname -m) "
90-
91- case " $ARCH " in
92- x86_64|amd64)
93- ARCH=" amd64"
94- ;;
95- aarch64|arm64)
96- ARCH=" arm64"
97- ;;
98- * )
99- log_error " Unsupported architecture: $ARCH "
100- exit 1
101- ;;
102- esac
10388
10489 case " $OS " in
105- linux)
106- PLATFORM=" linux-$ARCH "
107- BINARY_EXT=" "
108- ;;
109- darwin)
110- PLATFORM=" macos-$ARCH "
90+ linux|darwin)
11191 BINARY_EXT=" "
11292 ;;
11393 mingw* |msys* |cygwin* )
114- PLATFORM=" windows-$ARCH "
11594 BINARY_EXT=" .exe"
11695 ;;
11796 * )
11897 log_error " Unsupported OS: $OS "
11998 exit 1
12099 ;;
121100 esac
122-
123- log_info " Detected platform: $PLATFORM "
124101}
125102
126103# Build native image (includes shadow jar, tracing agent, and native compilation)
127104build_native_image () {
128105 log_info " Building native image (this includes JAR build and tracing agent)..."
129106 ./gradlew nativeCompile --no-configuration-cache --no-daemon
130107
131- local BINARY_PATH=" build/native/nativeCompile/nf-language-server ${BINARY_EXT} "
108+ local BINARY_PATH=" build/native/nativeCompile/nlsp ${BINARY_EXT} "
132109 if [[ -f " $BINARY_PATH " ]]; then
133110 log_info " Native image built successfully: $BINARY_PATH "
134111 ls -lh " $BINARY_PATH "
@@ -142,7 +119,7 @@ build_native_image() {
142119test_native_binary () {
143120 log_info " Testing native binary..."
144121
145- local BINARY_PATH=" build/native/nativeCompile/nf-language-server ${BINARY_EXT} "
122+ local BINARY_PATH=" build/native/nativeCompile/nlsp ${BINARY_EXT} "
146123 local OUTPUT
147124
148125 OUTPUT=$( ./lsp-simulator.sh | " $BINARY_PATH " 2>&1 | head -20)
@@ -156,30 +133,10 @@ test_native_binary() {
156133 fi
157134}
158135
159- # Package the binary
160- package_binary () {
161- log_info " Packaging binary for $PLATFORM ..."
162-
163- local BINARY_PATH=" build/native/nativeCompile/nf-language-server${BINARY_EXT} "
164- local DIST_DIR=" build/dist"
165- local ARCHIVE_NAME=" nf-language-server-$PLATFORM "
166-
167- mkdir -p " $DIST_DIR "
168-
169- if [[ " $OS " == " darwin" ]] || [[ " $OS " == " linux" ]]; then
170- tar -czvf " $DIST_DIR /$ARCHIVE_NAME .tar.gz" -C " build/native/nativeCompile" " nf-language-server${BINARY_EXT} "
171- log_info " Created: $DIST_DIR /$ARCHIVE_NAME .tar.gz"
172- else
173- # Windows - create zip
174- (cd " build/native/nativeCompile" && zip -r " ../../../$DIST_DIR /$ARCHIVE_NAME .zip" " nf-language-server${BINARY_EXT} " )
175- log_info " Created: $DIST_DIR /$ARCHIVE_NAME .zip"
176- fi
177- }
178136
179137# Main build process
180138main () {
181139 local SKIP_TEST=false
182- local SKIP_PACKAGE=false
183140
184141 # Parse arguments
185142 while [[ $# -gt 0 ]]; do
@@ -188,18 +145,13 @@ main() {
188145 SKIP_TEST=true
189146 shift
190147 ;;
191- --skip-package)
192- SKIP_PACKAGE=true
193- shift
194- ;;
195148 --help|-h)
196149 echo " Usage: $0 [options]"
197150 echo " "
198151 echo " Build GraalVM native image for nf-language-server"
199152 echo " "
200153 echo " Options:"
201154 echo " --skip-test Skip testing the native binary"
202- echo " --skip-package Skip packaging the binary"
203155 echo " --help, -h Show this help message"
204156 echo " "
205157 echo " Requirements:"
@@ -225,16 +177,9 @@ main() {
225177 test_native_binary
226178 fi
227179
228- if [[ " $SKIP_PACKAGE " != " true" ]]; then
229- package_binary
230- fi
231-
232180 echo " "
233181 log_info " Build completed successfully!"
234- log_info " Binary: build/native/nativeCompile/nf-language-server${BINARY_EXT} "
235- if [[ " $SKIP_PACKAGE " != " true" ]]; then
236- log_info " Package: build/dist/nf-language-server-$PLATFORM .tar.gz"
237- fi
182+ log_info " Binary: build/native/nativeCompile/nlsp${BINARY_EXT} "
238183}
239184
240185main " $@ "
0 commit comments