Multi-File Projects
A project.yaml describes a multi-file Cambrian project: which .cam sources
to load, which backend to target, where to write output, and optional test /
Foundry / Lean knobs.
CLI
cambrian-transpiler --project path/to/project.yaml
Entry sources listed under sources: are merged into one program. Transitive
import "./other.cam" edges are followed automatically — shared helper
files need not be enumerated. Optional library_paths: / imports: pull
helpers from a search root (for example the contract standard
library) without listing them as project entries.
Minimal example
name: uniswap-v2
target: evm
output_dir: build/
sources:
- ERC20.cam
- UniswapV2Pair.cam
- UniswapV2Factory.cam
Common keys
| Key | Role |
|---|---|
name | Project name (informational / packaging) |
target | Backend: typically evm or lean |
sources | Entry-point .cam files (relative to the YAML) |
library_paths | Optional extra directories to search for shared .cam files (${VAR} expanded; absolute or relative to the YAML). None are built in. |
imports | Shared declaration files to load (helpers, not entities). Looked up next to the YAML, then in each library_paths directory. Names join the same program-wide namespace. |
output_dir | Where generated code is written (default build/) |
foundry | Foundry / solc options (optimizer, via_ir, remappings, …) |
fuzz | Shared fuzz defaults (runs, seed, shrink, …) |
invariant | Shared invariant defaults (runs, depth, fail_on_revert, …) |
lean | Lean-target knobs (numerics, proof_helpers, intrinsics, …) |
Foundry remappings
When using @solidity_import on an extern entity:
foundry:
optimizer: true
via_ir: true
remappings:
- "@openzeppelin/=lib/openzeppelin-contracts/"
- "forge-std/=lib/forge-std/src/"
Tests
fuzz:
runs: 64
seed: 1
shrink: true
invariant:
runs: 16
depth: 16
fail_on_revert: false
Imports vs project sources
sources:— entities and their tests, fuzz, and invariants. These are the files you own and deploy.imports:— shared helpers listed in YAML (pure fn, types,library,event/error,extern entity, …). Looked up next to the YAML, then in eachlibrary_pathsdirectory.import "./lib.cam"— always relative to the importing file. A missing file is an ordinary “file not found”;library_pathsis not searched.import "token/erc20-core.cam"(no.//../) — same directory as the importer first, then eachlibrary_pathsentry.- An imported file must not declare
entity,test,fuzz, orinvariant— put those onsources:. Imported names are not wrapped in a package; a clash is the same duplicate-name error as two declarations in one file.
library_paths:
- ${CAMBRIAN_STDLIB}
imports:
- math.cam
- token/erc20-core.cam
See Program Structure, project.yaml, and the Contract Standard Library.
Full key list
For the complete schema (including nested Foundry profiles and Lean emission options), see the reference page project.yaml.