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 18, 2024
1 parent e2d6bff commit d7ab9f4
Show file tree
Hide file tree
Showing 17 changed files with 321 additions and 129,457 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/fips-bindings-generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
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, 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 -f -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
- 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: 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, 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 Expand Up @@ -38,7 +38,7 @@ jobs:
cargo test -p aws-lc-sys --features bindgen,ssl
- name: Collect symbols
run: |
./scripts/build/collect_symbols.sh
./scripts/build/collect_symbols.sh -c aws-lc-sys
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols from ${{ matrix.os }}"
collect-cross-symbols-and-commit:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
cross test -p aws-lc-sys --features bindgen,ssl --target ${{ matrix.target }}
- name: Collect symbols
run: |
./scripts/build/collect_symbols.sh -t ${{ matrix.target }}
./scripts/build/collect_symbols.sh -c aws-lc-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:
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", "GOPROXY"
]
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 = "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 = "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
32 changes: 18 additions & 14 deletions aws-lc-fips-sys/builder/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ fn add_header_include_path(args: &mut Vec<String>, path: String) {
args.push(path);
}

fn prepare_clang_args(manifest_dir: &Path) -> Vec<String> {
fn prepare_clang_args(manifest_dir: &Path, options: &BindingOptions) -> Vec<String> {
let mut clang_args: Vec<String> = Vec::new();

add_header_include_path(
&mut clang_args,
get_rust_include_path(manifest_dir).display().to_string(),
);

add_header_include_path(
&mut clang_args,
get_generated_include_path(manifest_dir)
.display()
.to_string(),
);
if options.build_prefix.is_some() {
add_header_include_path(
&mut clang_args,
get_generated_include_path(manifest_dir)
.display()
.to_string(),
);
}

add_header_include_path(
&mut clang_args,
Expand Down Expand Up @@ -96,14 +98,14 @@ const PRELUDE: &str = r"
";

#[derive(Default)]
pub(crate) struct BindingOptions<'a> {
pub build_prefix: &'a str,
pub(crate) struct BindingOptions {
pub build_prefix: Option<String>,
pub include_ssl: bool,
pub disable_prelude: bool,
}

fn prepare_bindings_builder(manifest_dir: &Path, options: &BindingOptions<'_>) -> bindgen::Builder {
let clang_args = prepare_clang_args(manifest_dir);
fn prepare_bindings_builder(manifest_dir: &Path, options: &BindingOptions) -> bindgen::Builder {
let clang_args = prepare_clang_args(manifest_dir, options);

let mut builder = bindgen::Builder::default()
.derive_copy(true)
Expand Down Expand Up @@ -136,15 +138,17 @@ fn prepare_bindings_builder(manifest_dir: &Path, options: &BindingOptions<'_>) -
if options.include_ssl {
builder = builder.clang_arg("-DAWS_LC_RUST_INCLUDE_SSL");
}

builder = builder.parse_callbacks(Box::new(StripPrefixCallback::new(options.build_prefix)));
if let Some(prefix) = &options.build_prefix {
let callbacks = StripPrefixCallback::new(prefix.as_str());
builder = builder.parse_callbacks(Box::new(callbacks));
}

builder
}

pub(crate) fn generate_bindings(
manifest_dir: &Path,
options: &BindingOptions<'_>,
options: &BindingOptions,
) -> bindgen::Bindings {
prepare_bindings_builder(manifest_dir, options)
.generate()
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
Loading

0 comments on commit d7ab9f4

Please sign in to comment.