Skip to content

Commit

Permalink
Fix feature gates for fips-link-precompiled
Browse files Browse the repository at this point in the history
  • Loading branch information
inikulin committed Aug 3, 2023
1 parent abfe2f7 commit e1b5d47
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
14 changes: 10 additions & 4 deletions boring-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ fn ensure_patches_applied() -> io::Result<()> {

// NOTE: init git in the copied files, so we can apply patches
if !has_git {
println!("cargo:warning=initing git in boringssl sources to apply patches");

run_command(Command::new("git").args(["init"]).current_dir(&src_path))?;
}

Expand Down Expand Up @@ -581,6 +579,10 @@ fn link_in_precompiled_bcm_o(bssl_dir: &str) {

fn main() {
println!("cargo:rerun-if-env-changed=BORING_BSSL_PATH");
println!("cargo:rerun-if-env-changed=BORING_BSSL_INCLUDE_PATH");
println!("cargo:rerun-if-env-changed=BORING_BSSL_SOURCE_PATH");
println!("cargo:rerun-if-env-changed=BORING_SSL_PRECOMPILED_BCM_O");
println!("cargo:rerun-if-env-changed=BORINGSSL_BUILD_DIR");

#[cfg(all(feature = "fips", feature = "rpk"))]
compile_error!("`fips` and `rpk` features are mutually exclusive");
Expand Down Expand Up @@ -622,10 +624,14 @@ fn main() {
println!("cargo:rustc-link-lib=static=crypto");
println!("cargo:rustc-link-lib=static=ssl");

println!("cargo:rerun-if-env-changed=BORING_BSSL_INCLUDE_PATH");
let include_path = env::var("BORING_BSSL_INCLUDE_PATH").unwrap_or_else(|_| {
let src_path = get_boringssl_source_path();
if cfg!(feature = "fips") {

if Path::new(&src_path)
.join("include")
.join("x509v3.h")
.exists()
{
format!("{}/include", &src_path)
} else {
format!("{}/src/include", &src_path)
Expand Down
2 changes: 1 addition & 1 deletion boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rustdoc-args = ["--cfg", "docsrs"]
fips = ["boring-sys/fips"]

# Link with precompiled FIPS-validated `bcm.o` module.
fips-link-precompiled = ["fips"]
fips-link-precompiled = ["fips", "boring-sys/fips-link-precompiled"]

# Enables Raw public key API (https://datatracker.ietf.org/doc/html/rfc7250)
rpk = ["boring-sys/rpk"]
Expand Down
2 changes: 1 addition & 1 deletion hyper-boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ runtime = ["hyper/runtime"]
fips = ["tokio-boring/fips"]

# Link with precompiled FIPS-validated `bcm.o` module.
fips-link-precompiled = ["fips"]
fips-link-precompiled = ["fips", "tokio-boring/fips-link-precompiled"]

# Enables Raw public key API (https://datatracker.ietf.org/doc/html/rfc7250)
rpk = ["tokio-boring/rpk"]
Expand Down
4 changes: 2 additions & 2 deletions tokio-boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
# Use a FIPS-validated version of boringssl.
fips = ["boring/fips"]
fips = ["boring/fips", "boring-sys/fips"]

# Link with precompiled FIPS-validated `bcm.o` module.
fips-link-precompiled = ["fips"]
fips-link-precompiled = ["fips", "boring/fips-link-precompiled", "boring-sys/fips-link-precompiled"]

# Enables Raw public key API (https://datatracker.ietf.org/doc/html/rfc7250)
rpk = ["boring/rpk"]
Expand Down

0 comments on commit e1b5d47

Please sign in to comment.