Skip to content

Commit

Permalink
Bindings generation for aws-lc-fips-sys v0.12.6
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Mar 15, 2024
1 parent be4bc0c commit e86075d
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 129,407 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/fips-bindings-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Auto-generate aws-lc-fips-sys Bindings

on:
push:
branches:
- 'generate/aws-lc-fips-sys-*'

env:
GIT_AUTHOR_NAME: "aws-lc-fips-sys-bindings-generator"
GIT_AUTHOR_EMAIL: "[email protected]"
GIT_COMMITTER_NAME: "aws-lc-fips-sys-bindings-generator"
GIT_COMMITTER_EMAIL: "[email protected]"

jobs:
collect-symbols-and-commit:
if: github.repository == 'aws/aws-lc-rs'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macos-12, macos-13-xlarge ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Install current Bash on macOS
if: runner.os == 'macOS'
run: brew install bash coreutils
- name: No-prefix build for ${{ matrix.os }}
env:
AWS_LC_FIPS_SYS_INTERNAL_NO_PREFIX: "1"
run: |
cargo test -p aws-lc-fips-sys --features bindgen,ssl
- name: Collect symbols
run: |
./scripts/build/collect_symbols.sh -c aws-lc-fips-sys
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols from ${{ matrix.os }}"
collect-cross-symbols-and-commit:
if: github.repository == 'aws/aws-lc-rs'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [ aarch64-unknown-linux-gnu, i686-unknown-linux-gnu, aarch64-unknown-linux-musl, x86_64-unknown-linux-musl ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Install cross
run: cargo install cross --locked --git https://github.com/cross-rs/cross
- name: No-prefix build for ${{ matrix.target }}
env:
AWS_LC_FIPS_SYS_INTERNAL_NO_PREFIX: "1"
run: |
cross test -p aws-lc-fips-sys --features bindgen,ssl --target ${{ matrix.target }}
- name: Collect symbols
run: |
./scripts/build/collect_symbols.sh -c aws-lc-fips-sys -t ${{ matrix.target }}
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols for ${{ matrix.target }}"
generate-headers-and-commit:
needs: [ collect-cross-symbols-and-commit, collect-symbols-and-commit ]
if: github.repository == 'aws/aws-lc-rs'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Generate Prefix Headers
run: ./scripts/generate/_generate_prefix_headers.sh -c aws-lc-fips-sys
- name: Update sys-crate metadata
run: ./scripts/ci/update_sys_crate_metadata.sh aws-lc-fips-sys
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated headers"
generate-bindings-and-commit:
needs: generate-headers-and-commit
if: github.repository == 'aws/aws-lc-rs'
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-12, macos-13-xlarge ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@stable
- name: Install current Bash on macOS
if: runner.os == 'macOS'
run: brew install bash coreutils
- name: Generate bindings for ${{ matrix.os }}
env:
AWS_LC_RUST_INTERNAL_BINDGEN: "1"
run: |
cargo test -p aws-lc-fips-sys --features bindgen,ssl
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings from ${{ matrix.os }}"
generate-cross-bindings-and-commit:
needs: generate-headers-and-commit
if: github.repository == 'aws/aws-lc-rs'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [ aarch64-unknown-linux-gnu, i686-unknown-linux-gnu, aarch64-unknown-linux-musl, x86_64-unknown-linux-musl ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@stable
- name: Install cross
run: cargo install cross --locked --git https://github.com/cross-rs/cross
- name: Generate bindings for ${{ matrix.target }}
env:
AWS_LC_RUST_INTERNAL_BINDGEN: "1"
run: |
cross test -p aws-lc-fips-sys --features bindgen,ssl --target ${{ matrix.target }}
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings for ${{ matrix.target }}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Auto-generate Bindings
name: Auto-generate aws-lc-sys Bindings

on:
push:
Expand Down
5 changes: 4 additions & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[build]
dockerfile = "./docker/linux-cross/Dockerfile"

[build.env]
passthrough = [
"AWS_LC_SYS_INTERNAL_NO_PREFIX", "AWS_LC_RUST_INTERNAL_BINDGEN"
"AWS_LC_SYS_INTERNAL_NO_PREFIX", "AWS_LC_RUST_INTERNAL_BINDGEN", "AWS_LC_FIPS_SYS_INTERNAL_NO_PREFIX"
]
8 changes: 4 additions & 4 deletions aws-lc-fips-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "aws-lc-fips-sys"
description = "AWS-LC is a general-purpose cryptographic library maintained by the AWS Cryptography team for AWS and their customers. This is the FIPS validated version of AWS-LC."
version = "0.12.5"
version = "0.12.6"
links = "aws_lc_fips_0_12_5"
authors = ["AWS-LC"]
edition = "2021"
Expand Down Expand Up @@ -56,18 +56,18 @@ build = "builder/main.rs"

[features]
asan = []
bindgen = ["dep:bindgen"] # Generate the bindings on the targetted platform as a fallback mechanism.
ssl = []
bindgen = ["dep:bindgen"] # Generate the bindings on the targetted platform as a fallback mechanism.

[build-dependencies]
cmake = "0.1.48"
dunce = "1.0"
fs_extra = "1.3"

[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]
[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]
bindgen = { version = "0.69.2", optional = true }

[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]
[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]
bindgen = { version = "0.69.2" }

[dependencies]
Expand Down
6 changes: 5 additions & 1 deletion aws-lc-fips-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ fn test_perl_command() -> bool {
}

fn test_go_command() -> bool {
test_command("go".as_ref(), &["version".as_ref()]).status
let result = test_command("go".as_ref(), &["version".as_ref()]);
if !result.status && result.executed {
eprintln!("Go stdout:\n--------\n{}\n--------", result.output);
}
result.status
}

fn test_ninja_command() -> bool {
Expand Down
59 changes: 51 additions & 8 deletions aws-lc-fips-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ use cmake_builder::CmakeBuilder;
#[cfg(any(
feature = "bindgen",
not(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64")
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"
))
))]
mod bindgen;
Expand Down Expand Up @@ -137,6 +142,7 @@ fn target_platform_prefix(name: &str) -> String {
pub(crate) struct TestCommandResult {
output: Box<str>,
status: bool,
executed: bool,
}

fn test_command(executable: &OsStr, args: &[&OsStr]) -> TestCommandResult {
Expand All @@ -147,19 +153,26 @@ fn test_command(executable: &OsStr, args: &[&OsStr]) -> TestCommandResult {
return TestCommandResult {
output,
status: result.status.success(),
executed: true,
};
}
TestCommandResult {
output: String::new().into_boxed_str(),
status: false,
executed: false,
}
}

#[cfg(any(
feature = "bindgen",
not(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64")
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"
))
))]
fn generate_bindings(manifest_dir: &Path, prefix: Option<String>, bindings_path: &PathBuf) {
Expand Down Expand Up @@ -255,6 +268,7 @@ trait Builder {
fn build(&self) -> Result<(), String>;
}

#[allow(clippy::too_many_lines)]
fn main() {
let is_internal_no_prefix =
env_var_to_bool("AWS_LC_FIPS_SYS_INTERNAL_NO_PREFIX").unwrap_or(false);
Expand All @@ -264,6 +278,11 @@ fn main() {

let pregenerated = !is_bindgen_required || is_internal_generate;

cfg_bindgen_platform!(
i686_unknown_linux_gnu,
"i686-unknown-linux-gnu",
pregenerated
);
cfg_bindgen_platform!(
x86_64_unknown_linux_gnu,
"x86_64-unknown-linux-gnu",
Expand All @@ -274,8 +293,27 @@ fn main() {
"aarch64-unknown-linux-gnu",
pregenerated
);

if !(x86_64_unknown_linux_gnu || aarch64_unknown_linux_gnu) {
cfg_bindgen_platform!(
x86_64_unknown_linux_musl,
"x86_64-unknown-linux-musl",
pregenerated
);
cfg_bindgen_platform!(
aarch64_unknown_linux_musl,
"aarch64-unknown-linux-musl",
pregenerated
);
cfg_bindgen_platform!(x86_64_apple_darwin, "x86_64-apple-darwin", pregenerated);
cfg_bindgen_platform!(aarch64_apple_darwin, "aarch64-apple-darwin", pregenerated);

if !(i686_unknown_linux_gnu
|| x86_64_unknown_linux_gnu
|| aarch64_unknown_linux_gnu
|| x86_64_unknown_linux_musl
|| aarch64_unknown_linux_musl
|| x86_64_apple_darwin
|| aarch64_apple_darwin)
{
is_bindgen_required = true;
}

Expand Down Expand Up @@ -310,8 +348,13 @@ fn main() {
#[cfg(any(
feature = "bindgen",
not(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64")
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"
))
))]
{
Expand Down
14 changes: 12 additions & 2 deletions aws-lc-fips-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ macro_rules! platform_binding {
};
}

platform_binding!(linux_x86_64);
platform_binding!(i686_unknown_linux_gnu);

platform_binding!(linux_aarch64);
platform_binding!(x86_64_unknown_linux_gnu);

platform_binding!(aarch64_unknown_linux_gnu);

platform_binding!(x86_64_unknown_linux_musl);

platform_binding!(aarch64_unknown_linux_musl);

platform_binding!(x86_64_apple_darwin);

platform_binding!(aarch64_apple_darwin);

#[cfg(use_bindgen_generated)]
#[allow(
Expand Down
Loading

0 comments on commit e86075d

Please sign in to comment.