Appearance
Build Scripts
The scripts/build/ directory contains all build pipelines and supporting code generators.
Overview
build/
├── all.sh Full build (server + mobile)
├── server.sh Server build pipeline
├── mobile.sh Mobile build pipeline
├── generators/
│ ├── embeds.ts Static file and migration embed generator
│ └── installer.ts CLI bundler and installer generator
└── templates/
└── installer.sh Installer shell script templateFull Build (all.sh)
Runs the complete build pipeline for both server and mobile:
bash
bun build
# or directly: bash scripts/build/all.shSteps:
- Run server tests (
bun testinserver/) - Run contract tests (
bun scripts/test/contracts.ts) - Build server binaries via
server.sh --server-only - Build mobile apps via
mobile.sh
Server Build (server.sh)
Builds the web frontend, generates embeds, compiles Linux binaries, runs smoke tests, and optionally uploads.
bash
bun build:server
# or directly: bash scripts/build/server.shFlags:
--server-only— skip the upload step (used byall.sh)--skip-upload— skip the upload step
Steps:
- Build web frontend (
bun build.ts --releaseinweb/) - Generate static embeds (
generators/embeds.ts) - Generate installer script (
generators/installer.ts) - Compile Linux binaries (arm64 + x64) with
bun build --compile - Run binary smoke tests (
scripts/test/binary.sh) - Upload binaries and installer to deploy server (unless skipped)
Mobile Build (mobile.sh)
Builds the Flutter app for both platforms.
bash
bun build:mobile
# or directly: bash scripts/build/mobile.shSteps:
- Fetch Flutter dependencies
- Run Flutter analyze
- Build Android App Bundle (AAB)
- Build iOS IPA (macOS only, requires Xcode signing)
- Copy artifacts to
releases/
Generators
generators/embeds.ts
Generates two files that embed assets into the compiled server binary:
server/src/static_embeds.ts— maps URL paths to web frontend files usingimport ... with { type: "file" }server/src/migration_embeds.ts— bundles database migration code for runtime execution
This runs automatically as part of server.sh, but can also be run standalone:
bash
bun scripts/build/generators/embeds.tsgenerators/installer.ts
Bundles the CLI TypeScript code (from scripts/cli/) into a single self-contained installer shell script:
- Uses
Bun.build()to bundlecli/main.tswith all dependencies - Reads the template from
templates/installer.sh - Replaces
###version###,###util.sh###, and###util.ts###placeholders - Writes the final
releases/installer.sh
Templates
templates/installer.sh
Shell script template with placeholder markers that generators/installer.ts fills in at build time. Contains the installer logic for downloading and setting up SafeCall on a production server.