-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile-macos.sh
More file actions
executable file
·104 lines (89 loc) · 3.61 KB
/
Copy pathcompile-macos.sh
File metadata and controls
executable file
·104 lines (89 loc) · 3.61 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# compile-macos.sh - compiles console-error-scanner into a standalone macOS
# binary with Nuitka, with a bundled Chromium headless shell.
#
# Output: dist/console-error-scanner/console-error-scanner + browsers/, and
# dist/console-error-scanner-vX.Y.Z-macos-<arch>.tar.gz ready to hand out.
#
# Build machine needs the Xcode Command Line Tools (clang): xcode-select --install
#
# Nuitka ad-hoc signs the binary automatically. On download, macOS quarantines
# it - the recipient clears it once:
# xattr -dr com.apple.quarantine console-error-scanner
# No .app bundle (this is a TUI). The arch (arm64/x86_64) is host-bound.
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
entry="$root/src/console_error_scanner/__main__.py"
init_py="$root/src/console_error_scanner/__init__.py"
out_dir="$root/dist"
dist_dir="$out_dir/console-error-scanner"
arch="$(uname -m)"
if ! command -v clang >/dev/null 2>&1; then
echo "Fehlt: clang - bitte Xcode Command Line Tools installieren: xcode-select --install" >&2
exit 1
fi
# venv mit dem Lockfile abgleichen - VOR der python-Ermittlung
if command -v uv >/dev/null 2>&1; then
echo "Syncing venv (uv sync --inexact)..."
uv sync --inexact --project "$root"
fi
if [ -x "$root/.venv/bin/python" ]; then
python="$root/.venv/bin/python"
else
python="python3"
fi
echo "Checking Playwright Chromium..."
"$python" -m playwright install chromium
# portables sed - 'grep -oP' gibt es auf dem BSD-grep von macOS nicht
version="$(sed -n 's/^__version__ *= *"\([^"]*\)".*/\1/p' "$init_py")"
if [ -z "$version" ]; then
echo "Konnte __version__ nicht aus $init_py lesen" >&2
exit 1
fi
echo "Compiling console-error-scanner v$version ($arch) with Nuitka..."
rm -rf "$dist_dir"
started=$(date +%s)
# Den Playwright-Node-Treiber NICHT explizit einschliessen - das macht Nuitkas
# eingebautes playwright-Plugin. Ein zusaetzliches --include-package-data=
# playwright kollidiert mit dem Plugin ("data file
# 'playwright/driver/node' conflicts with exe").
# Nuitka als Build-Tool sicherstellen (kein Dev-Dep, wird ad-hoc installiert).
# 'uv sync' ohne --inexact entfernt es wieder, daher: nach jedem Sync pruefen.
if ! "$python" -m nuitka --version >/dev/null 2>&1; then
echo "Nuitka fehlt im venv - installiere..."
uv pip install nuitka || { echo "Nuitka-Installation fehlgeschlagen" >&2; exit 1; }
fi
"$python" -m nuitka \
--standalone \
--assume-yes-for-downloads \
--remove-output \
--include-package=console_error_scanner \
--include-package-data=console_error_scanner \
--output-dir="$out_dir" \
--output-filename=console-error-scanner \
"$entry"
if [ -d "$out_dir/__main__.dist" ]; then
mv "$out_dir/__main__.dist" "$dist_dir"
fi
# Nur die neueste Headless-Shell mitbuendeln (~265 MB). Alle Use-Cases laufen
# headless - das volle Chromium (~407 MB) wird nie gebraucht.
echo "Bundling Chromium headless shell..."
browsers_dir="$dist_dir/browsers"
mkdir -p "$browsers_dir"
cache="${HOME}/Library/Caches/ms-playwright"
latest="$(ls -d "$cache/chromium_headless_shell-"* 2>/dev/null | sort -V | tail -1)"
if [ ! -d "$latest" ]; then
echo "Kein chromium_headless_shell im Playwright-Cache gefunden" >&2
exit 1
fi
cp -r "$latest" "$browsers_dir/"
elapsed=$(( $(date +%s) - started ))
size_mb=$(du -sm "$dist_dir" | cut -f1)
tarball="$out_dir/console-error-scanner-v$version-macos-$arch.tar.gz"
rm -f "$tarball"
tar -czf "$tarball" -C "$out_dir" console-error-scanner
tar_mb=$(du -sm "$tarball" | cut -f1)
echo ""
echo "Done in ${elapsed}s"
echo " dist folder : $dist_dir (${size_mb} MB)"
echo " tarball : $tarball (${tar_mb} MB)"