Merge pull request #1529 from ravenexp/fix-cargo-target-parsing
Clean up CARGO_CFG_TARGET_FAMILY variable parsing
This commit is contained in:
commit
2939bf1ed6
21
build.rs
21
build.rs
|
@ -144,8 +144,6 @@ impl CrossCompileConfig {
|
||||||
fn cross_compiling() -> Result<Option<CrossCompileConfig>> {
|
fn cross_compiling() -> Result<Option<CrossCompileConfig>> {
|
||||||
if env::var_os("PYO3_CROSS").is_none()
|
if env::var_os("PYO3_CROSS").is_none()
|
||||||
&& env::var_os("PYO3_CROSS_LIB_DIR").is_none()
|
&& env::var_os("PYO3_CROSS_LIB_DIR").is_none()
|
||||||
&& env::var_os("PYO3_CROSS_INCLUDE_DIR").is_none()
|
|
||||||
&& env::var_os("PYO3_CROSS_VERSION").is_none()
|
|
||||||
&& env::var_os("PYO3_CROSS_PYTHON_VERSION").is_none()
|
&& env::var_os("PYO3_CROSS_PYTHON_VERSION").is_none()
|
||||||
{
|
{
|
||||||
let target = env::var("TARGET")?;
|
let target = env::var("TARGET")?;
|
||||||
|
@ -489,7 +487,7 @@ fn windows_hardcoded_cross_compile(
|
||||||
) {
|
) {
|
||||||
(Some(major), Some(minor), None) => (major, minor),
|
(Some(major), Some(minor), None) => (major, minor),
|
||||||
_ => bail!(
|
_ => bail!(
|
||||||
"Expected major.minor version (e.g. 3.9) for PYO3_CROSS_VERSION, got `{}`",
|
"Expected major.minor version (e.g. 3.9) for PYO3_CROSS_PYTHON_VERSION, got `{}`",
|
||||||
version
|
version
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -518,13 +516,18 @@ fn windows_hardcoded_cross_compile(
|
||||||
fn load_cross_compile_info(
|
fn load_cross_compile_info(
|
||||||
cross_compile_config: CrossCompileConfig,
|
cross_compile_config: CrossCompileConfig,
|
||||||
) -> Result<(InterpreterConfig, BuildFlags)> {
|
) -> Result<(InterpreterConfig, BuildFlags)> {
|
||||||
let target_family = env::var("CARGO_CFG_TARGET_FAMILY")?;
|
match env::var_os("CARGO_CFG_TARGET_FAMILY") {
|
||||||
// Because compiling for windows on linux still includes the unix target family
|
|
||||||
if target_family == "unix" {
|
|
||||||
// Configure for unix platforms using the sysconfigdata file
|
// Configure for unix platforms using the sysconfigdata file
|
||||||
load_cross_compile_from_sysconfigdata(cross_compile_config)
|
Some(os) if os == "unix" => load_cross_compile_from_sysconfigdata(cross_compile_config),
|
||||||
} else {
|
// Use hardcoded interpreter config when targeting Windows
|
||||||
windows_hardcoded_cross_compile(cross_compile_config)
|
Some(os) if os == "windows" => windows_hardcoded_cross_compile(cross_compile_config),
|
||||||
|
// Waiting for users to tell us what they expect on their target platform
|
||||||
|
Some(os) => bail!(
|
||||||
|
"Unsupported target OS family for cross-compilation: {:?}",
|
||||||
|
os
|
||||||
|
),
|
||||||
|
// Unknown os family - try to do something useful
|
||||||
|
None => load_cross_compile_from_sysconfigdata(cross_compile_config),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue