Skip to content

Commit

Permalink
Merge pull request #160 from rcore-os/examples
Browse files Browse the repository at this point in the history
Tidy up aarch64 example build
  • Loading branch information
qwandor authored Oct 23, 2024
2 parents 4a4170d + 33bd6fe commit c0807ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions examples/aarch64/build.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
use cc::Build;
use std::env;

const PLATFORMS: [&str; 2] = ["crosvm", "qemu"];

fn main() {
env::set_var("CROSS_COMPILE", "aarch64-linux-gnu");
println!(
"cargo::rustc-check-cfg=cfg(platform, values(\"{}\"))",
PLATFORMS.join("\", \"")
);

env::set_var("CROSS_COMPILE", "aarch64-none-elf");
env::set_var("CC", "clang");

let platform = env::var("CARGO_CFG_PLATFORM").expect("Missing platform name");
match platform.as_ref() {
"qemu" => {
Build::new()
.file("entry.S")
.file("exceptions.S")
.file("idmap.S")
.compile("empty");
println!("cargo:rustc-link-arg=-Tqemu.ld");
}
"crosvm" => {
Build::new()
.file("entry.S")
.file("exceptions.S")
.file("idmap_crosvm.S")
.compile("empty");
println!("cargo:rustc-link-arg=-Tcrosvm.ld");
}
_ => {
panic!("Unexpected platform name \"{}\"", platform);
}
}
assert!(
PLATFORMS.contains(&platform.as_str()),
"Unexpected platform name {:?}. Supported platforms: {:?}",
platform,
PLATFORMS,
);
Build::new()
.file("entry.S")
.file("exceptions.S")
.file(format!("idmap_{platform}.S"))
.compile("example");
println!("cargo:rustc-link-arg=-T{platform}.ld");
println!("cargo:rustc-link-arg=-Timage.ld");
}
File renamed without changes.

0 comments on commit c0807ba

Please sign in to comment.