From 114a2c40bd2baca8e9d0142e374040fd40dbcb6c Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 7 May 2024 00:57:24 +0800 Subject: [PATCH] add a flag for changing targets gracefully at the moment an SVD pointer hangs out that messes builds up when changing targets (sometimes) -- this is the pointer that includes extra files in the build for targets that have disjoint RTL sources. add a flag for cleaning this up. --- xtask/src/builder.rs | 21 ++++++++++++++++----- xtask/src/main.rs | 6 ++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/xtask/src/builder.rs b/xtask/src/builder.rs index 7f0ee0561..ced1c74c1 100644 --- a/xtask/src/builder.rs +++ b/xtask/src/builder.rs @@ -146,6 +146,7 @@ pub(crate) struct Builder { no_image: bool, /// when Some, specifies a swap region as offset, size swap: Option<(u32, u32)>, + change_target: bool, } impl Builder { @@ -174,6 +175,7 @@ impl Builder { dry_run: false, no_image: false, swap: None, + change_target: false, } } @@ -226,6 +228,11 @@ impl Builder { self } + pub fn set_change_target_flag(&mut self) -> &mut Builder { + self.change_target = true; + 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, @@ -764,6 +771,15 @@ impl Builder { println!("Dry run requested: only building and not running"); } } else { + let svd_spec_path = format!( + "target/{}/{}/build/SVD_PATH", + self.target.as_ref().expect("target"), + self.stream.as_str() + ); + if self.change_target { + std::fs::remove_file(&svd_spec_path).ok(); // don't fail if the file does not exist + } + // ------ build the kernel ------ let mut kernel_extra = vec![]; if self.kernel_disable_defaults { @@ -823,11 +839,6 @@ impl Builder { } // ---------- extract SVD file path, as computed by utralib ---------- - let svd_spec_path = format!( - "target/{}/{}/build/SVD_PATH", - self.target.as_ref().expect("target"), - self.stream.as_str() - ); let mut svd_spec_file = OpenOptions::new().read(true).open(svd_spec_path)?; let mut svd_path_str = String::new(); svd_spec_file.read_to_string(&mut svd_path_str)?; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 95fece991..6c7d25ab9 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -193,6 +193,9 @@ fn main() -> Result<(), Box> { if env::args().filter(|x| x == "--offline").count() != 0 { builder.add_global_flag("--offline"); } + if env::args().filter(|x| x == "--change-target").count() != 0 { + builder.set_change_target_flag(); + } // manage an ugly patch we have to do to selectively configure AES for only cramium-soc targets match builder::search_in_file("services/aes/Cargo.toml", "default = []") { @@ -596,6 +599,7 @@ fn print_help() { [--gdb-stub] [--debug-loader] [--offline] + [--change-target] [cratespecs] is a list of 0 or more items of the following syntax: [name] crate 'name' to be built from local source @@ -620,6 +624,8 @@ be merged in with explicit app/service treatment with the following flags: [--debug-loader] Enable debug printing in the loader [--offline] Avoid network traffic [--swap offset:size] Specify a region for swap memory. The behavior of this depends on the target. +[--change-target] Used to clean the cached target/*/*/build/SVD_PATH when changing build targets. + This will also force a full rebuild every time the flag is specified. - An 'app' must be enumerated in apps/manifest.json. A pre-processor configures the launch menu based on the list of specified apps.