diff --git a/sdk/cargo-build-bpf/src/main.rs b/sdk/cargo-build-bpf/src/main.rs index 836f306665..297112cf5d 100644 --- a/sdk/cargo-build-bpf/src/main.rs +++ b/sdk/cargo-build-bpf/src/main.rs @@ -16,6 +16,7 @@ struct Config { dump: bool, features: Vec, no_default_features: bool, + offline: bool, verbose: bool, workspace: bool, } @@ -33,6 +34,7 @@ impl Default for Config { dump: false, features: vec![], no_default_features: false, + offline: false, verbose: false, workspace: false, } @@ -211,6 +213,9 @@ fn build_bpf(config: Config, manifest_path: Option) { if let Some(manifest_path) = manifest_path { metadata_command.manifest_path(manifest_path); } + if config.offline { + metadata_command.other_options(vec!["--offline".to_string()]); + } let metadata = metadata_command.exec().unwrap_or_else(|err| { eprintln!("Failed to obtain package metadata: {}", err); @@ -268,6 +273,12 @@ fn main() { .takes_value(false) .help("Dump ELF information to a text file on success"), ) + .arg( + Arg::with_name("offline") + .long("offline") + .takes_value(false) + .help("Run without accessing the network"), + ) .arg( Arg::with_name("verbose") .short("v") @@ -338,6 +349,7 @@ fn main() { .ok() .unwrap_or_else(Vec::new), no_default_features: matches.is_present("no_default_features"), + offline: matches.is_present("offline"), verbose: matches.is_present("verbose"), workspace: matches.is_present("workspace"), }; diff --git a/sdk/cargo-test-bpf/src/main.rs b/sdk/cargo-test-bpf/src/main.rs index 4f2a8b3439..6adfa29cbb 100644 --- a/sdk/cargo-test-bpf/src/main.rs +++ b/sdk/cargo-test-bpf/src/main.rs @@ -17,6 +17,7 @@ struct Config { extra_cargo_test_args: Vec, features: Vec, no_default_features: bool, + offline: bool, verbose: bool, workspace: bool, } @@ -31,6 +32,7 @@ impl Default for Config { extra_cargo_test_args: vec![], features: vec![], no_default_features: false, + offline: false, verbose: false, workspace: false, } @@ -121,6 +123,9 @@ fn test_bpf(config: Config, manifest_path: Option) { if let Some(manifest_path) = manifest_path.as_ref() { metadata_command.manifest_path(manifest_path); } + if config.offline { + metadata_command.other_options(vec!["--offline".to_string()]); + } let metadata = metadata_command.exec().unwrap_or_else(|err| { eprintln!("Failed to obtain package metadata: {}", err); @@ -200,6 +205,12 @@ fn main() { .takes_value(true) .help("Place final BPF build artifacts in this directory"), ) + .arg( + Arg::with_name("offline") + .long("offline") + .takes_value(false) + .help("Run without accessing the network"), + ) .arg( Arg::with_name("verbose") .short("v") @@ -233,6 +244,7 @@ fn main() { .ok() .unwrap_or_else(Vec::new), no_default_features: matches.is_present("no_default_features"), + offline: matches.is_present("offline"), verbose: matches.is_present("verbose"), workspace: matches.is_present("workspace"), ..Config::default()