Skip to content

Commit

Permalink
Add a default_lib_name_for_target function
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed May 28, 2022
1 parent 4986d8e commit 5913ced
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,18 +443,7 @@ print("mingw", get_platform().startswith("mingw"))
// Fixup lib_name if it's not set
let lib_name = lib_name.or_else(|| {
if let Ok(Ok(target)) = env::var("TARGET").map(|target| target.parse::<Triple>()) {
if target.operating_system == OperatingSystem::Windows {
Some(default_lib_name_windows(
version,
implementation,
abi3,
false,
))
} else if is_linking_libpython_for_target(&target) {
Some(default_lib_name_unix(version, implementation, None))
} else {
None
}
default_lib_name_for_target(version, implementation, abi3, &target)
} else {
None
}
Expand Down Expand Up @@ -1423,18 +1412,8 @@ fn default_cross_compile(cross_compile_config: &CrossCompileConfig) -> Result<In
.implementation
.unwrap_or(PythonImplementation::CPython);

let lib_name = if cross_compile_config.target.operating_system == OperatingSystem::Windows {
Some(default_lib_name_windows(
version,
implementation,
abi3,
false,
))
} else if is_linking_libpython_for_target(&cross_compile_config.target) {
Some(default_lib_name_unix(version, implementation, None))
} else {
None
};
let lib_name =
default_lib_name_for_target(version, implementation, abi3, &cross_compile_config.target);

let mut lib_dir = cross_compile_config.lib_dir_string();

Expand Down Expand Up @@ -1543,6 +1522,26 @@ fn load_cross_compile_config(
// This contains only the limited ABI symbols.
const WINDOWS_ABI3_LIB_NAME: &str = "python3";

fn default_lib_name_for_target(
version: PythonVersion,
implementation: PythonImplementation,
abi3: bool,
target: &Triple,
) -> Option<String> {
if target.operating_system == OperatingSystem::Windows {
Some(default_lib_name_windows(
version,
implementation,
abi3,
false,
))
} else if is_linking_libpython_for_target(&target) {
Some(default_lib_name_unix(version, implementation, None))
} else {
None
}
}

fn default_lib_name_windows(
version: PythonVersion,
implementation: PythonImplementation,
Expand Down

0 comments on commit 5913ced

Please sign in to comment.