Files

43 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the conformance plugin for the host target and generate a complete
# plugin.yaml (target triple + real artifact SHA-256). The tracked plugin.yaml
# is a zero-digest template and is never rewritten.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
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="plugin.$ext"
cc -std=c11 -O2 "${flags[@]}" -I "$here/include" -o "$out/$artifact" "$here/src/plugin.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.ext
version: 0.1.0
abi: "^1.0"
kind: worker
exports:
- name: solver.add
signature: "(\$a: Int, \$b: Int) -> Int"
- name: solver.neg
signature: "(\$a: Int) -> Int"
- name: quant.scale
signature: "(\$a: Int) -> Int"
requires:
- math.compute
artifacts:
- target: $host
file: $artifact
sha256: "$hash"
YAML
echo "built $out/$artifact for $host (sha256 $hash)"