Merge pull request #37 from Evrard-Nil/allow-pre-built-binaries

Allow pre-built binaries of BoringSSL
This commit is contained in:
Joshua Nelson 2021-07-28 14:58:52 -04:00 committed by GitHub
commit 7c772a9832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 10 deletions

View File

@ -9,9 +9,20 @@ and [hyper](https://github.com/hyperium/hyper) built on top of it.
## Release Support ## Release Support
The crate statically links with the latest BoringSSL master branch. By default, the crate statically links with the latest BoringSSL master branch.
### Contribution ## Support for pre-built binaries
While this crate can build BoringSSL on its own, you may want to provide pre-built binaries instead.
To do so, specify the environment variable `BORING_BSSL_PATH` with the path to the binaries.
You can also provide specific headers by setting `BORING_BSSL_INCLUDE_PATH`.
_Notes_: The crate will look for headers in the `$BORING_BSSL_INCLUDE_PATH/openssl/` folder, make sure to place your headers there.
_Warning_: When providing a different version of BoringSSL make sure to use a compatible one, the crate relies on the presence of certain functions.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0 submitted for inclusion in the work by you, as defined in the Apache-2.0

View File

@ -175,14 +175,17 @@ fn main() {
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
let mut cfg = get_boringssl_cmake_config(); let bssl_dir = std::env::var("BORING_BSSL_PATH").unwrap_or_else(|_| {
let mut cfg = get_boringssl_cmake_config();
if cfg!(feature = "fuzzing") { if cfg!(feature = "fuzzing") {
cfg.cxxflag("-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE") cfg.cxxflag("-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE")
.cxxflag("-DBORINGSSL_UNSAFE_FUZZER_MODE"); .cxxflag("-DBORINGSSL_UNSAFE_FUZZER_MODE");
} }
cfg.build_target("bssl").build().display().to_string()
});
let bssl_dir = cfg.build_target("bssl").build().display().to_string();
let build_path = get_boringssl_platform_output_path(); let build_path = get_boringssl_platform_output_path();
let build_dir = format!("{}/build/{}", bssl_dir, build_path); let build_dir = format!("{}/build/{}", bssl_dir, build_path);
println!("cargo:rustc-link-search=native={}", build_dir); println!("cargo:rustc-link-search=native={}", build_dir);
@ -195,7 +198,11 @@ fn main() {
println!("cargo:rustc-cdylib-link-arg=-Wl,-undefined,dynamic_lookup"); println!("cargo:rustc-cdylib-link-arg=-Wl,-undefined,dynamic_lookup");
} }
let include_path = PathBuf::from("deps/boringssl/src/include"); let include_path = PathBuf::from(
std::env::var("BORING_BSSL_INCLUDE_PATH")
.unwrap_or_else(|_| String::from("deps/boringssl/src/include")),
);
let mut builder = bindgen::Builder::default() let mut builder = bindgen::Builder::default()
.derive_copy(true) .derive_copy(true)
.derive_debug(true) .derive_debug(true)