Skip to content

Commit

Permalink
Fix bindgen dependency cfg (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Apr 2, 2024
1 parent 2502a73 commit 972db16
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 51 deletions.
66 changes: 63 additions & 3 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,68 @@ 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, windows-latest ]
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: dtolnay/rust-toolchain@stable
- name: Run cargo tree
if: ${{ matrix.os != 'windows-latest' }}
run: |
if cargo tree -e build -p aws-lc-sys | grep -q bindgen; then
exit 1 # bindgen should not be listed
else
exit 0
fi
- name: Run cargo tree
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
$output = cargo tree -e build -p aws-lc-sys | Select-String -Pattern "bindgen"
if ($null -eq $output) {
exit 1 # bindgen should be listed
} else {
exit 0
}
bindgen-fips-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, windows-latest ]
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: dtolnay/rust-toolchain@stable
- name: Run cargo tree
if: ${{ matrix.os != 'windows-latest' }}
run: |
if cargo tree -e build -p aws-lc-fips-sys | grep -q bindgen; then
exit 1 # bindgen should not be listed
else
exit 0
fi
- name: Run cargo tree
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
$output = cargo tree -e build -p aws-lc-fips-sys | Select-String -Pattern "bindgen"
if ($null -eq $output) {
exit 1 # bindgen should be listed
} else {
exit 0
}
mirai-analysis:
if: github.repository == 'aws/aws-lc-rs'
runs-on: ubuntu-latest
Expand All @@ -155,7 +217,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}
Expand Down Expand Up @@ -186,8 +248,6 @@ jobs:
working-directory: ./aws-lc-rs
run: cargo --locked check



copyright:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-fips-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
42 changes: 20 additions & 22 deletions aws-lc-fips-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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<String>, bindings_path: &PathBuf) {
Expand Down Expand Up @@ -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 = "")
))
))]
{
Expand Down
5 changes: 3 additions & 2 deletions aws-lc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
51 changes: 29 additions & 22 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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<String>, bindings_path: &PathBuf) {
Expand Down Expand Up @@ -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")
))
))]
{
Expand Down

0 comments on commit 972db16

Please sign in to comment.