ops/build.py (standard library only, Python 3.9+). It builds, for the target OS and CPU:
- the admin UI (
admin_ui/, npm; embedded into the server binary), - sargo, the Rust model router (
rust/sargo/, cargo), optionally embedded into the server binary, - the parsers of esbuild and typescript-go (
generate_esbuild:go runofgen_esbuildandgen_tsgoininternal/memory/memory_code), which are not in git and which every Go build below needs (they are the TypeScript/JavaScript/CSS code extraction ofremember, behind the Go build tagtsjs_css), - the Go binaries in
build/:gligabao(the server and CLI),gligabao_agent,gligabao_worker, and alwaysgligabao_agent_linux_amd64(baked into the Modal app by the ML sidecar, see ml_sidecar.md).
run_build.sh, run_build_rust.sh, part of run_pypi.sh) are only wrappers for Linux/macOS that call it. See “Build pipeline” in AGENTS.md.
Usage
Shell wrappers:
./run_build.sh [--no-admin-ui] [--sargo] is ops/build.py all, ./run_build_rust.sh [--static] [--embed] is ops/build.py sargo. PYTHON=... picks the interpreter.
How it is organised
- Pure helpers compute things from data:
Target(OS + arch, with the.exesuffix and the Rust target triple),target_from,go_env,go_release_args,sargo_env. - One pipeline per platform:
build_linux,build_macos,build_windows(tablePIPELINES). Each runs the admin UI step, the sargo step (if asked), then the Go binaries, for its OS. - One sargo builder per platform:
build_sargo_linux,build_sargo_macos,build_sargo_windows(tableSARGO_BUILDERS). - What cross-compiles: Go always does (
CGO_ENABLED=0, so no C toolchain), from any host to any of the 3 OSes. Rust does not without a cross linker, so sargo is built only on its own OS. Asking for--sargofor another OS fails at the start, before any slow step, saying which OS to run the build on. - Embedding:
rust/sargo/embed.goembedsrust/sargo/bin/sargo(the file has this name on every OS) andrust/sargo/config.toml.bin/holds only.gitkeepon a fresh checkout, so the Go build always works; the gligabao binary then reports sargo as not embedded. - Code parsers and the
tsjs_csstag:internal/memory/memory_code/{esparser,tsparser}are copies of third party parsers that are not committed (about 6 MB);generate_esbuildmakes them and every Go build ofops/build.py(andops/pypi.py) passes-tags tsjs_css. Without the tag a plaingo buildstill works, and TypeScript/JavaScript/CSS are reported as unsupported (Python and Go need no tag). The Dockerfile andrun_tests.shdo the same; a build ofgligabao_intmust callpython3 ops/build.py esbuildand use-tags tsjs_css. - Output:
build/gligabao[.exe],build/gligabao_agent[.exe],build/gligabao_worker[.exe],build/gligabao_agent_linux_amd64. The server is built plain (its version comes from the embeddedVERSION); the agent and worker are-trimpath -s -wwith-X main.version=<VERSION>.
Linux
- Needs: Go, Node + npm (unless
--no-admin-ui), and for--sargocargo (rustup, plusbuild-essential) andmusl-tools(sudo apt install -y musl-toolson Ubuntu). - sargo: a fully static binary for the target
<x86_64|aarch64>-unknown-linux-musl, so it runs on any Linux (glibc or musl) of the same CPU architecture.rustup target addis run for you. The TLS dependency (ring) compiles C code; cc-rs looks for<arch>-linux-musl-gcc, but Ubuntu’smusl-toolsonly shipsmusl-gcc, so the build setsCC_<triple>=musl-gcc. - Architecture: sargo is built for the host architecture only (a cross musl compiler would be needed);
--archdifferent from the host fails with a message. Build on an arm64 machine for arm64 sargo. The Go binaries cross-compile freely (GOOS=linux GOARCH=arm64 python3 ops/build.py all --no-admin-ui). - Result:
build/gligabaois static (CGO off) and embeds the static sargo.
macOS
- Needs: Go, Node + npm, and for
--sargocargo (rustup) and the Xcode command line tools (xcode-select --install, the linker). - sargo: target
aarch64-apple-darwin(Apple silicon,arm64) orx86_64-apple-darwin(Intel,amd64);rustup target addis run for you. Both architectures build on either kind of Mac, so one machine can produce both. macOS binaries cannot be fully static, but sargo links only system libraries, so--staticjust means “build for the explicit target triple”. - Embedding: the embedded sargo must match the gligabao binary: build both for the same
--arch(python3 ops/build.py all --os darwin --arch amd64 --sargoon an Apple silicon Mac). - Result:
build/gligabao(a Mach-O binary, CGO off). The Go binaries are not code-signed or notarized by this program; do that separately for distribution.
Windows
- Needs: Go, Node + npm (
npm.cmdis found automatically), and for--sargocargo (downloadrustup-init.exefrom rustup.rs) with the Visual Studio C++ Build Tools (the MSVC linker). Run it from a normal terminal:py ops/build.py all --sargo(orpython). No bash,makeor MSYS is needed. - sargo: target
x86_64-pc-windows-msvcoraarch64-pc-windows-msvc, built withRUSTFLAGS=-C target-feature=+crt-staticso the.exeneeds no Visual C++ redistributable. Forarm64install the ARM64 build tools component of Visual Studio. - Executables: every output gets
.exe(gligabao.exe,gligabao_agent.exe,gligabao_worker.exe;gligabao_agent_linux_amd64is a Linux file and has no suffix). The embedded sargo is stored asbin/sargobut extracted assargo.exeat run time (internal/sargo/server.go), because Windows only runs.exefiles. - Paths: the program only uses
pathliband argument lists (never a shell), so paths with spaces and backslashes are safe.
Not done by this program
- The container image (
Dockerfile,run_build_container.sh; it contains the ML sidecar too) builds in its own Docker stages. TheDockerfiledoes not yet include sargo (seeleftover_tasks/). - The PyPI packaging (staging, wheels, twine, upload) is
ops/pypi.py, which usesops/build.pyfor the admin UI, sargo and the server binary. See pypi.md. - Running one OS’s pipeline for another OS’s sargo (e.g. in CI, use one runner per OS and run
all --sargoon each).