Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Transpiler CLI

cambrian-transpiler <INPUT.cam> [MORE.cam ...] [OPTIONS]
cambrian-transpiler --project <project.yaml> [--check] [--check-lean] [OPTIONS]
cambrian-transpiler --version [--json]
cambrian-transpiler --help

Targets

--targetOutput
evm (default)Flat Solidity + Foundry harness
leanLean 4 Lake project

Flags

FlagDescription
-o <dir>Output directory (single-file mode). Default build/<entity_name>-entity/, where <entity_name> is the first entity’s name in snake_case (Counter → build/counter-entity/)
--target <name>Select backend (single-file mode)
--project <file>Load a multi-file project.yaml
--checkParse, validate and run target checks; write no files
--check-leanAfter Lean codegen, run lake build in the output directory
--dump-astParse, print the AST in Cambrian syntax, exit (single-file mode)
--diagnostic-format human|jsonhuman (default) or json: one cambrian.diagnostics/v1 JSON envelope on stdout (compiler identity + diagnostic list); progress lines are suppressed
--max-errors NCap on recovered parse diagnostics (default 32)
--version [--json]Print the compiler build identity (--json: a cambrian.build-identity/v1 object)
--helpPrint usage

--help also lists --source-map; it has no effect on the EVM and Lean targets and only prints a warning.

Single-file vs project mode

  • Single-file mode takes one or more .cam files on the command line (e.g. a contract plus its .test.cam) and merges them. The first entity names the default output directory and, on EVM, the main .sol file.
  • Project mode (--project p.yaml) reads the target, sources and output_dir from the YAML (relative to the YAML file). -o, --target and --dump-ast are ignored, with a warning for each. The init-route rules for factory deploy (V62 / V63) are warnings in single-file EVM mode and errors in project mode, so use --project … --check before shipping.
  • --check-lean with an EVM target has no effect and prints a warning, in both modes.
  • On EVM the Foundry harness (foundry.toml, setup.sh, test/) is emitted only when the program contains tests, properties or invariants.

Exit codes

CodeMeaning
0Success (warnings do not change the exit code)
1Any error: diagnostics with error severity, unknown flag value or target, missing input, failed lake build under --check-lean, or a post-codegen E27 (the generated files are left on disk for inspection)

Examples

cambrian-transpiler contracts/counter.cam -o /tmp/c-evm --target evm
cambrian-transpiler contracts/counter.cam contracts/counter.test.cam -o /tmp/c-evm
cambrian-transpiler contracts/counter.cam -o /tmp/c-lean --target lean --check-lean
cambrian-transpiler contracts/counter.cam --check --diagnostic-format json
cambrian-transpiler --project examples/governor/project.yaml
cambrian-transpiler contracts/counter.cam --dump-ast

Build the binary with cargo build --release in the cambrian-lang workspace; the executable is target/release/cambrian-transpiler.