From 868f0571727eef966c283f72bf7683ba60d0ccdc Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 1 Apr 2024 18:56:27 -0400 Subject: [PATCH] Fix bindgen dependency cfg --- .github/workflows/analysis.yml | 20 +++++++++++-- aws-lc-fips-sys/Cargo.toml | 4 +-- aws-lc-fips-sys/builder/main.rs | 42 +++++++++++++-------------- aws-lc-sys/Cargo.toml | 5 ++-- aws-lc-sys/builder/main.rs | 51 +++++++++++++++++++-------------- 5 files changed, 71 insertions(+), 51 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 295501f0476..90fe7cb3fd8 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -132,6 +132,22 @@ jobs: env: RUSTC_WRAPPER: "" + bindgen-dependency: + if: github.repository == 'aws/aws-lc-rs' + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-12, macos-13-xlarge ] + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - uses: dtolnay/rust-toolchain@stable + - name: Run cargo tree + run: | + if cargo tree -e build -p aws-lc-sys | grep -q bindgen; then exit 1; else exit 0; fi + mirai-analysis: if: github.repository == 'aws/aws-lc-rs' runs-on: ubuntu-latest @@ -155,7 +171,7 @@ jobs: MIRAI_TMP_SRC=$(mktemp -d) git clone --depth 1 --branch ${{ env.MIRAI_TAG }} https://github.com/facebookexperimental/MIRAI.git ${MIRAI_TMP_SRC} pushd ${MIRAI_TMP_SRC} - cargo install --force --path ./checker --no-default-features + cargo install --locked --force --path ./checker --no-default-features popd rm -rf ${MIRAI_TMP_SRC} @@ -186,8 +202,6 @@ jobs: working-directory: ./aws-lc-rs run: cargo --locked check - - copyright: runs-on: ubuntu-latest steps: diff --git a/aws-lc-fips-sys/Cargo.toml b/aws-lc-fips-sys/Cargo.toml index 0ee7e2dbb58..75090769f7e 100644 --- a/aws-lc-fips-sys/Cargo.toml +++ b/aws-lc-fips-sys/Cargo.toml @@ -64,10 +64,10 @@ cmake = "0.1.48" dunce = "1.0" fs_extra = "1.3" -[target.'cfg(any(target = "aarch64-apple-darwin", target = "x86_64-apple-darwin", target = "aarch64-unknown-linux-gnu", target = "x86_64-unknown-linux-gnu", target = "aarch64-unknown-linux-musl", target = "x86_64-unknown-linux-musl"))'.build-dependencies] +[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), any(target_os = "linux", target_os = "macos"), any(target_env = "gnu", target_env = "musl", target_env = "")))'.build-dependencies] bindgen = { version = "0.69.2", optional = true } -[target.'cfg(not(any(target = "aarch64-apple-darwin", target = "x86_64-apple-darwin", target = "aarch64-unknown-linux-gnu", target = "x86_64-unknown-linux-gnu", target = "aarch64-unknown-linux-musl", target = "x86_64-unknown-linux-musl")))'.build-dependencies] +[target.'cfg(not(all(any(target_arch = "x86_64", target_arch = "aarch64"), any(target_os = "linux", target_os = "macos"), any(target_env = "gnu", target_env = "musl", target_env = ""))))'.build-dependencies] bindgen = { version = "0.69.2" } [dependencies] diff --git a/aws-lc-fips-sys/builder/main.rs b/aws-lc-fips-sys/builder/main.rs index 8f5114c64a6..7296ab304ea 100644 --- a/aws-lc-fips-sys/builder/main.rs +++ b/aws-lc-fips-sys/builder/main.rs @@ -11,13 +11,10 @@ use cmake_builder::CmakeBuilder; #[cfg(any( feature = "bindgen", - not(any( - target = "aarch64-apple-darwin", - target = "x86_64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "x86_64-unknown-linux-gnu", - target = "aarch64-unknown-linux-musl", - target = "x86_64-unknown-linux-musl" + not(all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") )) ))] mod bindgen; @@ -133,7 +130,14 @@ fn prefix_string() -> String { format!("aws_lc_fips_{}", VERSION.to_string().replace('.', "_")) } -#[cfg(feature = "bindgen")] +#[cfg(any( + feature = "bindgen", + not(all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") + )) +))] fn target_platform_prefix(name: &str) -> String { format!("{}_{}", target().replace('-', "_"), name) } @@ -164,13 +168,10 @@ fn test_command(executable: &OsStr, args: &[&OsStr]) -> TestCommandResult { #[cfg(any( feature = "bindgen", - not(any( - target = "aarch64-apple-darwin", - target = "x86_64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "x86_64-unknown-linux-gnu", - target = "aarch64-unknown-linux-musl", - target = "x86_64-unknown-linux-musl" + not(all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") )) ))] fn generate_bindings(manifest_dir: &Path, prefix: Option, bindings_path: &PathBuf) { @@ -339,13 +340,10 @@ fn main() { } else if is_bindgen_required { #[cfg(any( feature = "bindgen", - not(any( - target = "aarch64-apple-darwin", - target = "x86_64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "x86_64-unknown-linux-gnu", - target = "aarch64-unknown-linux-musl", - target = "x86_64-unknown-linux-musl" + not(all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") )) ))] { diff --git a/aws-lc-sys/Cargo.toml b/aws-lc-sys/Cargo.toml index 45d5e58a1ea..7050e4add69 100644 --- a/aws-lc-sys/Cargo.toml +++ b/aws-lc-sys/Cargo.toml @@ -55,14 +55,15 @@ cmake = "0.1.48" dunce = "1.0" fs_extra = "1.3" -[target.'cfg(any(target = "aarch64-apple-darwin", target = "x86_64-apple-darwin", target = "aarch64-unknown-linux-gnu", target = "i686-unknown-linux-gnu", target = "x86_64-unknown-linux-gnu", target = "aarch64-unknown-linux-musl", target = "x86_64-unknown-linux-musl"))'.build-dependencies] +[target.'cfg(any(all(any(target_arch = "x86_64", target_arch = "aarch64"), any(target_os = "linux", target_os = "macos"), any(target_env = "gnu", target_env = "musl", target_env = "")), all(target_arch = "i686", target_os = "linux", target_env = "gnu")))'.build-dependencies] bindgen = { version = "0.69.2", optional = true } -[target.'cfg(not(any(target = "aarch64-apple-darwin", target = "x86_64-apple-darwin", target = "aarch64-unknown-linux-gnu", target = "i686-unknown-linux-gnu", target = "x86_64-unknown-linux-gnu", target = "aarch64-unknown-linux-musl", target = "x86_64-unknown-linux-musl")))'.build-dependencies] +[target.'cfg(not(any(all(any(target_arch = "x86_64", target_arch = "aarch64"), any(target_os = "linux", target_os = "macos"), any(target_env = "gnu", target_env = "musl", target_env = "")), all(target_arch = "i686", target_os = "linux", target_env = "gnu"))))'.build-dependencies] bindgen = { version = "0.69.2" } [dependencies] libc = "0.2.121" paste = "1.0.11" + [package.metadata.aws-lc-sys] commit-hash = "4e690737e0a386f8c5eb9a0a88becc7985b5d24e" diff --git a/aws-lc-sys/builder/main.rs b/aws-lc-sys/builder/main.rs index 60c56f57653..b69a07ba9ea 100644 --- a/aws-lc-sys/builder/main.rs +++ b/aws-lc-sys/builder/main.rs @@ -12,13 +12,12 @@ use cmake_builder::CmakeBuilder; #[cfg(any( feature = "bindgen", not(any( - target = "aarch64-apple-darwin", - target = "x86_64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "i686-unknown-linux-gnu", - target = "x86_64-unknown-linux-gnu", - target = "aarch64-unknown-linux-musl", - target = "x86_64-unknown-linux-musl" + all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") + ), + all(target_arch = "i686", target_os = "linux", target_env = "gnu") )) ))] mod bindgen; @@ -127,7 +126,17 @@ fn prefix_string() -> String { format!("aws_lc_{}", VERSION.to_string().replace('.', "_")) } -#[cfg(feature = "bindgen")] +#[cfg(any( + feature = "bindgen", + not(any( + all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") + ), + all(target_arch = "i686", target_os = "linux", target_env = "gnu") + )) +))] fn target_platform_prefix(name: &str) -> String { format!("{}_{}", target().replace('-', "_"), name) } @@ -157,13 +166,12 @@ fn test_command(executable: &OsStr, args: &[&OsStr]) -> TestCommandResult { #[cfg(any( feature = "bindgen", not(any( - target = "aarch64-apple-darwin", - target = "x86_64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "i686-unknown-linux-gnu", - target = "x86_64-unknown-linux-gnu", - target = "aarch64-unknown-linux-musl", - target = "x86_64-unknown-linux-musl" + all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") + ), + all(target_arch = "i686", target_os = "linux", target_env = "gnu") )) ))] fn generate_bindings(manifest_dir: &Path, prefix: Option, bindings_path: &PathBuf) { @@ -336,13 +344,12 @@ fn main() { #[cfg(any( feature = "bindgen", not(any( - target = "aarch64-apple-darwin", - target = "x86_64-apple-darwin", - target = "aarch64-unknown-linux-gnu", - target = "i686-unknown-linux-gnu", - target = "x86_64-unknown-linux-gnu", - target = "aarch64-unknown-linux-musl", - target = "x86_64-unknown-linux-musl" + all( + any(target_arch = "x86_64", target_arch = "aarch64"), + any(target_os = "linux", target_os = "macos"), + any(target_env = "gnu", target_env = "musl", target_env = "") + ), + all(target_arch = "i686", target_os = "linux", target_env = "gnu") )) ))] {