Skip to content

Commit 74b9ed7

Browse files
authored
chore: add offline mode to cli build (#1605)
1 parent 738e407 commit 74b9ed7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/cli/src/commands/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ pub struct BuildArgs {
9393

9494
#[arg(long, default_value = "release", help = "Build profile")]
9595
pub profile: String,
96+
97+
#[arg(long, default_value = "false", help = "use --offline in cargo build")]
98+
pub offline: bool,
9699
}
97100

98101
#[derive(Clone, Default, clap::Args)]
@@ -127,6 +130,9 @@ pub(crate) fn build(build_args: &BuildArgs) -> Result<Option<PathBuf>> {
127130
.with_features(build_args.features.clone())
128131
.with_profile(build_args.profile.clone());
129132
guest_options.target_dir = build_args.target_dir.clone();
133+
if build_args.offline {
134+
guest_options.options = vec!["--offline".to_string()];
135+
}
130136

131137
let pkg = get_package(&build_args.manifest_dir);
132138
// We support builds of libraries with 0 or >1 executables.
@@ -215,6 +221,7 @@ mod tests {
215221
exe_commit_output: PathBuf::from(DEFAULT_EXE_COMMIT_PATH),
216222
profile: "dev".to_string(),
217223
target_dir: Some(target_dir.to_path_buf()),
224+
offline: false,
218225
};
219226
build(&build_args)?;
220227
assert!(

crates/toolchain/build/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct GuestOptions {
1717
/// Target directory
1818
pub target_dir: Option<PathBuf>,
1919
/// Custom options to pass as args to `cargo build`.
20-
pub(crate) options: Vec<String>,
20+
pub options: Vec<String>,
2121
}
2222

2323
impl GuestOptions {

0 commit comments

Comments
 (0)