Files
solvecraft/scripts/cpp-ref-key.sh
T
bherbruck b50a704c90 WIP: port usd-brep v1.0.1 (3fd5b95) SMLib/SM_API changes
Snapshot of the swarm's in-progress v1.0.1 port before merging main:
per-slice ports (curve_class, face, brep/NLib, heal, primitives/cone,
SM_API and small files, offset/merge/topology_intersector, proto_topology,
vertex/vertexuse/track changes), shim/FFI updates, the pin file and
callgraph remap, fixtures and "fixed in v1.0.1" addenda. Not yet gated.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJzQKZ9sjU1DhgS253e8J5
2026-10-26 20:27:47 -04:00

44 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Print the key that names a prebuilt C++ reference build (harness/cpp/build.sh output).
#
# v1-<upstream commit, 12 hex>-<16 hex of a sha256 over the harness inputs>
#
# The inputs are exactly what build.sh compiles into bin/cpp/lib: the pinned upstream
# commit (UPSTREAM_COMMIT in scripts/upstream-pin.env) plus
# harness/cpp/{CMakeLists.txt,build.sh,stubs/**,patches/**}. The shims
# (harness/cpp/shim/**) are compiled by crates/solidcore-ffi, not by build.sh, so they
# are not part of the key. CI (actions/cache key), .github/workflows/cpp-reference.yml
# (release tag cpp-ref-<key>) and scripts/fetch-cpp.sh all call this script, so they
# always agree. Bump the "v1" prefix when the packaging itself changes.
#
# An UPSTREAM_COMMIT environment variable overrides the pinned commit.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# The pin lives in scripts/upstream-pin.env (also read by fetch-cpp.sh, package-cpp-ref.sh,
# the site and CI); ATTRIBUTION.md / AGENTS.md / README.md quote it for humans.
PINNED="$(sed -n 's/^UPSTREAM_COMMIT=//p' "$ROOT/scripts/upstream-pin.env")"
[ -n "$PINNED" ] || { echo "cpp-ref-key.sh: no UPSTREAM_COMMIT in scripts/upstream-pin.env" >&2; exit 1; }
COMMIT="${UPSTREAM_COMMIT:-$PINNED}"
if command -v sha256sum >/dev/null 2>&1; then
sha() { sha256sum | cut -c1-64; }
else
sha() { shasum -a 256 | cut -c1-64; } # macOS
fi
cd "$ROOT"
files="$(
{ printf '%s\n' harness/cpp/CMakeLists.txt harness/cpp/build.sh
for d in harness/cpp/stubs harness/cpp/patches; do
if [ -d "$d" ]; then find "$d" -type f; fi
done
} | LC_ALL=C sort
)"
hash="$(
printf '%s\n' "$files" | while IFS= read -r f; do
printf '%s %s\n' "$(sha < "$f")" "$f"
done | sha
)"
printf 'v1-%s-%s\n' "$(printf '%s' "$COMMIT" | cut -c1-12)" "$(printf '%s' "$hash" | cut -c1-16)"