nandi/libjavapublic Fork 0
29ba4c0
Commits
Clone
git clone https://git.rickub.com/nandi/libjava.git
git clone ssh://git@rickub.com/nandi/libjava.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Merge `just appimage` into the Clojure example branch

Both sides only touched the justfile and in different regions: the appimage
recipe appends after `jdk`, the clojure recipes sit above `build`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandithebull committed 2026-09-20T15:55:43-07:00 Browse files
29ba4c0 parents: 0f4b377 12f125f
modified justfile +64 -0
@@ -58,3 +58,67 @@ jdk:
5858 trap 'rm -rf "$d"' EXIT
5959 printf 'import libjava/config\necho javaHome\n' > "$d/jdk.nim"
6060 nim c -r --path:src --hints:off -d:libjavaNoLink --nimcache:"$d/cache" -o:"$d/jdk" "$d/jdk.nim"
61+
62+# The AppImage carries its own jlink'd Java runtime, so the demo binary is
63+# linked against $ORIGIN/../lib/jvm rather than the build machine's JDK.
64+# appimagetool is downloaded to build/tools on first use; set APPIMAGETOOL to
65+# point at your own copy instead.
66+#
67+# Bundle the example into a self-contained AppImage in out/
68+appimage: java
69+ #!/usr/bin/env bash
70+ set -euo pipefail
71+ home="${JAVA_HOME:-$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")}"
72+ arch=$(uname -m)
73+
74+ tool="${APPIMAGETOOL:-build/tools/appimagetool}"
75+ if [ ! -x "$tool" ]; then
76+ mkdir -p "$(dirname "$tool")"
77+ curl -fsSL -o "$tool" \
78+ "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$arch.AppImage"
79+ chmod +x "$tool"
80+ fi
81+
82+ rm -rf build/AppDir
83+ mkdir -p build/AppDir/usr/bin build/AppDir/build
84+
85+ # A minimal runtime: the demo only touches java.base.
86+ "$home/bin/jlink" --add-modules java.base \
87+ --strip-debug --no-header-files --no-man-pages --compress=2 \
88+ --output build/AppDir/usr/lib/jvm
89+
90+ # Headers from the build JDK; libjvm resolved next to the binary at runtime.
91+ # (nim links through a shell, so $ORIGIN needs escaping twice over.)
92+ nim c -d:release --path:src -d:libjavaNoLink --nimcache:build/nimcache \
93+ --passL:"-L$home/lib/server -ljvm -Wl,-rpath,\\\$ORIGIN/../lib/jvm/lib/server" \
94+ -o:build/AppDir/usr/bin/demo examples/demo.nim
95+
96+ # demo.nim looks for its classes at the relative path build/classes,
97+ # so AppRun runs from the AppDir root.
98+ cp -r build/classes build/AppDir/build/classes
99+
100+ printf '%s\n' \
101+ '#!/usr/bin/env bash' \
102+ 'cd "$(dirname "$(readlink -f "$0")")"' \
103+ 'exec ./usr/bin/demo "$@"' > build/AppDir/AppRun
104+ chmod +x build/AppDir/AppRun
105+
106+ printf '%s\n' \
107+ '[Desktop Entry]' \
108+ 'Type=Application' \
109+ 'Name=libjava demo' \
110+ 'Exec=AppRun' \
111+ 'Icon=libjava-demo' \
112+ 'Categories=Development;' \
113+ 'Terminal=true' > build/AppDir/libjava-demo.desktop
114+
115+ printf '%s\n' \
116+ '<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256">' \
117+ ' <rect width="256" height="256" rx="32" fill="#1b1f23"/>' \
118+ ' <text x="128" y="164" font-family="sans-serif" font-size="104"' \
119+ ' font-weight="bold" fill="#ffe873" text-anchor="middle">Jn</text>' \
120+ '</svg>' > build/AppDir/libjava-demo.svg
121+ ln -sf libjava-demo.svg build/AppDir/.DirIcon
122+
123+ mkdir -p out
124+ ARCH="$arch" "$tool" build/AppDir "out/libjava-demo-$arch.AppImage"
@@ -58,3 +58,67 @@ jdk:
58 trap 'rm -rf "$d"' EXIT58 trap 'rm -rf "$d"' EXIT
59 printf 'import libjava/config\necho javaHome\n' > "$d/jdk.nim"59 printf 'import libjava/config\necho javaHome\n' > "$d/jdk.nim"
60 nim c -r --path:src --hints:off -d:libjavaNoLink --nimcache:"$d/cache" -o:"$d/jdk" "$d/jdk.nim"60 nim c -r --path:src --hints:off -d:libjavaNoLink --nimcache:"$d/cache" -o:"$d/jdk" "$d/jdk.nim"
61+
62+# The AppImage carries its own jlink'd Java runtime, so the demo binary is
63+# linked against $ORIGIN/../lib/jvm rather than the build machine's JDK.
64+# appimagetool is downloaded to build/tools on first use; set APPIMAGETOOL to
65+# point at your own copy instead.
66+#
67+# Bundle the example into a self-contained AppImage in out/
68+appimage: java
69+ #!/usr/bin/env bash
70+ set -euo pipefail
71+ home="${JAVA_HOME:-$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")}"
72+ arch=$(uname -m)
73+
74+ tool="${APPIMAGETOOL:-build/tools/appimagetool}"
75+ if [ ! -x "$tool" ]; then
76+ mkdir -p "$(dirname "$tool")"
77+ curl -fsSL -o "$tool" \
78+ "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$arch.AppImage"
79+ chmod +x "$tool"
80+ fi
81+
82+ rm -rf build/AppDir
83+ mkdir -p build/AppDir/usr/bin build/AppDir/build
84+
85+ # A minimal runtime: the demo only touches java.base.
86+ "$home/bin/jlink" --add-modules java.base \
87+ --strip-debug --no-header-files --no-man-pages --compress=2 \
88+ --output build/AppDir/usr/lib/jvm
89+
90+ # Headers from the build JDK; libjvm resolved next to the binary at runtime.
91+ # (nim links through a shell, so $ORIGIN needs escaping twice over.)
92+ nim c -d:release --path:src -d:libjavaNoLink --nimcache:build/nimcache \
93+ --passL:"-L$home/lib/server -ljvm -Wl,-rpath,\\\$ORIGIN/../lib/jvm/lib/server" \
94+ -o:build/AppDir/usr/bin/demo examples/demo.nim
95+
96+ # demo.nim looks for its classes at the relative path build/classes,
97+ # so AppRun runs from the AppDir root.
98+ cp -r build/classes build/AppDir/build/classes
99+
100+ printf '%s\n' \
101+ '#!/usr/bin/env bash' \
102+ 'cd "$(dirname "$(readlink -f "$0")")"' \
103+ 'exec ./usr/bin/demo "$@"' > build/AppDir/AppRun
104+ chmod +x build/AppDir/AppRun
105+
106+ printf '%s\n' \
107+ '[Desktop Entry]' \
108+ 'Type=Application' \
109+ 'Name=libjava demo' \
110+ 'Exec=AppRun' \
111+ 'Icon=libjava-demo' \
112+ 'Categories=Development;' \
113+ 'Terminal=true' > build/AppDir/libjava-demo.desktop
114+
115+ printf '%s\n' \
116+ '<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256">' \
117+ ' <rect width="256" height="256" rx="32" fill="#1b1f23"/>' \
118+ ' <text x="128" y="164" font-family="sans-serif" font-size="104"' \
119+ ' font-weight="bold" fill="#ffe873" text-anchor="middle">Jn</text>' \
120+ '</svg>' > build/AppDir/libjava-demo.svg
121+ ln -sf libjava-demo.svg build/AppDir/.DirIcon
122+
123+ mkdir -p out
124+ ARCH="$arch" "$tool" build/AppDir "out/libjava-demo-$arch.AppImage"