|
5 | 5 | # Make a freshly-built Windows prebuilt self-contained so it can be used WITHOUT |
6 | 6 | # MSYS2/MinGW or any compiler on the target machine. We copy the addon's entire |
7 | 7 | # transitive MinGW DLL closure next to the .node, plus the GObject-Introspection |
8 | | -# typelibs it needs at runtime. |
| 8 | +# typelibs and runtime data it needs at runtime. |
| 9 | +# |
| 10 | +# The set of bundled libraries is driven by the curated seed list |
| 11 | +# windows/runtime-libraries.txt (also a user-facing reference). The exact |
| 12 | +# resolved DLL set is written to <binding-dir>/bundled-dlls.txt. |
9 | 13 | # |
10 | 14 | # Run inside the MINGW64 shell, after building. |
11 | 15 | # |
12 | 16 | # ./scripts/windows-bundle-runtime.sh lib/binding/node-v127-win32-x64 |
13 | 17 | # |
14 | 18 | set -euo pipefail |
15 | 19 |
|
16 | | -BINDING_DIR="${1:?usage: windows-bundle-runtime.sh <binding-dir>}" |
| 20 | +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) |
| 21 | + |
| 22 | +BINDING_DIR="${1:?usage: windows-bundle-runtime.sh <binding-dir> [runtime-libraries.txt]}" |
| 23 | +# The curated seed list lives in a text file so it doubles as user-facing |
| 24 | +# reference (windows/runtime-libraries.txt). Override with $2 if needed. |
| 25 | +LIBS_FILE="${2:-$SCRIPT_DIR/../windows/runtime-libraries.txt}" |
| 26 | +# MinGW bin dir the seed names resolve against. |
| 27 | +MB="${MINGW_BIN:-/mingw64/bin}" |
| 28 | + |
17 | 29 | NODE_FILE="$BINDING_DIR/node_gtk.node" |
18 | 30 |
|
19 | 31 | if [ ! -f "$NODE_FILE" ]; then |
20 | 32 | echo "error: $NODE_FILE not found" |
21 | 33 | ls -la "$BINDING_DIR" || true |
22 | 34 | exit 1 |
23 | 35 | fi |
| 36 | +if [ ! -f "$LIBS_FILE" ]; then |
| 37 | + echo "error: seed list $LIBS_FILE not found" |
| 38 | + exit 1 |
| 39 | +fi |
24 | 40 |
|
25 | 41 | # GObject-Introspection loads each namespace's shared library at runtime via |
26 | 42 | # g_module_open() when you call gi.require('Gtk', ...). Those libraries |
27 | | -# (libgio, libgtk, libgdk, libpango, libatk, libgdk_pixbuf, ...) are NOT linked |
28 | | -# by node_gtk.node, so ntldd on the addon alone misses them. We therefore seed |
29 | | -# the closure from the addon AND from the GTK runtime libraries themselves. |
30 | | -MB=/mingw64/bin |
31 | | -# Seed from the addon AND from every runtime library a real GTK4/Adwaita app |
32 | | -# pulls in (the quilx target: Gtk4 + Adw + GtkSourceView5 + Pango + GdkPixbuf + |
33 | | -# Graphene). Missing entries are skipped, so a few GTK3 names are kept too for |
34 | | -# robustness. |
35 | | -ENTRY_LIBS=( |
36 | | - "$NODE_FILE" |
37 | | - "$MB/libgirepository-1.0-1.dll" |
38 | | - "$MB/libgio-2.0-0.dll" |
39 | | - "$MB/libgtk-4-1.dll" |
40 | | - "$MB/libadwaita-1-0.dll" |
41 | | - "$MB/libgtksourceview-5-0.dll" |
42 | | - "$MB/libpango-1.0-0.dll" |
43 | | - "$MB/libpangocairo-1.0-0.dll" |
44 | | - "$MB/libgdk_pixbuf-2.0-0.dll" |
45 | | - "$MB/libgraphene-1.0-0.dll" |
46 | | - "$MB/libcairo-gobject-2.dll" |
47 | | -) |
| 43 | +# (libgio, libgtk, libgdk, libpango, libgdk_pixbuf, ...) are NOT linked by |
| 44 | +# node_gtk.node, so ntldd on the addon alone misses them. We therefore seed the |
| 45 | +# closure from the addon AND from the GTK runtime libraries listed in LIBS_FILE. |
| 46 | +echo "## Seed libraries from $LIBS_FILE" |
| 47 | +ENTRY_LIBS=("$NODE_FILE") |
| 48 | +while IFS= read -r line; do |
| 49 | + # strip comments and surrounding whitespace; skip blanks |
| 50 | + name="${line%%#*}" |
| 51 | + name="$(echo "$name" | tr -d '[:space:]')" |
| 52 | + [ -z "$name" ] && continue |
| 53 | + if [ -f "$MB/$name" ]; then |
| 54 | + ENTRY_LIBS+=("$MB/$name") |
| 55 | + echo " - $name" |
| 56 | + else |
| 57 | + echo " (skip missing seed $name)" |
| 58 | + fi |
| 59 | +done < "$LIBS_FILE" |
48 | 60 |
|
49 | 61 | echo "## Computing recursive DLL closure for the addon + GTK runtime" |
50 | 62 | # ntldd -R prints every transitive dependency with its resolved Windows path: |
@@ -73,7 +85,21 @@ sort -u /tmp/dll-closure.txt | while IFS= read -r u; do |
73 | 85 | copied=$((copied + 1)) |
74 | 86 | fi |
75 | 87 | done |
76 | | -echo "## DLLs bundled into $BINDING_DIR ($(ls "$BINDING_DIR"/*.dll | wc -l) total)" |
| 88 | +DLL_COUNT=$(ls "$BINDING_DIR"/*.dll 2>/dev/null | wc -l | tr -d ' ') |
| 89 | +echo "## DLLs bundled into $BINDING_DIR ($DLL_COUNT total)" |
| 90 | + |
| 91 | +# Write the exact set that shipped, as a reference manifest (ships in the |
| 92 | +# bundle and the artifact). Generated from the curated seed list above. |
| 93 | +MANIFEST="$BINDING_DIR/bundled-dlls.txt" |
| 94 | +{ |
| 95 | + echo "# bundled-dlls.txt — Windows DLLs shipped with this node-gtk prebuilt." |
| 96 | + echo "# GENERATED by scripts/windows-bundle-runtime.sh; do not edit by hand." |
| 97 | + echo "# Edit the curated seed list windows/runtime-libraries.txt instead." |
| 98 | + echo "# $DLL_COUNT DLLs, expanded from the seed list via 'ntldd -R'." |
| 99 | + echo "#" |
| 100 | + ( cd "$BINDING_DIR" && ls -1 *.dll 2>/dev/null | sort ) |
| 101 | +} > "$MANIFEST" |
| 102 | +echo "## Wrote manifest $MANIFEST" |
77 | 103 |
|
78 | 104 | echo "## Bundling GObject-Introspection typelibs" |
79 | 105 | TYPELIB_SRC=$(pkg-config --variable=typelibdir gobject-introspection-1.0 2>/dev/null || true) |
|
0 commit comments