Skip to content
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

Remove cfg! directives in build.rs causing cross-compilation to fail #555

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions rustler_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,21 +895,31 @@ fn get_nif_version_from_features() -> (u32, u32) {

fn main() {
let nif_version = get_nif_version_from_features();
let target_family_or_current =
env::var("CARGO_CFG_TARGET_FAMILY").unwrap_or_else(|_| env::consts::FAMILY.to_string());

let target_family = if cfg!(target_family = "windows") {
let target_family = if target_family_or_current == "windows" {
OsFamily::Win
} else if cfg!(target_family = "unix") {
OsFamily::Unix
} else {
panic!("Unsupported Operational System Family")
};

let target_pointer_width = match env::var("CARGO_CFG_TARGET_POINTER_WIDTH") {
Ok(target_pointer_width) => target_pointer_width,
Err(err) => panic!(
"An error occurred while determining the pointer width to compile `rustler_sys` for:\n\n{:?}\n\nPlease report a bug.",
err
)
};

let ulong_size = match target_family {
OsFamily::Win => 4,
OsFamily::Unix => {
if cfg!(target_pointer_width = "32") {
if target_pointer_width == "32" {
4
} else if cfg!(target_pointer_width = "64") {
} else if target_pointer_width == "64" {
8
} else {
panic!("Unsupported target pointer width")
Expand Down