Skip to content

Commit

Permalink
Add CI test for FreeBSD (#477)
Browse files Browse the repository at this point in the history
* Add CI test for FreeBSD

* Cleanup bindgen setups
  • Loading branch information
justsmth authored Aug 6, 2024
1 parent a12cde3 commit 8510fd1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,24 @@ jobs:
run: cargo ${{ env.ACTION_CARGO }} -p aws-lc-rs --all-targets --target ${{ matrix.target }} --features bindgen
- name: Release Build for ${{ matrix.target }}
run: cargo ${{ env.ACTION_CARGO }} --release -p aws-lc-rs --all-targets --target ${{ matrix.target }}
freebsd:
if: github.repository_owner == 'aws'
name: aws-lc-rs freebsd test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Prepare VM
uses: vmactions/freebsd-vm@v1
with:
release: 13.2
usesh: true
copyback: false
prepare: |
pkg install -y git gmake bash sudo cmake-core llvm-devel-lite curl rust-bindgen-cli
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
export AWS_LC_SYS_EXTERNAL_BINDGEN=1
cargo test -p aws-lc-rs
1 change: 1 addition & 0 deletions aws-lc-sys/builder/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn prepare_bindings_builder(manifest_dir: &Path, options: &BindingOptions) -> bi
.allowlist_file(r".*(/|\\)openssl((/|\\)[^/\\]+)+\.h")
.allowlist_file(r".*(/|\\)rust_wrapper\.h")
.rustified_enum(r"point_conversion_form_t")
.rust_target(bindgen::RustTarget::Stable_1_59)
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
.generate_comments(true)
.fit_macro_constants(false)
Expand Down
40 changes: 30 additions & 10 deletions aws-lc-sys/builder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{fmt, fmt::Debug};

use cc_builder::CcBuilder;
use cmake_builder::CmakeBuilder;
Expand Down Expand Up @@ -353,6 +354,12 @@ fn is_bindgen_required() -> bool {
|| !has_pregenerated()
}

fn internal_bindgen_supported() -> bool {
// TODO: internal bindgen creates invalid bindings on FreeBSD
// See: https://github.com/aws/aws-lc-rs/issues/476
target_os() != "freebsd"
}

fn is_no_prefix() -> bool {
unsafe { AWS_LC_SYS_NO_PREFIX }
}
Expand Down Expand Up @@ -436,7 +443,7 @@ fn main() {
all(target_arch = "x86", target_os = "linux", target_env = "gnu")
))
))]
if !is_external_bindgen() {
if internal_bindgen_supported() && !is_external_bindgen() {
emit_warning(&format!(
"Generating bindings - internal bindgen. Platform: {}",
target()
Expand Down Expand Up @@ -532,6 +539,16 @@ pub(crate) struct BindingOptions {
pub disable_prelude: bool,
}

impl Debug for BindingOptions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BindingOptions")
.field("build_prefix", &self.build_prefix)
.field("include_ssl", &self.include_ssl)
.field("disable_prelude", &self.disable_prelude)
.finish()
}
}

fn invoke_external_bindgen(
manifest_dir: &Path,
prefix: &Option<String>,
Expand Down Expand Up @@ -579,25 +596,28 @@ fn invoke_external_bindgen(
// to conform with the most recent release. We will guide consumers to likewise use the
// latest version of bindgen-cli.
bindgen_params.extend(vec![
"--rust-target",
r"1.59",
"--with-derive-default",
"--with-derive-eq",
"--allowlist-file",
r".*(/|\\)openssl(/|\\)[^/\\]+\.h",
r".*(/|\\)openssl((/|\\)[^/\\]+)+\.h",
"--allowlist-file",
r".*(/|\\)rust_wrapper\.h",
"--rustified-enum",
r"point_conversion_form_t",
"--default-macro-constant-type",
r"signed",
"--formatter",
r"rustfmt",
"--output",
gen_bindings_path.to_str().unwrap(),
"--with-derive-default",
"--with-derive-partialeq",
"--with-derive-eq",
"--raw-line",
COPYRIGHT,
"--generate",
"functions,types,vars,methods,constructors,destructors",
header.as_str(),
"--rust-target",
r"1.59",
"--output",
gen_bindings_path.to_str().unwrap(),
"--formatter",
r"rustfmt",
"--",
]);
clang_args
Expand Down

0 comments on commit 8510fd1

Please sign in to comment.