Skip to main content
Documentation menu

Cargo-inspired interface

Cabin is Cargo-inspired, not Cargo-compatible. The interface borrows Cargo’s vocabulary where the semantics line up — so a Cargo user picks Cabin up quickly — and deliberately diverges where Cargo’s terminology would be misleading for C/C++.

This page is the audit checkpoint for that contract: it lists what Cabin adopts, what it renames, what it intentionally leaves out, and where to look for the rule when in doubt.

What Cabin adopts from Cargo

Subcommands

Cabin commandCargo analogueNotes
cabin initcargo initSingle-package generator (current directory). --bin / --lib select scaffold kind (binary by default). See new-and-init.md.
cabin newcargo newSingle-package generator (new directory). --bin / --lib select scaffold kind (binary by default). See new-and-init.md.
cabin buildcargo buildPlans + invokes Ninja
cabin checkcargo checkReuses the build graph but compiles with -fsyntax-only; no objects or binaries
cabin cleancargo cleanRemoves Cabin-generated build artifacts
cabin runcargo runBuilds and runs an exec target; -- forwards args
cabin testcargo testBuilds + runs test targets
cabin fetchcargo fetchDownloads + verifies registry artifacts
cabin updatecargo updateRe-resolves, refreshes lockfile
cabin metadatacargo metadataDeterministic JSON state
cabin treecargo treeResolved dependency tree
cabin explain(no direct analogue)Typed answers about the resolved graph
cabin vendorcargo vendorFile-registry materialization
cabin packagecargo packageSource-archive + canonical metadata
cabin publishcargo publishLocal file-registry publish (no remote yet)
cabin fmtcargo fmtFormats workspace C/C++ sources with clang-format
cabin versioncargo versionPrints Cabin’s version; with -v adds release, commit, host triple, and OS fields when available. cabin --version keeps working as the concise framework spelling.

Flags / options

FlagSemanticsCargo analogue
-p, --package <name>Workspace package selectionidentical
--workspace / --exclude <name>Workspace-wide selectionidentical
--manifest-path <path>Manifest discoveryidentical
--features <names>Enable named featuresidentical
--all-features / --no-default-featuresFeature selectionidentical
--releaseCompatibility alias for --profile releaseidentical
--profile <name>Build profileidentical
-j, --jobs <N>Number of parallel jobs for the build backendidentical
--locked / --frozenLockfile policyidentical
--offlineForbid network accessidentical
--bin <name>Pick an executable to run (cabin run only)matches Cargo’s cargo run --bin; Cabin does not offer a Cargo-style --target <name> manifest-target selector on cabin build / cabin test (see below)
--color <when>Terminal-color choice (auto / always / never)identical wording; Cabin’s env-var spelling is CABIN_TERM_COLOR
-v, --verboseIncrease Cabin’s status output volume; specify twice for very verbose outputidentical
-q, --quietSuppress Cabin-owned status messages (errors are unaffected)identical
--listPrint every subcommand (including distribution helpers hidden from --help) and exitidentical wording; cabin --help is curated for day-to-day use, cabin --list is the full directory

Environment variables

Read-side and write-side CABIN_* env vars mirror Cargo’s CARGO_* shape (see environment-variables.md for the full list). Highlights:

  • CABIN_BUILD_DIR analogous to CARGO_TARGET_DIR, but spelled with Cabin’s own name to match the --build-dir flag.
  • CABIN_NET_OFFLINE analogous to CARGO_NET_OFFLINE.
  • CABIN_TERM_COLOR analogous to CARGO_TERM_COLOR.

What Cabin deliberately diverges on

--build-dir instead of --target-dir

Cabin keeps the word target for platform / toolchain targets (x86_64-unknown-linux-gnu, …). Cargo’s --target-dir would be ambiguous in C/C++ where “target” also means a manifest-declared library / executable target. The build output directory flag is therefore --build-dir, the config key is [paths] build-dir, and the env var is CABIN_BUILD_DIR.

Default build directory: build/.

No --target overload for manifest-target selection

Cargo overloads --target for binary selection in some contexts. Cabin does not offer a --target <name> manifest-target selector on any command.

Selection works through three other surfaces:

  • cabin run --bin <name> picks an executable to build and run — the same shape Cargo uses for cargo run --bin. This is the only single-target selector in the CLI.
  • cabin test builds every test target in the selected packages. Narrow the run by narrowing the package selection.
  • cabin build builds every default-buildable target (library, header_only, executable) in the selected packages. Dev-only kinds (test, example) are excluded from this default and reach the build graph only as transitive deps of a selected target.

Per-language separation

Cabin keeps CC vs. CXX, and CFLAGS vs. CXXFLAGS (whether passed via manifest, profile, or env vars) strictly separated. Cargo’s RUSTFLAGS is single-language by definition; C/C++ has two language slots and they do not share argv space. The fingerprint distinguishes the two, so a flag moved between slots has a distinct build identity even when the argv string is identical.

Package-metadata as compile-time macros

Cargo exposes CARGO_PKG_* to Rust code as compile-time env vars through env!(). C/C++ has no env!(): turning package metadata into compiler -D flags by default would (a) leak into public headers, (b) change ABI when the version bumps, and (c) churn every affected object file. Cabin’s default is therefore no automatic -DCABIN_PACKAGE_* macros. cabin run and cabin test receive a scoped subset of the metadata as env vars; compile commands stay clean. Explicit opt-in macros may be added in a future change behind a manifest flag, with the orchestration layer threading them through the build-configuration fingerprint so a future binary-artifact cache can key on the changed inputs.

cabin explain

cabin explain has no direct Cargo equivalent. It exposes a typed query model (package, target, source, feature, build-config) so users can ask “why is this package / target / feature / configuration in the resolved state?” without re-deriving it by hand. See metadata-tree-explain.md.

What Cabin intentionally does not have

These are Cargo / Rust concepts that do not (yet) translate to Cabin’s C/C++ scope:

  • cargo doc — Cabin has no doc generator yet; rustdoc has no C/C++ equivalent that would justify the surface.
  • cargo install — install / prefix semantics are not designed.
  • cargo search / cargo login / cargo logout / cargo owner / cargo yank — registry-server work is out of scope until a Cabin registry server exists.
  • cargo rustc / cargo rustdoc / cargo fix — Rust-specific.
  • cargo bench — Cabin has no benchmark target kind and no benchmark harness model. Users who need to time a binary declare an executable and run it themselves.
  • Doctest / book / fix / clippy / miri analogues.

If a later iteration wants to add one of these, it should land alongside an explicit motivation rather than as an opportunistic addition.

Where the audit lives

The full audit checklist is captured by the Cargo-inspired interface section in architecture.md. When this page changes, that section in the architecture document should be updated in the same commit.