Files
solvecraft/scripts/fetch-smlib.sh
T
Brennen Herbruck 8695af8acc solidcraft-smlib: SMLib statically linked behind its C API, with a safe wrapper
A new crate (L1, only the kernel uses it) builds tangency-labs/smlib's SMLib,
SM_API and C API with the cc crate when its `native` feature is on, from the
commit in crates/smlib/SMLIB_REV (scripts/fetch-smlib.sh fetches just those
sources). The kernel's `smlib` feature turns it on. Without it nothing C++
is built and every call returns NotBuilt, so workspace builds need no C++
toolchain.

unsafe is confined to src/ffi.rs. The wrapper owns handles, maps statuses to
errors, checks the C API version, and sends SMLib's per-call log to the log
crate. Crash reports note the native kernel call in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 02:28:44 -04:00

21 lines
983 B
Bash
Executable File

#!/usr/bin/env bash
# Fetches the SMLib sources solidcraft-smlib builds (feature `native`): tangency-labs/smlib at
# the commit in crates/smlib/SMLIB_REV, only the parts the build reads (source/SMLib,
# source/SM_API, capi), into target/smlib-<rev12>. OpenCASCADE is not part of the fork.
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
rev="$(tr -d '[:space:]' < "$root/crates/smlib/SMLIB_REV")"
dest="${SOLIDCRAFT_SMLIB_DIR:-$root/target/smlib-${rev:0:12}}"
if [ -f "$dest/capi/include/smlib.h" ] && [ "$(git -C "$dest" rev-parse HEAD 2>/dev/null)" = "$rev" ]; then
echo "SMLib $rev already at $dest"
exit 0
fi
rm -rf "$dest"
mkdir -p "$dest"
git -C "$dest" init -q
git -C "$dest" remote add origin https://github.com/tangency-labs/smlib.git
git -C "$dest" sparse-checkout set --no-cone /source/SMLib/ /source/SM_API/ /capi/ /LICENSE
git -C "$dest" fetch -q --depth 1 --filter=blob:none origin "$rev"
git -C "$dest" checkout -q FETCH_HEAD
echo "SMLib $rev at $dest"