Add --offline flag
This commit is contained in:
@ -16,6 +16,7 @@ struct Config {
|
|||||||
dump: bool,
|
dump: bool,
|
||||||
features: Vec<String>,
|
features: Vec<String>,
|
||||||
no_default_features: bool,
|
no_default_features: bool,
|
||||||
|
offline: bool,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
workspace: bool,
|
workspace: bool,
|
||||||
}
|
}
|
||||||
@ -33,6 +34,7 @@ impl Default for Config {
|
|||||||
dump: false,
|
dump: false,
|
||||||
features: vec![],
|
features: vec![],
|
||||||
no_default_features: false,
|
no_default_features: false,
|
||||||
|
offline: false,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
workspace: false,
|
workspace: false,
|
||||||
}
|
}
|
||||||
@ -211,6 +213,9 @@ fn build_bpf(config: Config, manifest_path: Option<PathBuf>) {
|
|||||||
if let Some(manifest_path) = manifest_path {
|
if let Some(manifest_path) = manifest_path {
|
||||||
metadata_command.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| {
|
let metadata = metadata_command.exec().unwrap_or_else(|err| {
|
||||||
eprintln!("Failed to obtain package metadata: {}", err);
|
eprintln!("Failed to obtain package metadata: {}", err);
|
||||||
@ -268,6 +273,12 @@ fn main() {
|
|||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Dump ELF information to a text file on success"),
|
.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(
|
||||||
Arg::with_name("verbose")
|
Arg::with_name("verbose")
|
||||||
.short("v")
|
.short("v")
|
||||||
@ -338,6 +349,7 @@ fn main() {
|
|||||||
.ok()
|
.ok()
|
||||||
.unwrap_or_else(Vec::new),
|
.unwrap_or_else(Vec::new),
|
||||||
no_default_features: matches.is_present("no_default_features"),
|
no_default_features: matches.is_present("no_default_features"),
|
||||||
|
offline: matches.is_present("offline"),
|
||||||
verbose: matches.is_present("verbose"),
|
verbose: matches.is_present("verbose"),
|
||||||
workspace: matches.is_present("workspace"),
|
workspace: matches.is_present("workspace"),
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,7 @@ struct Config {
|
|||||||
extra_cargo_test_args: Vec<String>,
|
extra_cargo_test_args: Vec<String>,
|
||||||
features: Vec<String>,
|
features: Vec<String>,
|
||||||
no_default_features: bool,
|
no_default_features: bool,
|
||||||
|
offline: bool,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
workspace: bool,
|
workspace: bool,
|
||||||
}
|
}
|
||||||
@ -31,6 +32,7 @@ impl Default for Config {
|
|||||||
extra_cargo_test_args: vec![],
|
extra_cargo_test_args: vec![],
|
||||||
features: vec![],
|
features: vec![],
|
||||||
no_default_features: false,
|
no_default_features: false,
|
||||||
|
offline: false,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
workspace: false,
|
workspace: false,
|
||||||
}
|
}
|
||||||
@ -121,6 +123,9 @@ fn test_bpf(config: Config, manifest_path: Option<PathBuf>) {
|
|||||||
if let Some(manifest_path) = manifest_path.as_ref() {
|
if let Some(manifest_path) = manifest_path.as_ref() {
|
||||||
metadata_command.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| {
|
let metadata = metadata_command.exec().unwrap_or_else(|err| {
|
||||||
eprintln!("Failed to obtain package metadata: {}", err);
|
eprintln!("Failed to obtain package metadata: {}", err);
|
||||||
@ -200,6 +205,12 @@ fn main() {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Place final BPF build artifacts in this directory"),
|
.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(
|
||||||
Arg::with_name("verbose")
|
Arg::with_name("verbose")
|
||||||
.short("v")
|
.short("v")
|
||||||
@ -233,6 +244,7 @@ fn main() {
|
|||||||
.ok()
|
.ok()
|
||||||
.unwrap_or_else(Vec::new),
|
.unwrap_or_else(Vec::new),
|
||||||
no_default_features: matches.is_present("no_default_features"),
|
no_default_features: matches.is_present("no_default_features"),
|
||||||
|
offline: matches.is_present("offline"),
|
||||||
verbose: matches.is_present("verbose"),
|
verbose: matches.is_present("verbose"),
|
||||||
workspace: matches.is_present("workspace"),
|
workspace: matches.is_present("workspace"),
|
||||||
..Config::default()
|
..Config::default()
|
||||||
|
Reference in New Issue
Block a user