Skip to content

Commit fdddab7

Browse files
thomasahleclaude
andcommitted
Add publish:circt workflow to sync-circt-wasm.sh
- sync-circt-wasm.sh --publish: packages UVM bundle, uploads all WASM artifacts to the circt-wasm GitHub release (--clobber), and updates CIRCT_REF_LOCKED in toolchain.lock.sh to the current vendor/circt HEAD - Auto-fallback: when circt-sim-vpi is not built separately, copies circt-sim as the VPI-capable binary (circt-sim already includes Asyncify + VPI exports unconditionally in Emscripten builds) - Adds npm run publish:circt as the one-stop release command Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ee9d9cd commit fdddab7

2 files changed

Lines changed: 65 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"bootstrap:repro": "./scripts/bootstrap-repro.sh",
1616
"repro:vpi:node": "node scripts/repro-cocotb-vpi-put-value.mjs",
1717
"sync:circt": "./scripts/sync-circt-wasm.sh",
18+
"publish:circt": "./scripts/sync-circt-wasm.sh --publish",
1819
"test": "vitest run",
1920
"test:e2e": "playwright test"
2021
},

scripts/sync-circt-wasm.sh

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
SRC_DIR="${1:-vendor/circt/build-wasm/bin}"
5-
DST_DIR="${2:-static/circt}"
6-
UVM_SRC_DIR="${3:-vendor/circt/lib/Runtime/uvm-core/src}"
4+
PUBLISH=0
5+
POSITIONAL=()
6+
for arg in "$@"; do
7+
case "$arg" in
8+
--publish) PUBLISH=1 ;;
9+
*) POSITIONAL+=("$arg") ;;
10+
esac
11+
done
12+
13+
SRC_DIR="${POSITIONAL[0]:-vendor/circt/build-wasm/bin}"
14+
DST_DIR="${POSITIONAL[1]:-static/circt}"
15+
UVM_SRC_DIR="${POSITIONAL[2]:-vendor/circt/lib/Runtime/uvm-core/src}"
716
UVM_DST_DIR="$DST_DIR/uvm-core/src"
817
UVM_MANIFEST_PATH="$DST_DIR/uvm-core/uvm-manifest.json"
918

@@ -64,16 +73,24 @@ for tool in "${TOOLS[@]}"; do
6473
patch_callmain_export "$DST_DIR/$tool.js"
6574
done
6675

67-
# Sync VPI-capable sim if present (built with -DCIRCT_SIM_WASM_VPI=ON).
76+
# Sync VPI-capable sim. circt-sim already includes Asyncify + VPI exports
77+
# unconditionally in Emscripten builds, so use it as the VPI binary when a
78+
# separately-named circt-sim-vpi build is not present in the source dir.
6879
if [ -f "$SRC_DIR/$VPI_TOOL.js" ] && [ -f "$SRC_DIR/$VPI_TOOL.wasm" ]; then
6980
cp -f "$SRC_DIR/$VPI_TOOL.js" "$DST_DIR/$VPI_TOOL.js"
7081
cp -f "$SRC_DIR/$VPI_TOOL.wasm" "$DST_DIR/$VPI_TOOL.wasm"
71-
patch_callmain_export "$DST_DIR/$VPI_TOOL.js"
72-
HAVE_VPI=1
82+
elif [ -f "$SRC_DIR/circt-sim.js" ] && [ -f "$SRC_DIR/circt-sim.wasm" ]; then
83+
echo "Note: $VPI_TOOL not in $SRC_DIR — using circt-sim as VPI-capable fallback" >&2
84+
cp -f "$SRC_DIR/circt-sim.js" "$DST_DIR/$VPI_TOOL.js"
85+
cp -f "$SRC_DIR/circt-sim.wasm" "$DST_DIR/$VPI_TOOL.wasm"
7386
else
74-
echo "Note: $VPI_TOOL not found in $SRC_DIR — skipping (cocotb lessons will be unavailable)" >&2
87+
echo "Note: $VPI_TOOL not found and no circt-sim fallback — skipping (cocotb lessons will be unavailable)" >&2
7588
HAVE_VPI=0
7689
fi
90+
if [ "${HAVE_VPI:-}" != "0" ]; then
91+
patch_callmain_export "$DST_DIR/$VPI_TOOL.js"
92+
HAVE_VPI=1
93+
fi
7794

7895
if [ ! -d "$UVM_SRC_DIR" ]; then
7996
echo "Missing full UVM source directory: $UVM_SRC_DIR" >&2
@@ -257,3 +274,43 @@ fi
257274
echo "Synced full UVM source files:"
258275
echo " source dir: $UVM_DST_DIR"
259276
echo " manifest: $UVM_MANIFEST_PATH"
277+
278+
# --publish: upload artifacts to the circt-wasm GitHub release and update the
279+
# toolchain lock so CI rebuilds from the same commit.
280+
if [ "$PUBLISH" -eq 1 ]; then
281+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
282+
source "$ROOT_DIR/scripts/toolchain.lock.sh"
283+
284+
CIRCT_COMMIT="$(git -C "${CIRCT_DIR:-vendor/circt}" rev-parse HEAD 2>/dev/null || true)"
285+
if [ -z "$CIRCT_COMMIT" ]; then
286+
echo "--publish: could not determine CIRCT commit from ${CIRCT_DIR:-vendor/circt}" >&2
287+
exit 1
288+
fi
289+
290+
# Bundle UVM sources for the release asset.
291+
UVM_BUNDLE="$(mktemp /tmp/uvm-core.XXXXXX.tar.gz)"
292+
tar -czf "$UVM_BUNDLE" -C "$DST_DIR" uvm-core
293+
echo "Created UVM bundle: $UVM_BUNDLE"
294+
295+
# Upload all artifacts, replacing existing assets on the release.
296+
RELEASE_ASSETS=(
297+
"$DST_DIR/circt-bmc.js" "$DST_DIR/circt-bmc.wasm"
298+
"$DST_DIR/circt-sim.js" "$DST_DIR/circt-sim.wasm"
299+
"$DST_DIR/circt-verilog.js" "$DST_DIR/circt-verilog.wasm"
300+
"$UVM_BUNDLE"
301+
)
302+
if [ "$HAVE_VPI" -eq 1 ]; then
303+
RELEASE_ASSETS+=("$DST_DIR/$VPI_TOOL.js" "$DST_DIR/$VPI_TOOL.wasm")
304+
fi
305+
306+
echo "Uploading to GitHub release 'circt-wasm'..."
307+
gh release upload circt-wasm "${RELEASE_ASSETS[@]}" --clobber
308+
rm -f "$UVM_BUNDLE"
309+
echo "GitHub release updated."
310+
311+
# Update toolchain lock to the current CIRCT commit.
312+
LOCK_FILE="$ROOT_DIR/scripts/toolchain.lock.sh"
313+
sed -i.bak "s|^readonly CIRCT_REF_LOCKED=.*|readonly CIRCT_REF_LOCKED=\"$CIRCT_COMMIT\"|" "$LOCK_FILE"
314+
rm -f "$LOCK_FILE.bak"
315+
echo "Updated CIRCT_REF_LOCKED to $CIRCT_COMMIT in $LOCK_FILE"
316+
fi

0 commit comments

Comments
 (0)