yams/scripts/dev/run_macos_install_smoke.sh
trvon 324be33abb
build: install only the runtime set from meson install
`meson install` of a Release tree staged 2.4 GiB: all 28 internal static
libraries (1.3 GiB), the whole include/ tree (459 files), 22 pkg-config
files for libraries that were never meant to be linked from outside, and
the ONNX resource library in the system libdir. Packages hid this by
deleting include/, *.a and pkgconfig/ after the fact.

- Internal static libraries are `install: false` and their pkg.generate()
  calls are gone, as is the top-level yams.pc (it required yams-api, which
  is not installable). Benchmarks are no longer installed either.
- Headers are not installed: no installable C++ library exists to link
  them against. The one SDK surface, the mobile C ABI, installs
  mobile_bindings.h and its .pc under the 'devel' install tag.
- Runtime installs carry explicit install_tag: 'runtime' where Meson
  cannot infer one (data, systemd unit/preset, the yams alias symlink,
  Windows DLL copies, the libzpdf install script), so
  `meson install --tags runtime` stages the same set as a plain install.
- libyams_onnx_resource moves from <libdir> to the private <libdir>/yams
  on Linux/macOS, without a soname version since nothing outside this
  build links it. yams-cli/yams-daemon RUNPATH becomes $ORIGIN/../lib/yams
  (@executable_path on macOS) and the ONNX/Glint plugins use $ORIGIN/..
  so they resolve it and the bundled ONNX Runtime, which also moves to
  <libdir>/yams (the ONNX plugin's runtime loader already searches its
  parent directory). Windows keeps its existing DLL layout.
- Homebrew templates and the macOS install smoke follow the new layout.
- scripts/prune-runtime-install.sh only strips now.

Measured on grim (Linux x86_64 Release, prefix /usr/local):
  staged paths  522 -> 11, staged bytes 2.4 GiB -> 1.0 GiB (unstripped)
  check_install_surface path violations: 6 -> 0
  `--tags devel` stages nothing; ldd resolves libyams_onnx_resource from
  bin/../lib/yams and the staged `yams --version` runs.

Signed-off-by: trvon <me@trevon.dev>
2026-10-01 14:22:10 -06:00

115 lines
2.9 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
if [[ "${OSTYPE:-}" != darwin* ]]; then
echo "This smoke test is intended for macOS." >&2
exit 1
fi
BUILD_DIR="${1:-build/release}"
KEEP_STAGE="${KEEP_STAGE:-0}"
if [[ ! -d "$BUILD_DIR" ]]; then
echo "Build directory not found: $BUILD_DIR" >&2
exit 1
fi
prefix="$(
python3 - "$BUILD_DIR" <<'PY'
import json
import pathlib
import sys
build_dir = pathlib.Path(sys.argv[1])
info_path = build_dir / 'meson-info' / 'intro-buildoptions.json'
if not info_path.exists():
raise SystemExit(f'missing build options: {info_path}')
options = json.loads(info_path.read_text())
for entry in options:
if entry.get('name') == 'prefix':
value = entry.get('value')
if not value:
raise SystemExit('prefix option was empty')
print(value)
break
else:
raise SystemExit('prefix option not found')
PY
)"
stage_dir="$(mktemp -d "${TMPDIR:-/tmp}/yams-install-smoke.XXXXXX")"
cleanup() {
if [[ "$KEEP_STAGE" != "1" ]]; then
rm -rf "$stage_dir"
else
echo "Kept staged install at: $stage_dir"
fi
}
trap cleanup EXIT
echo "Staging install from $BUILD_DIR"
echo "Install prefix: $prefix"
echo "Stage dir: $stage_dir"
meson install -C "$BUILD_DIR" --destdir "$stage_dir"
install_root="$stage_dir$prefix"
bin_dir="$install_root/bin"
lib_dir="$install_root/lib"
private_lib_dir="$lib_dir/yams"
plugin_dir="$private_lib_dir/plugins"
cli_bin="$bin_dir/yams"
plugin_path="$plugin_dir/libyams_onnx_plugin.dylib"
if [[ ! -x "$cli_bin" ]]; then
echo "Missing CLI binary: $cli_bin" >&2
exit 1
fi
if [[ ! -f "$plugin_path" ]]; then
echo "Missing ONNX plugin: $plugin_path" >&2
exit 1
fi
if [[ ! -f "$private_lib_dir/libyams_onnx_resource.dylib" ]]; then
echo "Missing ONNX resource library in $private_lib_dir" >&2
exit 1
fi
if ! compgen -G "$private_lib_dir/libonnxruntime*.dylib" >/dev/null; then
echo "Missing ONNX Runtime dylib in $private_lib_dir" >&2
exit 1
fi
echo "Installed ONNX artifacts:"
echo " CLI: $cli_bin"
echo " Plugin: $plugin_path"
echo " Resource: $(ls "$private_lib_dir"/libyams_onnx_resource*.dylib | tr '\n' ' ')"
echo " Runtime: $(ls "$private_lib_dir"/libonnxruntime*.dylib | tr '\n' ' ')"
echo "Checking installed plugin linkage"
otool -L "$plugin_path"
if otool -L "$plugin_path" | grep -q 'libonnxruntime'; then
echo "Installed ONNX plugin still links libonnxruntime directly" >&2
exit 1
fi
export PATH="$bin_dir:$PATH"
export DYLD_LIBRARY_PATH="$lib_dir${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
export YAMS_PLUGIN_DIR="$plugin_dir"
export YAMS_SKIP_MODEL_LOADING=1
echo "Running staged CLI smoke"
"$cli_bin" --version
doctor_output="$({ "$cli_bin" doctor plugin onnx --no-daemon; } 2>&1)"
printf '%s\n' "$doctor_output"
if [[ "$doctor_output" != *"Interface: model_provider_v1 v1 -> AVAILABLE"* ]]; then
echo "Installed plugin doctor smoke did not report the model provider interface" >&2
exit 1
fi
echo "macOS install smoke passed"