add --offline flag

this has become necessary because with the inclusion of a version
number in a crate name, rustc always consults the on-line index on
every build (even when it's not necessary), which can double the
build time. Using --offline reduces that thrashing.
This commit is contained in:
bunnie 2024-02-01 00:50:43 +08:00
parent 31efca3e9c
commit 886215c1b0
2 changed files with 14 additions and 0 deletions

View file

@ -122,6 +122,7 @@ pub(crate) struct Builder {
/// services identically.
apps: Vec<CrateSpec>,
features: Vec<String>,
global_flags: Vec<String>,
stream: BuildStream,
min_ver: String,
target: Option<String>,
@ -149,6 +150,7 @@ impl Builder {
services: Vec::new(),
apps: Vec::new(),
features: Vec::new(),
global_flags: Vec::new(),
stream: BuildStream::Release,
min_ver: crate::MIN_XOUS_VERSION.to_string(),
target: Some(crate::TARGET_TRIPLE_RISCV32.to_string()),
@ -198,6 +200,11 @@ impl Builder {
self
}
pub fn add_global_flag<'a>(&'a mut self, flag: &str) -> &'a mut Builder {
self.global_flags.push(flag.to_string());
self
}
/// Set a minimum xous version. This is the minimum Xous version necessary to read
/// the PDDB that is generated by this build. The purpose of this is so that we can
/// trim migration code out of the PDDB: when we have a breaking change to the PDDB,
@ -434,6 +441,10 @@ impl Builder {
);
remote_args.push(&output_root);
for flag in self.global_flags.iter() {
local_args.push(flag);
}
// modify the stream if release (debug is the default for builds; release is the default for installs)
match stream {
BuildStream::Release => {

View file

@ -154,6 +154,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if env::args().filter(|x| x == "--debug-loader").count() != 0 {
builder.add_loader_feature("debug-print");
}
if env::args().filter(|x| x == "--offline").count() != 0 {
builder.add_global_flag("--offline");
}
// ---- now process the verb plus position dependent arguments ----
let mut args = env::args();