-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
Read host target triple from rustc -vV
#487
Conversation
ea7ecde
to
d8c3016
Compare
I think the best solution for both If there are other reasons I've missing and we still need to go for reading the target triple, I'd do what cargo does and read use std::process::Command;
use anyhow::{format_err, Context, Result};
use std::str;
fn get_target() -> Result<String> {
let output = Command::new("rustc")
.arg("-vV")
.output()
.context("Failed to run rustc to get the host target")?;
let output = str::from_utf8(&output.stdout).context("`rustc -vV` didn't return utf8 output")?;
let field = "host: ";
let host = output
.lines()
.find(|l| l.starts_with(field))
.map(|l| &l[field.len()..])
.ok_or_else(|| {
format_err!(
"`rustc -vV` didn't have a line for `{}`, got:\n{}",
field.trim(),
output
)
})?
.to_string();
Ok(host)
}
fn main() -> Result<()> {
let host = get_target()?;
println!("target triple: {}", host);
Ok(())
} |
There is also #423 affected by target_env |
Co-authored-by: konstin <konstin@mailbox.org>
rustc --print cfg
rustc -vV
Anyway I think it's good to get rid of |
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --target x86_64-unknown-linux-musl |
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.
Since we're only shipping musl anyway, wouldn't it make more sense to only run the tests for musl?
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 in case someone needs to compile maturin from source instead of using prebuilt wheels, for example on some BSD systems?
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.
Looks good, thank you!
Fixes #478, closes #486
cc @al626