A prebuilt tool, bin/ludic-ui-preview (built by ludic-dev build, shipped beside ludic-lsp, run as `ludic ui-preview [--font DIR]`): ludic.ui with a backend that records every draw call as a line, and mock component classes the studio describes (load / model / calls). frame t runs ui_show at interface time t; text is measured on the CPU with the game's font.json metrics; locale goes through ludic.i18n; tree / box / rules inspect the frame. No game code, no GPU, no network. The wire protocol is frozen as tools/ui-preview/protocol-v1.md; smoke.txt is a transcript to run. ludic.ui gains, all additive: UiClass.make_of, UiBackend.said / emitted, UiRule.text / at (with comment line breaks kept so rule lines count true, and a class's styles read under its .lss path), and ui_root, ui_find, ui_rules_of, ui_rule_value, ui_building, ui_class, ui_class_load, ui_file_forget, ui_errors_clear; ui_nine_cuts_into exported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.9 KiB
Text
52 lines
2.9 KiB
Text
# toolchain.ludic — building the toolchain's own binaries. Contributor-only:
|
|
# this is what `ludic-dev build` does, and none of it ships to a user.
|
|
# compile a Ludic source to a native binary in bin/ via ludicc + clang (-O2).
|
|
# Returns true on success. Used for the CLI, the contributor tool and the editor
|
|
# tools — every binary the toolchain builds of itself.
|
|
function build_tool(name: pointer, src: pointer) -> bool {
|
|
let ll = `build/{name}.ll`
|
|
let out = `bin/{exe_name(name)}`
|
|
if not shq(`bin/{exe_name("ludicc")} --unsafe --globals {src} --emit-llvm -o {ll} 2>/dev/null`) { print(`build failed: {name} (compile)`); return false }
|
|
# write to a temp then move, so a running bin/ludic can rebuild itself in place
|
|
# (Windows lets a running executable be renamed, never replaced, so the old one
|
|
# steps aside first)
|
|
if not shq(`{cc()} -O2 {ll} -o {out}.tmp`) { print(`build failed: {name} (link)`); return false }
|
|
if host_windows() { shell(`rm -f {out}.old; mv -f {out} {out}.old 2>/dev/null; mv -f {out}.tmp {out} && rm -f {ll} {out}.old 2>/dev/null`) }
|
|
else { shell(`mv -f {out}.tmp {out} && rm -f {ll}`) }
|
|
return true
|
|
}
|
|
|
|
# ---- build-cli: the self-hosted front-end binaries ---------------------------
|
|
# Both ludicc and ludic are the SAME multi-call binary assembled from the IR seed
|
|
# with clang alone; invoked as `ludic` it compiles-and-runs, as `ludicc` it just
|
|
# compiles.
|
|
function cmd_dev_build_cli() -> int {
|
|
shell("mkdir -p bin build")
|
|
let seed = seed_file()
|
|
let bin = `bin/{exe_name("ludicc")}`
|
|
print(`cc: {seed} -> {bin} (from the IR seed, no C compiler)`)
|
|
if not shq(`{cc()} {seed} -o {bin}`) { err("ludic: the seed did not assemble\n"); return 1 }
|
|
shell(`chmod +x {bin}`)
|
|
print(`done. built {bin}`)
|
|
return 0
|
|
}
|
|
|
|
# ---- build: the whole toolchain --------------------------------------------
|
|
# bin/ludic is what a user installs; bin/ludic-dev is this tool, which exists
|
|
# only in a checkout and is never part of a release.
|
|
function cmd_dev_build() -> int {
|
|
if cmd_dev_build_cli() != 0 { return 1 }
|
|
print("ludicc: tools/ludic-cli/main.ludic -> bin/ludic (the CLI users install)")
|
|
if not build_tool("ludic", "tools/ludic-cli/main.ludic") { return 1 }
|
|
print("ludicc: tools/ludic-cli/dev.ludic -> bin/ludic-dev (this tool, rebuilding itself)")
|
|
if not build_tool("ludic-dev", "tools/ludic-cli/dev.ludic") { return 1 }
|
|
print("ludicc: tools/ludic-tools/fmt.ludic -> bin/ludic-fmt")
|
|
if not build_tool("ludic-fmt", "tools/ludic-tools/fmt.ludic") { return 1 }
|
|
print("ludicc: tools/ludic-tools/lsp.ludic -> bin/ludic-lsp")
|
|
if not build_tool("ludic-lsp", "tools/ludic-tools/lsp.ludic") { return 1 }
|
|
print("ludicc: tools/ui-preview/main.ludic -> bin/ludic-ui-preview")
|
|
if not build_tool("ludic-ui-preview", "tools/ui-preview/main.ludic") { return 1 }
|
|
sync_vscode_grammar()
|
|
print("done. toolchain in bin/ (ludicc, ludic, ludic-dev, ludic-fmt, ludic-lsp, ludic-ui-preview)")
|
|
return 0
|
|
}
|