Skip to main content

canic_host/
lib.rs

1//! Host-side build, install, deployment, fleet-template, and release-set helpers for Canic workspaces.
2
3use std::process::Command;
4
5pub mod adoption;
6mod artifact_io;
7mod bootstrap_store;
8mod build_profile;
9pub mod build_provenance;
10pub mod canister_build;
11mod cargo_metadata;
12pub mod deployment_catalog;
13pub mod deployment_truth;
14pub mod duration;
15pub mod evidence_envelope;
16pub mod format;
17pub mod icp;
18pub mod icp_config;
19pub mod install_root;
20pub mod installed_deployment;
21pub mod policy_gate;
22pub mod registry;
23pub mod release_set;
24pub mod replica_query;
25pub mod response_parse;
26pub mod table;
27#[cfg(test)]
28mod test_support;
29mod workspace_discovery;
30
31pub(crate) fn cargo_command() -> Command {
32    let cargo = std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into());
33    let mut command = Command::new(cargo);
34
35    if let Some(toolchain) = std::env::var_os("RUSTUP_TOOLCHAIN") {
36        command.env("RUSTUP_TOOLCHAIN", toolchain);
37    }
38
39    command
40}
41
42pub(crate) fn icp_environment_from_env() -> String {
43    std::env::var("ICP_ENVIRONMENT").unwrap_or_else(|_| "local".to_string())
44}
45
46pub(crate) fn should_export_candid_artifacts(environment: &str) -> bool {
47    environment == "local"
48}
49
50pub(crate) fn remove_optional_file(path: &std::path::Path) -> std::io::Result<()> {
51    match std::fs::remove_file(path) {
52        Ok(()) => Ok(()),
53        Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()),
54        Err(err) => Err(err),
55    }
56}
57
58#[cfg(test)]
59mod tests;