Files
magic/scripts/run_magic.sh.in
T
Darryl L. MilesandClaude Opus 4.8 869e99f69e build: document run_magic* launchers, template WISH/TCLSH, validate the env
Expand each run_magic*.sh header to state its purpose, usage, and the full set
of environment overrides.  Initialize every knob with ${VAR:-default} so a value
inherited from the environment always wins:

  - CAD_ROOT is now overridable (was hardwired to $builddir/CAD_DIR); point it at
    a shared/installed tree to skip staging.
  - WISH/TCLSH default to the wish/tclsh configure detected for this build's
    Tcl/Tk (@WISH_EXE@/@TCLSH_EXE@, matching --with-tk/--with-tcl), so a build
    against a non-standard Tcl/Tk automatically uses the correct absolute paths.
    MAGIC_WISH (what tkcon.tcl uses for the Tk console) defaults from WISH.

Add magic_check_env(): on source, sanity-check each value (directory / regular
file / executable, as appropriate) and print a non-fatal stderr warning naming
the offending variable and whether it came from the environment or the baked
default -- to make a bad override easy to diagnose.  Empty optional values
(e.g. no tclsh configured) and a not-yet-created CAD_ROOT are not flagged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-07-26 14:54:11 -04:00

37 lines
1.7 KiB
Bash

#!/usr/bin/env bash
#
# run_magic.sh -- launch magic with its GUI straight from the build tree.
# Generated by configure from scripts/run_magic.sh.in.
#
# PURPOSE
# Run the just-built magic *without* `make install`. On first run it stages
# ${builddir}/CAD_DIR (a tree of symlinks into the build and source trees) and
# exports CAD_ROOT so magic finds its tech/glyphs/styles and Tcl runtime there.
# Because it symlinks (never copies), a rebuild is picked up with no re-staging.
#
# USAGE
# ./run_magic.sh [magic-args...] # opens the default graphics device
# ./run_magic.sh -d XR foo.mag # pick a device / load a layout
# ./run_magic.sh -T scmos # start with a given technology
# (needs an X display; for batch/no-GUI use run_magicnull.sh instead.)
#
# This launches the self-contained "magicexec" (a wish replacement linked
# against this build's Tcl/Tk), so it needs no external wish. If magic opens
# its Tk console internally it uses $MAGIC_WISH (see below).
#
# ENVIRONMENT OVERRIDES (all optional; each wins over the baked default)
# CAD_ROOT reuse an alternate runtime tree instead of staging $builddir/CAD_DIR
# MAGIC_WISH wish for the Tk console (default: the configure-matched wish)
# WISH TCLSH wish/tclsh matching this build's Tcl/Tk (--with-tk / --with-tcl)
# MAGIC_BUILDDIR MAGIC_SRCDIR build/source tops (default: baked-in absolutes)
# Inherited values are sanity-checked; problems print as stderr warnings.
# See magic_run_common.sh for the authoritative list and defaults.
set -eu
here="$(cd "$(dirname "$0")" && pwd)"
. "$here/magic_run_common.sh"
magic_require_built
magic_stage
exec "$MAGIC_TCL/magicexec" -- "$@"