1use std::process::Command;
4
5pub mod adoption;
6mod artifact_io;
7mod bootstrap_store;
8mod build_profile;
9pub mod build_provenance;
10mod cache_file;
11pub mod canister_build;
12mod cargo_metadata;
13pub mod deployment_catalog;
14pub mod deployment_truth;
15pub mod duration;
16pub mod evidence_envelope;
17pub mod format;
18pub mod icp;
19pub mod icp_config;
20pub mod install_root;
21pub mod installed_deployment;
22pub mod nns_node_operator;
23pub mod nns_node_provider;
24pub mod nns_registry;
25pub mod policy_gate;
26pub mod registry;
27pub mod release_set;
28pub mod replica_query;
29pub mod response_parse;
30pub mod subnet_catalog;
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 {
65 use super::should_export_candid_artifacts;
66
67 #[test]
69 fn candid_artifact_export_is_dev_only() {
70 assert!(should_export_candid_artifacts("local"));
71 assert!(!should_export_candid_artifacts("ic"));
72 }
73}