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