Skip to main content

Crate cabin_env

Crate cabin_env 

Source
Expand description

CABIN_* environment variable name constants and the typed builder for the cabin run / cabin test package-execution overlay.

Cabin is Cargo-inspired (not Cargo-compatible): the env vars it reads on the input side and the env vars it sets on the output side both follow Cargo’s naming conventions where the semantics line up, and diverge with CABIN_* names where Cabin’s C/C++ semantics differ. This crate is the single source of truth for both halves so the rest of the codebase agrees on names.

Crate boundaries:

  • this crate must not run processes, read configuration files, or touch the filesystem;
  • it must not depend on cabin, cabin-build, or other higher-level crates that would create cyclic dependencies;
  • it consumes typed inputs and produces typed outputs (the orchestration layer is responsible for mapping resolved values into PackageEnvInputs).

§Read-side env vars

Constants for every CABIN_* variable Cabin’s CLI reads live as pub const ... : &str = "..." in this crate. The orchestration layer reads each one through std::env::var (or an injected env_fn for tests) and threads the value through to the right resolver.

§Run / test overlay

cabin run and cabin test inject exactly the same small, stable set of package-execution variables built by package_env. The overlay is layered on top of the inherited environment; it never clears the user’s PATH, LANG, etc.

Re-exports§

pub use build_flags::CFLAGS;
pub use build_flags::CPPFLAGS;
pub use build_flags::CXXFLAGS;
pub use build_flags::EnvBuildFlags;
pub use build_flags::EnvBuildFlagsError;
pub use build_flags::LDFLAGS;
pub use build_flags::parse_env_build_flags;

Modules§

build_flags
Read-side ingestion of the conventional C/C++ build-flag environment variables: CPPFLAGS, CFLAGS, CXXFLAGS, and LDFLAGS.

Structs§

PackageEnvInputs
Inputs for package_env. The orchestration layer fills this in from already-resolved typed values. cabin run and cabin test use the same shape — the injected overlay does not depend on whether the target is a binary or a test.

Enums§

BoolError
Errors produced by parse_bool.

Constants§

CABIN_BUILD_DIR
Build output directory. Honored by commands that write to, read from, or deliberately exclude the build directory: cabin build, cabin clean, cabin run, cabin test, cabin fmt, and cabin tidy.
CABIN_BUILD_JOBS
Number of parallel jobs the build backend should use. Cargo-style: positive integer, 0 is rejected. Cabin reads this env var when --jobs is not on the command line.
CABIN_CACHE_DIR
Override for the artifact cache directory for a single invocation. Honored by every command that resolves an artifact cache. Wins over CABIN_CACHE_HOME and the XDG fallbacks below it.
CABIN_CACHE_HOME
Override for the per-user cache home — the directory cabin’s global cache lives under. Defaults to $XDG_CACHE_HOME/cabin, falling back to $HOME/.cache/cabin, per XDG Base Directory conventions. Mirrors the precedence shape CABIN_CONFIG_HOME uses for the per-user config home.
CABIN_COMPILER_WRAPPER
Compiler-cache wrapper selector (ccache, sccache, none). Honored by cabin-toolchain’s wrapper resolver.
CABIN_CONFIG
Path to a single explicit Cabin config file. When set, no other config files are loaded.
CABIN_CONFIG_HOME
Override for the per-user config home (the directory under which Cabin looks for config.toml). Honored by the cabin-config crate’s discovery layer.
CABIN_FMT
Override for the clang-format executable Cabin spawns from cabin fmt. When set and non-empty, the value is used verbatim (typically an absolute path) and the PATH lookup is skipped. When unset, Cabin spawns clang-format from PATH.
CABIN_MANIFEST_DIR
Absolute path to the package’s manifest directory.
CABIN_MANIFEST_PATH
Absolute path to the package’s cabin.toml manifest.
CABIN_NET_OFFLINE
Forbid network access for this invocation. Equivalent to passing --offline on the CLI. The CLI flag still takes precedence; the env var only sets the default.
CABIN_NO_CONFIG
When truthy, Cabin loads no config files at all. Used by the integration test harness so a developer’s ~/.config/cabin/config.toml cannot leak into tests.
CABIN_PACKAGE_NAME
Package name in the form the manifest declares.
CABIN_PACKAGE_VERSION
Resolved package version (<major>.<minor>.<patch> plus any pre-release / build suffix exactly as the manifest declares).
CABIN_PKG_CONFIG
Override for the pkg-config executable Cabin spawns when probing system = true dependencies. Same shape as CABIN_FMT and the other Cabin tool overrides: when set and non-empty the value is used verbatim (typically an absolute path) and the PATH lookup is skipped; when unset, Cabin spawns pkg-config from PATH. Cabin only invokes pkg-config when the workspace declares at least one system = true entry.
CABIN_PROFILE
Active profile name (dev, release, or any custom profile).
CABIN_TERM_COLOR
Terminal-color selector (auto, always, or never). Honored by the CLI when --color is not present.
CABIN_TERM_QUIET
Suppress Cabin-owned status output when no -q / --quiet CLI flag is present.
CABIN_TERM_VERBOSE
Enable verbose Cabin-owned status output when no -v / --verbose CLI flag is present.
CABIN_TIDY
Override for the run-clang-tidy executable Cabin spawns from cabin tidy. Same shape as CABIN_FMT: when set and non-empty the value is used verbatim and the PATH lookup is skipped, otherwise Cabin resolves run-clang-tidy against PATH.

Functions§

package_env
Build the CABIN_* overlay surfaced to a cabin run / cabin test child process. Returns a deterministic BTreeMap so two calls with the same inputs are byte-equal. Infallible: every value is copied straight from the typed inputs.
parse_bool
Whether a raw env-var value should be treated as truthy. Mirrors Cargo: any of 1, true, yes, on (case- insensitive) is truthy; an empty string is falsy; anything else is rejected via BoolError::Invalid.