-
Notifications
You must be signed in to change notification settings - Fork 747
ot/earlgrey-cw310: custom build.rs that supports alternative linker script for tests #4190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
<
2BF1
span class="js-pending-review">Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to expose this? We could namespace new functionality in the future, but what we have seems like the normal APIs we can just expose directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you -- I am fine to re-export all of the functions inside default, but it seems easier to just have default be pub and then we can still hide functions inside the file by making individual functions not pub