-
Notifications
You must be signed in to change notification settings - Fork 500
support "vxworks" and "nto" OSes on get_base_archiver_variant
#1456
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
Open
onur-ozkan
wants to merge
6
commits into
rust-lang:main
Choose a base branch
from
onur-ozkan:extend-ar-finding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
82eec26
support "vxworks" and "nto" OSes on `get_base_archiver_variant`
onur-ozkan 91646ce
improve target matching for Neutrino
onur-ozkan 8301ac2
apply nits
onur-ozkan a1af860
add test coverage for archiver
onur-ozkan bb33e30
bless fmt
onur-ozkan 59c3044
extend archiver coverage
onur-ozkan 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use std::env; | ||
|
||
#[test] | ||
fn main() { | ||
unsafe { env::set_var("AR_i586_pc_nto_qnx700", "custom-ar") }; | ||
let ar = get_ar_for_target("i586-pc-nto-qnx700"); | ||
assert_eq!(ar, "custom-ar"); | ||
unsafe { env::remove_var("AR_i586_pc_nto_qnx700") }; | ||
|
||
unsafe { env::set_var("AR", "custom-ar2") }; | ||
let ar = get_ar_for_target("x86_64-unknown-linux-gnu"); | ||
assert_eq!(ar, "custom-ar2"); | ||
unsafe { env::remove_var("AR") }; | ||
|
||
let ar = get_ar_for_target("x86_64-unknown-linux-gnu"); | ||
assert_eq!(ar, "ar"); | ||
|
||
let ar = get_ar_for_target("x86_64-unknown-linux-musl"); | ||
assert_eq!(ar, "ar"); | ||
|
||
let ar = get_ar_for_target("riscv64gc-unknown-openbsd"); | ||
assert_eq!(ar, "ar"); | ||
|
||
let ar = get_ar_for_target("i686-wrs-vxworks"); | ||
assert_eq!(ar, "wr-ar"); | ||
|
||
let ar = get_ar_for_target("i586-pc-nto-qnx700"); | ||
assert_eq!(ar, "ntox86-ar"); | ||
|
||
let ar = get_ar_for_target("aarch64-unknown-nto-qnx700"); | ||
assert_eq!(ar, "ntoaarch64-ar"); | ||
|
||
let ar = get_ar_for_target("x86_64-pc-nto-qnx710"); | ||
assert_eq!(ar, "ntox86_64-ar"); | ||
|
||
let ar = get_ar_for_target("wasm32-wasip1"); | ||
assert!( | ||
// `llvm-ar` is usually an absolute path for this target, so we check it with `ends_with`. | ||
ar.ends_with(&maybe_exe("llvm-ar")) | ||
// If `llvm-ar` doesn't exist, the logic falls back to `ar` for this target. | ||
|| ar == "ar" | ||
); | ||
|
||
let ar = get_ar_for_target("riscv64-linux-android"); | ||
// If `llvm-ar` is not available on the system, this will fall back to `$target-ar` (e.g., `riscv64-linux-android-ar` in this case) | ||
assert!(ar == "llvm-ar" || ar == "riscv64-linux-android-ar"); | ||
} | ||
|
||
fn get_ar_for_target(target: &'static str) -> String { | ||
let mut cfg = cc::Build::new(); | ||
cfg.host("x86_64-unknown-linux-gnu").target(target); | ||
let ar = cfg.get_archiver(); | ||
let ar = ar.get_program().to_str().unwrap().to_string(); | ||
println!("cc::Build::get_archiver -> target: '{target}': resolved archiver: '{ar}'"); | ||
ar | ||
} | ||
|
||
/// Appends `.exe` to the file name on Windows systems. | ||
fn maybe_exe(file: &'static str) -> String { | ||
if cfg!(windows) { | ||
format!("{file}.exe") | ||
} else { | ||
file.to_owned() | ||
} | ||
} |
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.
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.
If you really want this to continue working in the future, it'd be nice if you could add either a test, or ideally a CI step that sets up the required environment for NTO and vxWorks and runs the normal test suite.
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.
Just added a coverage on certain targets along with NTO and wxWorks.