Skip to content

Commit

Permalink
Consider target env for pregenerated bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Dec 11, 2023
1 parent 9eb4456 commit 673c272
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions aws-lc-fips-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ cmake = "0.1.48"
dunce = "1.0"
fs_extra = "1.3"

[target.'cfg(any(all(target_os = "linux", target_arch = "x86_64"), all(target_os = "linux", target_arch = "aarch64")))'.build-dependencies]
[target.'cfg(any(all(target_os = "linux", target_arch = "x86_64", target_env="gnu"), all(target_os = "linux", target_arch = "aarch64", target_env="gnu")))'.build-dependencies]
bindgen = { version = "0.69.1", optional = true }

[target.'cfg(not(any(all(target_os = "linux", target_arch = "x86_64"), all(target_os = "linux", target_arch = "aarch64"))))'.build-dependencies]
[target.'cfg(not(any(all(target_os = "linux", target_arch = "x86_64", target_env="gnu"), all(target_os = "linux", target_arch = "aarch64", target_env="gnu"))))'.build-dependencies]
bindgen = { version = "0.69.1" }

[dependencies]
Expand Down
12 changes: 8 additions & 4 deletions aws-lc-fips-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ fn target_arch() -> String {
env::var("CARGO_CFG_TARGET_ARCH").unwrap()
}

fn target_env() -> String {
env::var("CARGO_CFG_TARGET_ENV").unwrap()
}

#[allow(unused)]
fn target_vendor() -> String {
env::var("CARGO_CFG_TARGET_VENDOR").unwrap()
Expand All @@ -272,9 +276,9 @@ fn target() -> String {
}

macro_rules! cfg_bindgen_platform {
($binding:ident, $os:literal, $arch:literal, $additional:expr) => {
($binding:ident, $os:literal, $arch:literal, $env:literal, $additional:expr) => {
let $binding = {
(target_os() == $os && target_arch() == $arch && $additional)
(target_os() == $os && target_arch() == $arch && target_env() == $env && $additional)
.then(|| {
emit_rustc_cfg(concat!($os, "_", $arch));
true
Expand All @@ -297,8 +301,8 @@ fn main() {

let pregenerated = !is_bindgen_required || is_internal_generate;

cfg_bindgen_platform!(linux_x86_64, "linux", "x86_64", pregenerated);
cfg_bindgen_platform!(linux_aarch64, "linux", "aarch64", pregenerated);
cfg_bindgen_platform!(linux_x86_64, "linux", "x86_64", "gnu", pregenerated);
cfg_bindgen_platform!(linux_aarch64, "linux", "aarch64", "gnu", pregenerated);

if !(linux_x86_64 || linux_aarch64) {
emit_rustc_cfg("use_bindgen_generated");
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ cmake = "0.1.48"
dunce = "1.0"
fs_extra = "1.3"

[target.'cfg(any(all(target_os = "macos", target_arch = "x86_64"), all(target_os = "linux", target_arch = "x86"), all(target_os = "linux", target_arch = "x86_64"), all(target_os = "linux", target_arch = "aarch64")))'.build-dependencies]
[target.'cfg(any(all(target_os = "macos", target_arch = "x86_64"), all(target_os = "linux", target_arch = "x86", target_env="gnu"), all(target_os = "linux", target_arch = "x86_64", target_env="gnu"), all(target_os = "linux", target_arch = "aarch64", target_env="gnu")))'.build-dependencies]
bindgen = { version = "0.69.1", optional = true }

[target.'cfg(not(any(all(target_os = "macos", target_arch = "x86_64"), all(target_os = "linux", target_arch = "x86"), all(target_os = "linux", target_arch = "x86_64"), all(target_os = "linux", target_arch = "aarch64"))))'.build-dependencies]
[target.'cfg(not(any(all(target_os = "macos", target_arch = "x86_64"), all(target_os = "linux", target_arch = "x86", target_env="gnu"), all(target_os = "linux", target_arch = "x86_64", target_env="gnu"), all(target_os = "linux", target_arch = "aarch64", target_env="gnu"))))'.build-dependencies]
bindgen = { version = "0.68.1" }


Expand Down
16 changes: 10 additions & 6 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ fn target_arch() -> String {
env::var("CARGO_CFG_TARGET_ARCH").unwrap()
}

fn target_env() -> String {
env::var("CARGO_CFG_TARGET_ENV").unwrap()
}

fn target_vendor() -> String {
env::var("CARGO_CFG_TARGET_VENDOR").unwrap()
}
Expand All @@ -273,9 +277,9 @@ fn target() -> String {
}

macro_rules! cfg_bindgen_platform {
($binding:ident, $os:literal, $arch:literal, $additional:expr) => {
($binding:ident, $os:literal, $arch:literal, $env:literal, $additional:expr) => {
let $binding = {
(target_os() == $os && target_arch() == $arch && $additional)
(target_os() == $os && target_arch() == $arch && target_env() == $env && $additional)
.then(|| {
emit_rustc_cfg(concat!($os, "_", $arch));
true
Expand All @@ -297,10 +301,10 @@ fn main() {

let pregenerated = !is_bindgen_required || is_internal_generate;

cfg_bindgen_platform!(linux_x86, "linux", "x86", pregenerated);
cfg_bindgen_platform!(linux_x86_64, "linux", "x86_64", pregenerated);
cfg_bindgen_platform!(linux_aarch64, "linux", "aarch64", pregenerated);
cfg_bindgen_platform!(macos_x86_64, "macos", "x86_64", pregenerated);
cfg_bindgen_platform!(linux_x86, "linux", "x86", "gnu", pregenerated);
cfg_bindgen_platform!(linux_x86_64, "linux", "x86_64", "gnu", pregenerated);
cfg_bindgen_platform!(linux_aarch64, "linux", "aarch64", "gnu", pregenerated);
cfg_bindgen_platform!(macos_x86_64, "macos", "x86_64", "", pregenerated);

if !(linux_x86 || linux_x86_64 || linux_aarch64 || macos_x86_64) {
emit_rustc_cfg("use_bindgen_generated");
Expand Down

0 comments on commit 673c272

Please sign in to comment.