-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ot/earlgrey-cw310: support alternative linker script for tests
This commit fixes the hack where OT currently relies on overwriting the linker script in the target directory, instead using a custom build.rs to allow this board to override the linker script in use based on the value of an environment variable. This PR also includes some cleanup to remove some lines that I believe are no longer necessary in the current build system. These line were scattered around the "test" rule for various boards and would directly copy files into the build directory, but I that is already handled by Cargo today.
- Loading branch information
1 parent
772ed33
commit db4ee1d
Showing
10 changed files
with
78 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed under the Apache License, Version 2.0 or the MIT License. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// Copyright Tock Contributors 2024. | ||
|
||
//! This board uses a custom build script to enable selecting a different layout | ||
//! file for tests, which require a different layout than normal kernel builds. | ||
//! The script is lightly adapted from the `default_linker_script` in | ||
//! `tock_build_scripts`, and uses the functions provided by that crate. | ||
|
||
use std::path::Path; | ||
|
||
const LINKER_SCRIPT_OVERRIDE_ENV: &str = "LINKER_SCRIPT_OVERRIDE"; | ||
|
||
fn main() { | ||
let linker_script = | ||
std::env::var(LINKER_SCRIPT_OVERRIDE_ENV).unwrap_or("layout.ld".to_string()); | ||
println!("cargo:rerun-if-env-changed={}", LINKER_SCRIPT_OVERRIDE_ENV); | ||
|
||
if !Path::new(&linker_script).exists() { | ||
panic!( | ||
"Boards must provide a linker script file; path does not exist: {:?}", | ||
linker_script | ||
); | ||
} | ||
tock_build_scripts::default::rustflags_check(); | ||
tock_build_scripts::default::include_tock_kernel_layout(); | ||
tock_build_scripts::default::add_board_dir_to_linker_search_path(); | ||
tock_build_scripts::default::set_and_track_linker_script(linker_script); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters