From 8a6995f66e56e5bea914e51709812b635d17baae Mon Sep 17 00:00:00 2001 From: Amitai Schleier Date: Sun, 13 Sep 2026 21:54:58 -0400 Subject: [PATCH] feat!: configure through shipyard-cmake; one locator, not three The shipyard pkg no longer writes the CMake user package registry, and MavericksShipyardConfig.cmake now refuses any cmake but shipyard-cmake. msc.sh is replaced wholesale by shipyard's canonical template (conventions check 17 compares it byte for byte): $SHIPYARD_SCRIPTS in CI, else ask shipyard-cmake where find_package(MavericksShipyard) lands. It was not the only locator. package.sh and scripts/guard.sh each carried their own four-entry fallback chain, and both named $HOME/.local/share/cmake/MavericksShipyard/scripts -- the prefix a `cmake --install` used to produce, which the pkg does not create. Neither read ~/.cmake/packages, so neither looked like a registry reader; both were about to resolve nothing off CI. package.sh's chain also OVERWROTE the $SHIPYARD msc.sh had already set eleven lines earlier. Both now use $SHIPYARD. guard.sh keeps its exit 4 for the case that is genuinely its own -- shipyard found, assert_binary_compatible.sh missing from it -- which is distinct from msc.sh's "no shipyard at all". Four call sites move to shipyard-cmake: the updater configure and --build in release.yml, build.sh's stdlib configure, and the `build it: cmake --build build/updater` recipe package.sh prints when the updater is absent. That last one sits behind a bare "(" that conventions check 18 deliberately skips, so no gate would have reported it. build.sh's prerequisites line named plain cmake; it now names the shipyard pkg. BREAKING CHANGE: builds now require the shipyard pkg (it provides /usr/local/bin/shipyard-cmake). Do not merge until shipyard has landed bc3082a. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GTxFde2TJMmp5p64DhvDSK --- .github/workflows/release.yml | 9 +++++---- build.sh | 5 +++-- msc.sh | 33 ++++++++++++++++++++++++--------- package.sh | 20 +++----------------- scripts/guard.sh | 15 +++------------ 5 files changed, 38 insertions(+), 44 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f443ab..170e6dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,8 +61,9 @@ jobs: # existing *-mavericks.* tags, so the full history has to be here. fetch-depth: 0 - # shipyard installs itself via its own action (HTTPS via the runner token); consumed thereafter - # via find_package(MavericksShipyard) + the installed ${MavericksShipyard_SCRIPTS}. + # shipyard installs itself via its own action (HTTPS via the runner token): the pkg, which puts + # shipyard-cmake on PATH and exports $SHIPYARD_SCRIPTS. Consumed thereafter via + # find_package(MavericksShipyard) under shipyard-cmake, and via msc.sh in the shell scripts. - name: Install mavericks-shipyard uses: ModernMavericks/shipyard/.github/actions/install@v1 @@ -134,8 +135,8 @@ jobs: - name: Build SwiftUpdater.app (Cocoa/Sparkle; must NOT link Swift) run: | # The Sparkle framework is fetched inside mavericks_add_updater_app (mavericks_fetch_sparkle). - cmake -S . -B build/updater -DCMAKE_OBJC_COMPILER=/usr/bin/clang - cmake --build build/updater --target SwiftUpdater + shipyard-cmake -S . -B build/updater -DCMAKE_OBJC_COMPILER=/usr/bin/clang + shipyard-cmake --build build/updater --target SwiftUpdater otool -L build/updater/SwiftUpdater.app/Contents/MacOS/SwiftUpdater | tee /tmp/o.txt ! grep -q '/usr/lib/swift' /tmp/o.txt || { echo "::error::updater links libswiftCore (self-update circularity)"; exit 1; } diff --git a/build.sh b/build.sh index 59a4376..60f7aa5 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,8 @@ # Produces: out/libswiftCore.dylib (+ libswiftSwiftOnoneSupport.dylib), minOS 10.9, # from Swift 6.3.3 swift.org sources, with NO Apple prebuilt runtime bytes redistributed. # -# Host: macOS with Xcode Command Line Tools (full Xcode NOT required), cmake + ninja + git. +# Host: macOS with Xcode Command Line Tools (full Xcode NOT required), ninja + git, and the +# shipyard pkg (it provides shipyard-cmake, the only cmake this family configures with). # Cross-target build (host may be arm64; output is x86_64). ~30-60 min from clean on 8 cores. # # Everything is PINNED below. Do not float versions — the stdlib is coupled to its compiler. @@ -140,7 +141,7 @@ echo "==> 4. Swift STDLIB-ONLY configure (prebuilt toolchain as native tools)" # skipped under SWIFT_INCLUDE_TESTS=OFF / SWIFT_INCLUDE_TOOLS=OFF -- so no LLVM source is needed. # Clang_DIR, LLVM_TABLEGEN and CLANG_TABLEGEN are deliberately absent: CMake reports them # unused in this configuration, since the branch that would read them is behind SWIFT_INCLUDE_TOOLS. -cmake -G Ninja -S swift -B stdlib-build \ +shipyard-cmake -G Ninja -S swift -B stdlib-build \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER="$TC/bin/clang" -DCMAKE_CXX_COMPILER="$TC/bin/clang++" \ -DLLVM_DIR="$LLVMB/lib/cmake/llvm" \ diff --git a/msc.sh b/msc.sh index e0dd80f..43c2af0 100644 --- a/msc.sh +++ b/msc.sh @@ -1,10 +1,25 @@ -# msc.sh -- sourced (with $HERE set to the sourcing script's dir): set $SHIPYARD to the installed -# mavericks-shipyard scripts dir. Prefer $SHIPYARD_SCRIPTS (exported by shipyard's install@v1); -# fall back to the CMake user package registry (a local `cmake --install`), then a sibling checkout -# (a dev box that never installed it). This is the only per-repo part of consuming shipyard's -# shell scripts; the logic itself (clone_pinned.sh, ...) lives in shipyard. +# usage: . build/msc.sh +# Sourced by a ModernMavericks product's build scripts: locates shipyard's scripts as +# $SHIPYARD and exports SHIPYARD_SCRIPTS. In CI, install@v1 has already exported +# SHIPYARD_SCRIPTS; anywhere else this asks shipyard-cmake -- the only cmake that configures +# against shipyard -- where find_package(MavericksShipyard) lands, so a CMAKE_PREFIX_PATH +# dev override moves the scripts together with the modules. About 2 s, exported so children +# skip it. CANONICAL COPY: shipyard's scripts/templates/msc.sh; conventions check 17 +# requires every product's copy to match it byte for byte, so change it there, not here. SHIPYARD="${SHIPYARD_SCRIPTS:-}" -[ -d "$SHIPYARD" ] || SHIPYARD="$(cat "$HOME/.cmake/packages/MavericksShipyard/"* 2>/dev/null | head -1)/scripts" -[ -d "$SHIPYARD" ] || SHIPYARD="$HERE/../mavericks-shipyard/scripts" -[ -d "$SHIPYARD" ] || { echo "cannot locate mavericks-shipyard scripts (set SHIPYARD_SCRIPTS or run install@v1)" >&2; return 1 2>/dev/null || exit 1; } -export SHIPYARD +if [ ! -d "$SHIPYARD" ]; then + _msc_probe="$(mktemp -d "${TMPDIR:-/tmp}/shipyard-probe.XXXXXX")" + printf '%s\n' 'cmake_minimum_required(VERSION 3.16)' 'project(shipyard_probe NONE)' \ + 'find_package(MavericksShipyard REQUIRED)' 'message(STATUS "SHIPYARD_DIR=${MavericksShipyard_DIR}")' \ + > "$_msc_probe/CMakeLists.txt" + # platform: appending /scripts to the substitution directly made a failed probe (no + # shipyard-cmake, a refused configure) yield the literal "/scripts" -- an absolute path, + # plausible-looking, and the error below would then complain about the wrong thing. So + # assign the probe's answer first and append only if there was one. + _msc_dir="$(shipyard-cmake -S "$_msc_probe" -B "$_msc_probe/b" 2>/dev/null | sed -n 's/^-- SHIPYARD_DIR=//p')" + if [ -n "$_msc_dir" ]; then SHIPYARD="$_msc_dir/scripts"; fi + rm -rf "$_msc_probe"; unset _msc_probe _msc_dir +fi +[ -d "$SHIPYARD" ] || { echo "msc.sh: cannot locate shipyard -- install the shipyard pkg (it provides shipyard-cmake), or set SHIPYARD_SCRIPTS" >&2; return 1 2>/dev/null || exit 1; } +SHIPYARD_SCRIPTS="$SHIPYARD" +export SHIPYARD SHIPYARD_SCRIPTS diff --git a/package.sh b/package.sh index fa93812..bc8cb17 100755 --- a/package.sh +++ b/package.sh @@ -13,27 +13,13 @@ DIST="${DIST:-$PWD/dist}" # from UPSTREAM_VERSION + the shipped tags. Never a committed file. HERE="$(cd "$(dirname "$0")" && pwd)" [ -f "$HERE/UPSTREAM_VERSION" ] || sh "$HERE/scripts/derive-upstream-version.sh" >/dev/null -. "$HERE/msc.sh" # -> $SHIPYARD (shipyard scripts dir) +. "$HERE/msc.sh" # -> $SHIPYARD: resolve-version, stage_updater and set_install_floor VERSION="$(MAVERICKS_ROOT="$HERE" sh "$SHIPYARD/resolve-version.sh")" IDENTIFIER="${PKG_IDENTIFIER:-dev.modernmavericks.swift-runtime}" NAME="swift-runtime-${VERSION}" mkdir -p "$DIST" [ -f "$OUT/usr/lib/swift/libswiftCore.dylib" ] || { echo "no build in $OUT; run build.sh" >&2; exit 1; } -# Locate mavericks-shipyard's scripts dir: installed SHIPYARD (find_package registry / --prefix), env -# override, or a sibling checkout. Not vendored -- consumed like the siblings. Both set_install_floor -# and stage_updater come from here. -HELPER="" -for c in \ - "${SHIPYARD_SCRIPTS:-}/set_install_floor.sh" \ - "${MavericksShipyard_SCRIPTS:-}/set_install_floor.sh" \ - "$HOME/.local/share/cmake/MavericksShipyard/scripts/set_install_floor.sh" \ - "$PWD/../mavericks-shipyard/scripts/set_install_floor.sh" ; do - [ -n "$c" ] && [ -f "$c" ] && { HELPER="$c"; break; } -done -[ -n "$HELPER" ] || { echo "package: cannot find mavericks-shipyard set_install_floor.sh (install SHIPYARD or set SHIPYARD_SCRIPTS)" >&2; exit 4; } -SHIPYARD="$(cd "$(dirname "$HELPER")" && pwd)" - echo ">> resources (welcome + license shown at install)" RES="$DIST/resources"; mkdir -p "$RES" cp scripts/resources/Welcome.html "$RES/" @@ -52,7 +38,7 @@ if [ -d "$UPD_APP" ]; then --scripts-out "$SCR" set -- --scripts "$SCR" else - echo " (no updater app at $UPD_APP; packaging runtime only -- build it: cmake --build build/updater)" + echo " (no updater app at $UPD_APP; packaging runtime only -- build it: shipyard-cmake --build build/updater)" fi echo ">> flat component pkg (payload -> /usr/lib/swift, /usr/local, /Library/LaunchAgents)" @@ -61,7 +47,7 @@ pkgbuild --root "$OUT" --identifier "$IDENTIFIER" --version "$VERSION" \ --install-location / "$DIST/swift-runtime-component.pkg" echo ">> product archive with 10.9.5 floor (shared helper)" -sh "$HELPER" \ +sh "$SHIPYARD/set_install_floor.sh" \ --identifier "$IDENTIFIER" \ --title "Mavericks Swift Runtime — Swift core runtime for OS X 10.9" \ --component "$DIST/swift-runtime-component.pkg" \ diff --git a/scripts/guard.sh b/scripts/guard.sh index 5343db0..322698d 100755 --- a/scripts/guard.sh +++ b/scripts/guard.sh @@ -9,18 +9,9 @@ # Usage: scripts/guard.sh [ ...] set -eu -# Locate the shared guard from mavericks-shipyard: installed SHIPYARD (find_package registry / -# --prefix), an env override, or a sibling checkout. Not vendored -- consumed like trackpad2/dimmit. -SHARED="" -for c in \ - "${SHIPYARD_SCRIPTS:-}/assert_binary_compatible.sh" \ - "${MavericksShipyard_SCRIPTS:-}/assert_binary_compatible.sh" \ - "$HOME/.local/share/cmake/MavericksShipyard/scripts/assert_binary_compatible.sh" \ - "$(dirname "$0")/../../mavericks-shipyard/scripts/assert_binary_compatible.sh" ; do - [ -n "$c" ] && [ -f "$c" ] && { SHARED="$c"; break; } -done -[ -n "$SHARED" ] || { echo "guard: cannot find mavericks-shipyard assert_binary_compatible.sh" >&2 - echo " install it (cmake --install) or set SHIPYARD_SCRIPTS." >&2; exit 4; } +. "$(dirname "$0")/../msc.sh" # -> $SHIPYARD (shipyard scripts dir) +SHARED="$SHIPYARD/assert_binary_compatible.sh" +[ -f "$SHARED" ] || { echo "guard: shipyard at $SHIPYARD has no assert_binary_compatible.sh" >&2; exit 4; } # Full post-10.9 os_* family, tolerant of the one/two leading-underscore SPI naming. export MAVERICKS_POST_10_9_SYMBOLS='__?os_signpost.*|__?os_log.*|_os_system_version_get_current_version|__?os_availability.*'