Skip to content

Commit 5ad87b7

Browse files
committed
fix(cli): use local z3 in dev wrapper
Signed-off-by: John Myers <[email protected]>
1 parent 79e6f73 commit 5ad87b7

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

scripts/bin/openshell

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ else
4242
return 0 ;;
4343
crates/openshell-cli/*|crates/openshell-core/*|crates/openshell-bootstrap/*)
4444
return 0 ;;
45+
crates/openshell-prover/*)
46+
return 0 ;;
4547
crates/openshell-policy/*|crates/openshell-providers/*|crates/openshell-tui/*)
4648
return 0 ;;
4749
*)
@@ -89,7 +91,28 @@ fi
8991

9092
if [[ "$needs_build" == "1" ]]; then
9193
echo "Recompiling openshell..." >&2
92-
cargo build --package openshell-cli --quiet
94+
build_args=(--package openshell-cli --quiet)
95+
if ! command -v pkg-config >/dev/null 2>&1 || ! pkg-config --exists z3 >/dev/null 2>&1; then
96+
z3_prefix=""
97+
if command -v brew >/dev/null 2>&1; then
98+
z3_prefix=$(brew --prefix z3 2>/dev/null || true)
99+
fi
100+
101+
for candidate in "$z3_prefix" /opt/homebrew/opt/z3 /usr/local/opt/z3; do
102+
if [[ -n "$candidate" && -f "$candidate/include/z3.h" && -d "$candidate/lib" ]]; then
103+
echo "Using local Z3 from ${candidate} for CLI build." >&2
104+
export Z3_SYS_Z3_HEADER="${candidate}/include/z3.h"
105+
export Z3_LIBRARY_PATH_OVERRIDE="${candidate}/lib"
106+
break
107+
fi
108+
done
109+
110+
if [[ -z "${Z3_SYS_Z3_HEADER:-}" ]]; then
111+
echo "Falling back to bundled Z3 for local CLI build." >&2
112+
build_args+=(--features bundled-z3)
113+
fi
114+
fi
115+
cargo build "${build_args[@]}"
93116
# Persist state after successful build
94117
mkdir -p "$(dirname "$STATE_FILE")"
95118
cd "$PROJECT_ROOT"
@@ -110,6 +133,8 @@ if [[ "$needs_build" == "1" ]]; then
110133
return 0 ;;
111134
crates/openshell-cli/*|crates/openshell-core/*|crates/openshell-bootstrap/*)
112135
return 0 ;;
136+
crates/openshell-prover/*)
137+
return 0 ;;
113138
crates/openshell-policy/*|crates/openshell-providers/*|crates/openshell-tui/*)
114139
return 0 ;;
115140
*)

0 commit comments

Comments
 (0)