Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building with non bazel commits of boringssl #215

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions boring-sys/build/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::PathBuf;
pub(crate) struct Config {
pub(crate) manifest_dir: PathBuf,
pub(crate) out_dir: PathBuf,
pub(crate) is_bazel: bool,
pub(crate) host: String,
pub(crate) target: String,
pub(crate) target_arch: String,
Expand Down Expand Up @@ -51,9 +52,15 @@ impl Config {
features.fips || features.fips_link_precompiled,
);

let mut is_bazel = false;
if let Some(src_path) = &env.source_path {
is_bazel = src_path.join("src").exists();
}

let config = Self {
manifest_dir,
out_dir,
is_bazel,
host,
target,
target_arch,
Expand Down
29 changes: 23 additions & 6 deletions boring-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,16 @@ fn apply_patch(config: &Config, patch_name: &str) -> io::Result<()> {
.join(patch_name)
.canonicalize()?;

let mut args = vec!["apply", "-v", "--whitespace=fix"];

// non-bazel versions of BoringSSL have no src/ dir
if config.is_bazel {
args.push("-p2");
}

run_command(
Command::new("git")
.args(["apply", "-v", "--whitespace=fix"])
.args(&args)
.arg(cmd_path)
.current_dir(src_path),
)?;
Expand Down Expand Up @@ -548,6 +555,16 @@ fn built_boring_source_path(config: &Config) -> &PathBuf {
"cargo:warning=skipping git patches application, provided\
native BoringSSL is expected to have the patches included"
);
} else if config.env.source_path.is_some()
&& (config.features.rpk
|| config.features.pq_experimental
|| config.features.underscore_wildcards)
{
panic!(
"BORING_BSSL_ASSUME_PATCHED must be set when setting
BORING_BSSL_SOURCE_PATH and using any of the following
features: rpk, pq-experimental, underscore-wildcards"
);
} else {
ensure_patches_applied(config).unwrap();
}
Expand Down Expand Up @@ -620,23 +637,23 @@ fn main() {
let bssl_dir = built_boring_source_path(&config);
let build_path = get_boringssl_platform_output_path(&config);

if config.features.fips || config.features.fips_link_precompiled {
if config.is_bazel {
println!(
"cargo:rustc-link-search=native={}/build/crypto/{}",
"cargo:rustc-link-search=native={}/lib/{}",
bssl_dir.display(),
build_path
);
} else {
println!(
"cargo:rustc-link-search=native={}/build/ssl/{}",
"cargo:rustc-link-search=native={}/build/crypto/{}",
bssl_dir.display(),
build_path
);
println!(
"cargo:rustc-link-search=native={}/lib/{}",
"cargo:rustc-link-search=native={}/build/ssl/{}",
bssl_dir.display(),
build_path
);
} else {
println!(
"cargo:rustc-link-search=native={}/build/{}",
bssl_dir.display(),
Expand Down
2 changes: 1 addition & 1 deletion boring-sys/patches/rpk.patch
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ index 8d5a23872..b9ac70dfe 100644

@@ -150,6 +169,7 @@ SSL_HANDSHAKE::SSL_HANDSHAKE(SSL *ssl_arg)
cert_compression_negotiated(false),
+ server_certificate_type_negotiated(false),
apply_jdk11_workaround(false),
can_release_private_key(false),
+ server_certificate_type_negotiated(false),
channel_id_negotiated(false) {
assert(ssl);

Expand Down
Loading