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 subnet_registry;
31pub mod table;
32#[cfg(test)]
33mod test_support;
34mod workspace_discovery;
35
36pub(crate) fn cargo_command() -> Command {
37    let cargo = std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into());
38    let mut command = Command::new(cargo);
39
40    if let Some(toolchain) = std::env::var_os("RUSTUP_TOOLCHAIN") {
41        command.env("RUSTUP_TOOLCHAIN", toolchain);
42    }
43
44    command
45}
46
47pub(crate) fn icp_environment_from_env() -> String {
48    std::env::var("ICP_ENVIRONMENT").unwrap_or_else(|_| "local".to_string())
49}
50
51pub(crate) fn should_export_candid_artifacts(environment: &str) -> bool {
52    environment == "local"
53}
54
55pub(crate) fn remove_optional_file(path: &std::path::Path) -> std::io::Result<()> {
56    match std::fs::remove_file(path) {
57        Ok(()) => Ok(()),
58        Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()),
59        Err(err) => Err(err),
60    }
61}
62
63#[cfg(test)]
64mod tests;