xtask: support building under riscv32imac-unknown-xous-elf

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-08-03 11:26:15 +08:00
parent ff23ba7eb0
commit 987434433e
2 changed files with 11 additions and 18 deletions

View file

@ -1,4 +1,3 @@
// this code vendored in from https://github.com/terry90/internationalization-rs // this code vendored in from https://github.com/terry90/internationalization-rs
// the original crate is targeted at a non-workspace, `std` project structure. The adaptations here // the original crate is targeted at a non-workspace, `std` project structure. The adaptations here
// make it suitable for `no_std` and workspace integration. // make it suitable for `no_std` and workspace integration.
@ -29,7 +28,7 @@ fn read_locales() -> Translations {
for entry in glob(&locales).expect("Failed to read glob pattern") { for entry in glob(&locales).expect("Failed to read glob pattern") {
let entry = entry.unwrap(); let entry = entry.unwrap();
println!("cargo:rerun-if-changed={}", entry.display()); // println!("cargo:rerun-if-changed={}", entry.display());
let file = File::open(entry).expect("Failed to open the file"); let file = File::open(entry).expect("Failed to open the file");
let mut reader = std::io::BufReader::new(file); let mut reader = std::io::BufReader::new(file);
let mut content = String::new(); let mut content = String::new();

View file

@ -10,7 +10,8 @@ use generate_locales::*;
type DynError = Box<dyn std::error::Error>; type DynError = Box<dyn std::error::Error>;
const TARGET: &str = "riscv32imac-unknown-none-elf"; const PROGRAM_TARGET: &str = "riscv32imac-unknown-none-elf";
const KERNEL_TARGET: &str = "riscv32imac-unknown-none-elf";
enum MemorySpec { enum MemorySpec {
SvdFile(String), SvdFile(String),
@ -31,14 +32,7 @@ impl std::fmt::Display for BuildError {
impl std::error::Error for BuildError {} impl std::error::Error for BuildError {}
fn main() { fn main() -> Result<(), Box<dyn std::error::Error>> {
if let Err(e) = try_main() {
eprintln!("{}", e);
std::process::exit(-1);
}
}
fn try_main() -> Result<(), DynError> {
let hw_pkgs = [ let hw_pkgs = [
"gam", "gam",
"status", "status",
@ -287,7 +281,7 @@ fn build_hw_image(
let kernel = build_kernel(debug)?; let kernel = build_kernel(debug)?;
let mut init = vec![]; let mut init = vec![];
let base_path = build(packages, debug, Some(TARGET), None, extra_args)?; let base_path = build(packages, debug, Some(PROGRAM_TARGET), None, extra_args)?;
for pkg in packages { for pkg in packages {
let mut pkg_path = base_path.clone(); let mut pkg_path = base_path.clone();
pkg_path.push(pkg); pkg_path.push(pkg);
@ -296,7 +290,7 @@ fn build_hw_image(
let mut loader = build( let mut loader = build(
&["loader"], &["loader"],
debug, debug,
Some(TARGET), Some(KERNEL_TARGET),
Some("loader".into()), Some("loader".into()),
None, None,
)?; )?;
@ -390,8 +384,8 @@ fn build_hw_image(
} }
println!(); println!();
println!("Signed loader at {}", loader_bin.to_str().unwrap()); println!("Signed loader at {}", loader_bin.display());
println!("Signed kernel at {}", xous_img_path.to_str().unwrap()); println!("Signed kernel at {}", xous_img_path.display());
Ok(()) Ok(())
} }
@ -484,7 +478,7 @@ fn build_kernel(debug: bool) -> Result<PathBuf, DynError> {
let mut path = build( let mut path = build(
&["kernel"], &["kernel"],
debug, debug,
Some(TARGET), Some(KERNEL_TARGET),
Some("kernel".into()), Some("kernel".into()),
None, None,
)?; )?;
@ -560,7 +554,7 @@ fn create_image(
let stream = if debug { "debug" } else { "release" }; let stream = if debug { "debug" } else { "release" };
let mut args = vec!["run", "--package", "tools", "--bin", "create-image", "--"]; let mut args = vec!["run", "--package", "tools", "--bin", "create-image", "--"];
let output_file = format!("target/{}/{}/args.bin", TARGET, stream); let output_file = format!("target/{}/{}/args.bin", PROGRAM_TARGET, stream);
args.push(&output_file); args.push(&output_file);
args.push("--kernel"); args.push("--kernel");
@ -586,7 +580,7 @@ fn create_image(
if !status.success() { if !status.success() {
return Err("cargo build failed".into()); return Err("cargo build failed".into());
} }
Ok(project_root().join(&format!("target/{}/{}/args.bin", TARGET, stream))) Ok(project_root().join(&format!("target/{}/{}/args.bin", PROGRAM_TARGET, stream)))
} }
fn cargo() -> String { fn cargo() -> String {