fluffos/CMakePresets.json
Yucong Sun 389d9f769c
lpcc: JSON-native stage outputs, wasm lpcc, disassembler fixes (#1283)
The compiler front-end's dumps are now JSON-native: each stage has ONE
model and its outputs (human text, --json envelope) are renderings of
it. lpcc ships in the wasm build so the fluffos-vscode extension can
bundle it with zero native setup.

--json stage outputs (one-line {"fluffos_lpcc":1,...} envelopes,
findable in mixed stdout; error_handler_t::replace everywhere since LPC
source bytes are not guaranteed UTF-8):

- tokens: positions, spellings, and token NAMES via lpc_token_name(),
  a new public accessor in grammar.y's epilogue over the parser's
  file-static yysymbol_name()/YYTRANSLATE table (grammar.autogen.*
  regenerated via the pinned copy-back)
- ast: per-node source LINES (absolute compilation-unit lines) plus a
  {"stage":"files"} companion envelope with the absolute-line->file
  segment table and the string table so (string N) atoms resolve.
  dump_tree's ~240-line hand-printed switch is GONE: the --ast text is
  render_sexpr() over the same ast_json model (one switch, two
  renderings; the rendered form is shape-compatible, one root per line,
  function nodes carry their index)
- bytecode (default and -O0, envelope carries optimized:true/false):
  the ONE opcode switch in disassemble() emits through a DisSink with
  two backends -- text reproduces the legacy dump format (verified
  byte-identical across a fixture corpus incl. switch tables and both
  optimizer modes), json builds the model natively: per-program
  sections (top + inherited), FUNCTIONS table via the shared
  fn_table_rows(), instruction rows {a,x,m,o,f,l} with source file:line
  NATIVE on every row, structured switch tables (resolved string keys,
  case targets, minval), and the line tables. dump_prog_json() exported
  via json_fwd

Disassembler fix folded in: loop_cond_number copied its 8-byte LPC_INT
literal (COPY_INT == COPY8) but advanced pc only 4, desyncing the
address stream -- '*** zero opcode ***' garbage and the next function's
listing swallowed. Advance sizeof(LPC_INT); 'bbranch_when_non_zero'
typo -> 'branch back'.

wasm: the emscripten branch builds lpcc-web (main_lpcc.cc as a plain
node CLI with NODERAWFS, so 'node lpcc.js <config> <file>' behaves like
the native binary; the unneeded event2 include is dropped -- mainlib.h
forward-declares init_main's event_base). Added to the wasm build
preset's target list, smoke-tested in the CI wasm job (compile a
testsuite file, expect the --json tokens envelope), and shipped in the
release wasm zip alongside the driver.

Full LPC testsuite passes; all stage outputs verified end-to-end by the
fluffos-vscode Compiler Explorer against fixture corpora.


Claude-Session: https://claude.ai/code/session_01AXqX4Kf55ArA39suS9cdCv

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 22:27:17 -07:00

172 lines
4.9 KiB
JSON

{
"version": 3,
"configurePresets": [
{
"name": "linux-debug",
"displayName": "Linux Debug (Clang + ASan/UBSan)",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"MARCH_NATIVE": "OFF",
"ENABLE_SANITIZER": "ON",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "linux-relwithdebinfo",
"displayName": "Linux RelWithDebInfo (Clang)",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"MARCH_NATIVE": "OFF",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "macos-debug",
"displayName": "macOS Debug",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"MARCH_NATIVE": "OFF"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "macos-relwithdebinfo",
"displayName": "macOS RelWithDebInfo",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"MARCH_NATIVE": "OFF"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "windows-debug",
"displayName": "Windows Debug (MSYS2/MinGW64)",
"generator": "MSYS Makefiles",
"binaryDir": "${sourceDir}/build",
"environment": {
"PATH": "$env{MSYS2_ROOT}/mingw64/bin;$env{MSYS2_ROOT}/usr/bin;$penv{PATH}",
"MSYSTEM": "MINGW64"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"MARCH_NATIVE": "OFF"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "windows-relwithdebinfo",
"displayName": "Windows RelWithDebInfo (MSYS2/MinGW64)",
"generator": "MSYS Makefiles",
"binaryDir": "${sourceDir}/build",
"environment": {
"PATH": "$env{MSYS2_ROOT}/mingw64/bin;$env{MSYS2_ROOT}/usr/bin;$penv{PATH}",
"MSYSTEM": "MINGW64"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"MARCH_NATIVE": "OFF"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "native-tools",
"displayName": "Native codegen tools (stage 1 of a cross build)",
"description": "Minimal native configuration whose only purpose is building make_func/build_applies/make_options_defs for a cross build.",
"binaryDir": "${sourceDir}/build-native-tools",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"MARCH_NATIVE": "OFF",
"USE_JEMALLOC": "OFF",
"PACKAGE_DB": "OFF",
"PACKAGE_PCRE": "OFF",
"PACKAGE_FFI": "OFF",
"PACKAGE_EXTERNAL": "OFF"
}
},
{
"name": "wasm",
"displayName": "WebAssembly (Emscripten)",
"description": "Cross build of the web driver. Configure through the emscripten wrapper: `emcmake cmake --preset wasm` (after building the native-tools preset). Wasm-built ICU/zlib are expected under /opt/wasm-deps; override with -DFLUFFOS_WASM_DEPS=<prefix>.",
"binaryDir": "${sourceDir}/build-wasm",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"FLUFFOS_HOST_TOOLS_DIR": "${sourceDir}/build-native-tools/src/tools"
}
}
],
"buildPresets": [
{
"name": "linux-debug",
"configurePreset": "linux-debug"
},
{
"name": "linux-relwithdebinfo",
"configurePreset": "linux-relwithdebinfo"
},
{
"name": "macos-debug",
"configurePreset": "macos-debug"
},
{
"name": "macos-relwithdebinfo",
"configurePreset": "macos-relwithdebinfo"
},
{
"name": "windows-debug",
"configurePreset": "windows-debug"
},
{
"name": "windows-relwithdebinfo",
"configurePreset": "windows-relwithdebinfo"
},
{
"name": "native-tools",
"configurePreset": "native-tools",
"targets": ["make_func", "build_applies", "make_options_defs"]
},
{
"name": "wasm",
"configurePreset": "wasm",
"targets": ["driver-web", "lpcc-web"]
}
]
}