;; .jerbuild — build a standalone jcode binary with `jerbuild build`.
;;
;; jerbuild bundles Chez Scheme + the jerboa stdlib, so NO jerboa source
;; checkout or external Chez is required. The only external input is the native
;; Rust lib (libjerboa_native), built from vendor/jerboa-native-rs with the
;; features jcode needs (tls + crypto + wasm). SQLite session storage comes from the
;; pure Scheme jsqlite library fetched at its locked commit under vendor/.

(entry  "main-binary.ss")
(output "jcode")
;; do-binary-build auto-appends the bundled stdlib; list only project + vendor.
(libdirs "lib"
         "vendor/jsqlite/src"
         "vendor-overrides/jerboa-websearch/src"
         "vendor/jerboa-websearch/src")

;; Symbols statically registered via Sforeign_symbol (termbox TUI shim and
;; jerboa-native tls+crypto+wasm). The custom main.c #includes + calls them.
(ffi-symbols "support/ffi-symbols.list")

;; Stock jerbuild main.c + setenv(JERBOA_STATIC=1); see the file's header.
(main-c "support/jcode-main.c")

;; C shims compiled into the binary.
(extra-sources
  ("src/jcode/ui/jcode_tui_shim.c" cflags: "-DTB_OPT_ATTR_W=32 -Ivendor/termbox2")
  ("support/debug-repl-socket-shim.c")
  ("support/landlock-shim.c"))

;; jerboa-native (Rust): tls + crypto only (no sqlite/duckdb/pcap/postgres). jerbuild
;; runs cargo and links the resulting libjerboa_native.a.
(rust-crates
  ("vendor/jerboa-native-rs/Cargo.toml"
   features: "tls,crypto,wasm"
   no-default-features: #t))
