refactor(tcl-examples): rename TCL scripts, drop dead pcell.tcl, fix comments and naming
Rename *-magic.tcl scripts to *-tcl.tcl to match the -tcl.js test naming convention. Delete the old bare-command pcell.tcl (used cellname create, no magic:: prefix) and promote pcell-magic.tcl to pcell.tcl. Fix misleading comment in magicWasm.c: Tclmagic_Init only bootstraps the interpreter; magic:: commands are registered separately by TclmagicRegisterCommands after magicMainInit. Align comment block dashes in TclmagicRegisterCommands to match tclmagic.c style (62 dashes). Replace intubun/tcl references in build scripts and CI with tcltk/tcl to match the actual pinned repo in npm/tcl.ref. Also run both test suites when build.sh is invoked with --test.
This commit is contained in:
parent
c78a81aa56
commit
eae3b70619
|
|
@ -73,7 +73,7 @@ jobs:
|
|||
echo "===== emcc -dM -E - ====="; echo | emcc -dM -E - | sort
|
||||
echo "===== em++ -dM -E - ====="; echo | em++ -dM -E - | sort
|
||||
|
||||
# Clone intubun/tcl into a sibling directory at the pinned ref from
|
||||
# Clone tcltk/tcl into a sibling directory at the pinned ref from
|
||||
# npm/tcl.ref. npm/build.sh would do this on its own, but doing it as
|
||||
# an explicit step makes the resolved SHA visible at the top of the
|
||||
# job log and keeps the build step's output focused on the C build.
|
||||
|
|
|
|||
|
|
@ -43,9 +43,12 @@ magicWasmEnsureCadRoot(void)
|
|||
}
|
||||
|
||||
#ifdef MAGIC_WRAPPER
|
||||
/* Forward decl — Tclmagic_Init installs all magic Tcl commands and calls
|
||||
* Tcl_InitStubs(), which sets tclStubsPtr. Without this, any Tcl_X macro
|
||||
* dereferences a NULL stubs pointer at runtime (crashes the wasm). */
|
||||
/* Forward decl — Tclmagic_Init bootstraps the Tcl interpreter (registers
|
||||
* the magic::initialize command and calls Tcl_InitStubs(), which sets
|
||||
* tclStubsPtr). Without this, any Tcl_X macro dereferences a NULL stubs
|
||||
* pointer at runtime (crashes the wasm). The actual magic:: commands
|
||||
* (magic::load, magic::gds, etc.) are registered separately by
|
||||
* TclmagicRegisterCommands() after magicMainInit() populates the clients. */
|
||||
extern int Tclmagic_Init(Tcl_Interp *interp);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
# EMSDK_DIR Path to an activated emsdk checkout.
|
||||
# If set, emsdk_env.sh is sourced from there.
|
||||
# If unset, emcc must already be on PATH (e.g. sourced externally).
|
||||
# TCL_REPO Override the path to the intubun/tcl checkout (default:
|
||||
# TCL_REPO Override the path to the tcltk/tcl checkout (default:
|
||||
# ../tcl relative to this magic checkout). Used by the TCL
|
||||
# variant only.
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ set -euo pipefail
|
|||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
# The TCL variant builds against a sibling clone of intubun/tcl (pristine —
|
||||
# The TCL variant builds against a sibling clone of tcltk/tcl (pristine —
|
||||
# magic never modifies it). The build itself happens inside magic under
|
||||
# build-tcl-wasm/, so the TCL source tree stays clean.
|
||||
TCL_REPO="${TCL_REPO:-$(dirname "$REPO_ROOT")/tcl}"
|
||||
|
|
@ -114,7 +114,7 @@ ensure_tcl_built() {
|
|||
# shellcheck source=/dev/null
|
||||
. "$TCL_REF_FILE"
|
||||
fi
|
||||
: "${TCL_REPO_URL:=https://github.com/intubun/tcl.git}"
|
||||
: "${TCL_REPO_URL:=https://github.com/tcltk/tcl.git}"
|
||||
: "${TCL_REF:=main}"
|
||||
|
||||
if [ ! -d "$TCL_REPO/.git" ]; then
|
||||
|
|
@ -210,6 +210,7 @@ esac
|
|||
if [ $OPT_TEST -eq 1 ]; then
|
||||
cd "$SCRIPT_DIR"
|
||||
npm run test
|
||||
npm run test:tcl
|
||||
fi
|
||||
|
||||
# --- optional pack -----------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function run({ magFile = DEFAULT_MAG, tech = DEFAULT_TECH, outputDi
|
|||
const { FS } = magic;
|
||||
const { tech: techName, cell } = loadCell(FS, tech, magFile);
|
||||
|
||||
magic.runScript(loadScript('cif-magic.tcl', techName, cell));
|
||||
magic.runScript(loadScript('cif-tcl.tcl', techName, cell));
|
||||
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
const data = vfsRead(FS, `/work/${cell}.cif`);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export async function run({ magFile = DEFAULT_MAG, tech = DEFAULT_TECH } = {}) {
|
|||
const { FS } = magic;
|
||||
const { tech: techName, cell } = loadCell(FS, tech, magFile);
|
||||
|
||||
magic.runScript(loadScript('drc-magic.tcl', techName, cell));
|
||||
magic.runScript(loadScript('drc-tcl.tcl', techName, cell));
|
||||
|
||||
const summary = output.find(l => /Total DRC errors/i.test(l));
|
||||
const match = summary?.match(/(\d+)/);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function run({ magFile = DEFAULT_MAG, tech = DEFAULT_TECH, outputDi
|
|||
const { FS } = magic;
|
||||
const { tech: techName, cell } = loadCell(FS, tech, magFile);
|
||||
|
||||
magic.runScript(loadScript('extract-magic.tcl', techName, cell));
|
||||
magic.runScript(loadScript('extract-tcl.tcl', techName, cell));
|
||||
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export async function run({ magFile = DEFAULT_MAG, tech = DEFAULT_TECH, outputDi
|
|||
const { FS } = magic;
|
||||
const { tech: techName, cell } = loadCell(FS, tech, magFile);
|
||||
|
||||
magic.runScript(loadScript('gds-magic.tcl', techName, cell));
|
||||
magic.runScript(loadScript('gds-tcl.tcl', techName, cell));
|
||||
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
const data = vfsRead(FS, `/work/${cell}.gds`);
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
magic::tech load __TECH__
|
||||
|
||||
proc make_rect {name width height} {
|
||||
magic::load $name
|
||||
magic::box 0 0 $width $height
|
||||
magic::paint m1
|
||||
magic::save /work/$name
|
||||
magic::gds write /work/$name
|
||||
}
|
||||
|
||||
make_rect pcell_4x8 4 8
|
||||
make_rect pcell_8x4 8 4
|
||||
|
|
@ -14,7 +14,7 @@ export async function run({ tech = DEFAULT_TECH, outputDir = DEFAULT_OUT } = {})
|
|||
const { FS } = magic;
|
||||
|
||||
FS.mkdirTree('/work');
|
||||
magic.runTcl(loadScript('pcell-magic.tcl', tech, ''));
|
||||
magic.runTcl(loadScript('pcell.tcl', tech, ''));
|
||||
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,12 @@
|
|||
# pcell.tcl — PCell generation test.
|
||||
#
|
||||
# Defines a parameterized cell proc and instantiates it with two
|
||||
# different sizes to verify that Tcl proc definitions, Magic drawing
|
||||
# commands, and GDS output all work end-to-end in the TCL variant.
|
||||
#
|
||||
# __TECH__ is substituted by pcell.js before execution.
|
||||
magic::tech load __TECH__
|
||||
|
||||
tech load __TECH__
|
||||
|
||||
# PCell definition: a labelled metal1 rectangle of variable size.
|
||||
proc make_rect {name width height} {
|
||||
cellname create $name
|
||||
box 0 0 $width $height
|
||||
paint m1
|
||||
save /work/$name
|
||||
gds write /work/$name
|
||||
magic::load $name
|
||||
magic::box 0 0 $width $height
|
||||
magic::paint m1
|
||||
magic::save /work/$name
|
||||
magic::gds write /work/$name
|
||||
}
|
||||
|
||||
# Instantiate with two different sizes.
|
||||
make_rect pcell_4x8 4 8
|
||||
make_rect pcell_8x4 8 4
|
||||
|
|
|
|||
|
|
@ -657,12 +657,13 @@ process_rlimit_startup_check(void)
|
|||
}
|
||||
|
||||
/*------------------------------------------------------*/
|
||||
/* Register magic:: commands with the Tcl interpreter. */
|
||||
/* Called after Magic's C subsystems are fully */
|
||||
/* initialized (i.e. after magicMainInit returns 0) */
|
||||
/* so that WindNextClient / WindGetCommandTable return */
|
||||
/* populated tables. */
|
||||
/*------------------------------------------------------*/
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Register magic:: commands with the Tcl interpreter. */
|
||||
/* Called after Magic's C subsystems are fully */
|
||||
/* initialized (i.e. after magicMainInit returns 0) */
|
||||
/* so that WindNextClient / WindGetCommandTable return */
|
||||
/* populated tables. */
|
||||
/*--------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
TclmagicRegisterCommands(Tcl_Interp *interp)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Build intubun/tcl as a static WASM library for linking into magic.wasm.
|
||||
# Build tcltk/tcl as a static WASM library for linking into magic.wasm.
|
||||
#
|
||||
# This script does NOT modify the TCL source tree — the build is fully
|
||||
# out-of-source. configure is invoked from the build directory inside magic,
|
||||
|
|
@ -53,7 +53,7 @@ fi
|
|||
# not a cryptic `set: pipefail: invalid option name` from bash.
|
||||
if head -1 "$TCL_SRC/unix/configure" | grep -q $'\r'; then
|
||||
echo "Error: $TCL_SRC/unix/configure has CRLF line endings." >&2
|
||||
echo " Reclone intubun/tcl with: git -c core.autocrlf=false clone …" >&2
|
||||
echo " Reclone tcltk/tcl with: git -c core.autocrlf=false clone …" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue