Skip to content

Commit e8d008e

Browse files
committed
feat: add functions for copying JRE with symlinks and printing Windows JRE diagnostics
1 parent 499c514 commit e8d008e

1 file changed

Lines changed: 53 additions & 1 deletion

File tree

bindings/python/scripts/build-native.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,53 @@ prune_windows_jre_artifacts() {
9393
echo -e "${CYAN}📋 Removed Windows JRE artifacts: ${YELLOW}${removed_count}${NC}"
9494
}
9595

96+
copy_tree_with_symlinks() {
97+
local src_dir="$1"
98+
local dest_dir="$2"
99+
local python_bin="$3"
100+
101+
"$python_bin" - "$src_dir" "$dest_dir" << 'PY'
102+
import shutil
103+
import sys
104+
from pathlib import Path
105+
106+
src = Path(sys.argv[1])
107+
dest = Path(sys.argv[2])
108+
109+
if dest.exists():
110+
shutil.rmtree(dest)
111+
112+
shutil.copytree(src, dest, symlinks=True)
113+
PY
114+
}
115+
116+
print_windows_jre_diagnostics() {
117+
local jre_dir="$1"
118+
local python_bin="$2"
119+
local label="$3"
120+
121+
echo -e "${CYAN}🔎 Windows JRE diagnostics (${label})...${NC}"
122+
123+
"$python_bin" - "$jre_dir" << 'PY'
124+
import os
125+
import sys
126+
from pathlib import Path
127+
128+
jre_dir = Path(sys.argv[1])
129+
files = [path for path in jre_dir.rglob('*') if path.is_file()]
130+
symlinks = [path for path in jre_dir.rglob('*') if path.is_symlink()]
131+
132+
print(f" Files: {len(files)}")
133+
print(f" Symlinks: {len(symlinks)}")
134+
135+
largest = sorted(files, key=lambda path: path.stat().st_size, reverse=True)[:15]
136+
for path in largest:
137+
size_mb = path.stat().st_size / 1024 / 1024
138+
rel_path = path.relative_to(jre_dir)
139+
print(f" {size_mb:8.1f} MB {rel_path}")
140+
PY
141+
}
142+
96143
# Check for Java (needed for jlink and JPype build)
97144
if ! command -v java &> /dev/null; then
98145
echo -e "${RED}❌ Java not found${NC}"
@@ -245,6 +292,7 @@ if [[ "$PLATFORM" == windows/* ]]; then
245292
prune_windows_jre_artifacts "$PY_BINDINGS_DIR/temp_jre"
246293
JRE_SIZE=$(du -sh "$PY_BINDINGS_DIR/temp_jre" | cut -f1)
247294
echo -e "${CYAN}📊 JRE size after Windows cleanup: ${YELLOW}${JRE_SIZE}${NC}"
295+
print_windows_jre_diagnostics "$PY_BINDINGS_DIR/temp_jre" "$PYTHON_WITH_BUILD" "temp_jre"
248296
fi
249297

250298
# Step 3: Copy JRE to package (JARs already filtered in place)
@@ -253,7 +301,11 @@ echo -e "${CYAN}📦 Preparing package...${NC}"
253301
# Build and copy JRE
254302
rm -rf "$PY_BINDINGS_DIR/src/arcadedb_embedded/jre"
255303
mkdir -p "$PY_BINDINGS_DIR/src/arcadedb_embedded/jre"
256-
cp -R "$PY_BINDINGS_DIR/temp_jre"/* "$PY_BINDINGS_DIR/src/arcadedb_embedded/jre/"
304+
copy_tree_with_symlinks "$PY_BINDINGS_DIR/temp_jre" "$PY_BINDINGS_DIR/src/arcadedb_embedded/jre" "$PYTHON_WITH_BUILD"
305+
306+
if [[ "$PLATFORM" == windows/* ]]; then
307+
print_windows_jre_diagnostics "$PY_BINDINGS_DIR/src/arcadedb_embedded/jre" "$PYTHON_WITH_BUILD" "staged package jre"
308+
fi
257309

258310
JAR_COUNT=$(ls -1 "$JARS_DIR"/*.jar | wc -l)
259311
echo -e "${GREEN}✅ Package prepared (${JAR_COUNT} JARs + JRE)${NC}"

0 commit comments

Comments
 (0)