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