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 candid_endpoints;
11pub mod canic_metadata;
12pub mod canister_build;
13pub mod canister_ready;
14mod cargo_metadata;
15pub mod cycle_balance;
16pub mod deployment_catalog;
17pub mod deployment_truth;
18pub mod duration;
19pub mod evidence_envelope;
20pub mod format;
21pub mod icp;
22pub mod icp_config;
23pub mod install_root;
24pub mod installed_deployment;
25pub mod policy_gate;
26pub mod registry;
27pub mod release_set;
28pub mod replica_query;
29pub mod response_parse;
30pub mod role_contract;
31pub mod state_manifest;
32pub mod subnet_registry;
33pub mod table;
34#[cfg(test)]
35mod test_support;
36mod workspace_discovery;
37
38pub(crate) fn cargo_command() -> Command {
39    let cargo = std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into());
40    let mut command = Command::new(cargo);
41
42    if let Some(toolchain) = std::env::var_os("RUSTUP_TOOLCHAIN") {
43        command.env("RUSTUP_TOOLCHAIN", toolchain);
44    }
45
46    command
47}
48
49pub(crate) fn icp_environment_from_env() -> String {
50    std::env::var("ICP_ENVIRONMENT").unwrap_or_else(|_| "local".to_string())
51}
52
53pub(crate) fn should_export_candid_artifacts(environment: &str) -> bool {
54    environment == "local"
55}
56
57pub(crate) fn remove_optional_file(path: &std::path::Path) -> std::io::Result<()> {
58    match std::fs::remove_file(path) {
59        Ok(()) => Ok(()),
60        Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()),
61        Err(err) => Err(err),
62    }
63}
64
65#[cfg(test)]
66mod tests;