mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-17 02:26:46 +00:00
Add cfg(ktest)
as a well-known configuration
This commit is contained in:
parent
ab1d931cb7
commit
8633893bb9
@ -209,6 +209,9 @@ fn build_kernel_elf(
|
||||
// We do not really allow unwinding except for kernel testing. However, we need to specify
|
||||
// this to show backtraces when panicking.
|
||||
"-C panic=unwind",
|
||||
// This is to let rustc know that "cfg(ktest)" is our well-known configuration.
|
||||
// See the [Rust Blog](https://blog.rust-lang.org/2024/05/06/check-cfg.html) for details.
|
||||
"--check-cfg cfg(ktest)",
|
||||
]);
|
||||
|
||||
if matches!(arch, Arch::X86_64) {
|
||||
|
@ -24,6 +24,12 @@ pub fn execute_forwarded_command(subcommand: &str, args: &Vec<String>) -> ! {
|
||||
cargo.arg("--target").arg(get_default_arch().triple());
|
||||
}
|
||||
cargo.args(args);
|
||||
|
||||
let env_rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();
|
||||
let rustflags = env_rustflags + " --check-cfg cfg(ktest)";
|
||||
|
||||
cargo.env("RUSTFLAGS", rustflags);
|
||||
|
||||
let status = cargo.status().expect("Failed to execute cargo");
|
||||
std::process::exit(status.code().unwrap_or(1));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user