Files
marqdo-cli/examples/plugin-demo/build.sh
T
cflmy 53cdea2325 fix(ci): build native plugin fixtures for the host target
The macOS job failed with no_matching_artifact because the integration test
copied the Linux-only example manifest and built a Linux-named .so. Tests now
generate a manifest for the actual host triple, use the platform dynamic
library name and compiler flags, and never rewrite the tracked example
manifest.

- add a cross-platform no_matching_artifact test that runs without a C compiler
- add real tamper and ABI-major-mismatch rejection tests
- make worker fixtures platform-native; Windows remains explicitly unsupported
  (no cc) rather than counted as a pass
- example build scripts emit host-specific build/ fixtures (gitignored)
- CI smoke points at the generated fixtures
2026-11-20 13:54:18 +08:00

45 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the example C plugin and generate a host-specific manifest.
#
# The artifact and generated manifest go to `build/`, which is gitignored. The
# tracked `plugin.yaml` is never rewritten by a test or build: it documents the
# manifest shape, while the generated one matches the machine that built it.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
repo="$(cd "$here/../.." && pwd)"
cd "$repo"
out="$here/build"
mkdir -p "$out"
host="$(rustc -vV | sed -n 's/^host: //p')"
case "$host" in
*apple-darwin*) ext="dylib"; flags=(-dynamiclib -fPIC) ;;
*windows*) ext="dll"; flags=(-shared) ;;
*) ext="so"; flags=(-shared -fPIC) ;;
esac
artifact="solver.$ext"
cc -std=c11 -O2 "${flags[@]}" -I include -o "$out/$artifact" "$here/solver.c"
if command -v sha256sum >/dev/null 2>&1; then
hash="$(sha256sum "$out/$artifact" | cut -d' ' -f1)"
else
hash="$(shasum -a 256 "$out/$artifact" | cut -d' ' -f1)"
fi
cat > "$out/plugin.yaml" <<YAML
plugin:
name: demo.solver
version: 0.1.0
abi: "^1.0"
kind: native
exports:
- name: solver.add
signature: "(\$a: Int, \$b: Int) -> Int"
requires:
- math.compute
artifacts:
- target: $host
file: $artifact
sha256: "$hash"
YAML
echo "built $out/$artifact for $host (sha256 $hash)"
echo "now run: marqdo plugin inspect $out"