Skip to content

Commit a28f048

Browse files
Add feature flags to enable native-tls usage of ureq
1 parent a5fbe97 commit a28f048

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

openblas-build/Cargo.toml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@ name = "openblas-build"
33
version = "0.10.7"
44
license = "Apache-2.0/MIT"
55
edition = "2018"
6-
authors = [
7-
"Toshiki Teramura <toshiki.teramura@gmail.com>",
8-
]
6+
authors = ["Toshiki Teramura <toshiki.teramura@gmail.com>"]
97
description = "The package provides a build helper for OpenBLAS."
108
documentation = "https://docs.rs/openblas-build"
119
homepage = "https://github.com/blas-lapack-rs/openblas-src"
1210
repository = "https://github.com/blas-lapack-rs/openblas-src"
13-
readme = "../README.md"
14-
exclude = [
15-
"test_build/",
11+
readme = "../README.md"
12+
exclude = ["test_build/"]
13+
14+
[features]
15+
default = ["tls"]
16+
17+
tls = ["ureq/tls", "ureq/gzip"]
18+
native-certs = [
19+
"native-tls",
20+
"ureq/native-certs",
21+
"ureq/native-tls",
22+
"ureq/gzip",
1623
]
1724

1825
[dependencies]
1926
anyhow = "1.0.68"
2027
flate2 = "1.0.25"
2128
tar = "0.4.38"
2229
thiserror = "1.0.22"
23-
ureq = "2.5.0"
30+
ureq = { version = "2.5.0", default-features = false }
31+
native-tls = { version = "0.2.11", optional = true }
2432
walkdir = "2.3.1"

openblas-build/src/download.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,28 @@ pub fn openblas_source_url() -> String {
1313
pub fn download(out_dir: &Path) -> Result<PathBuf> {
1414
let dest = out_dir.join(format!("OpenBLAS-{}", OPENBLAS_VERSION));
1515
if !dest.exists() {
16-
let buf = ureq::get(&openblas_source_url()).call()?.into_reader();
16+
let buf = get_agent()
17+
.get(&openblas_source_url())
18+
.call()?
19+
.into_reader();
1720
let gz_stream = flate2::read::GzDecoder::new(buf);
1821
let mut ar = tar::Archive::new(gz_stream);
1922
ar.unpack(out_dir)?;
2023
assert!(dest.exists());
2124
}
2225
Ok(dest)
2326
}
27+
28+
#[cfg(feature = "native-tls")]
29+
fn get_agent() -> ureq::Agent {
30+
ureq::AgentBuilder::new()
31+
.tls_connector(std::sync::Arc::new(
32+
native_tls::TlsConnector::new().expect("failed to create TLS connector"),
33+
))
34+
.build()
35+
}
36+
37+
#[cfg(not(feature = "native-tls"))]
38+
fn get_agent() -> ureq::Agent {
39+
ureq::agent()
40+
}

openblas-src/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ build = "build.rs"
2424
links = "openblas"
2525

2626
[features]
27-
default = ["cblas", "lapacke"]
27+
default = ["cblas", "lapacke", "tls"]
2828

2929
cache = []
3030
cblas = []
3131
lapacke = []
3232
static = []
3333
system = []
34+
tls = ["openblas-build/tls"]
35+
native-certs = ["openblas-build/native-certs"]
3436

3537
[dev-dependencies]
3638
libc = "0.2"
3739

3840
[build-dependencies]
3941
dirs = "3.0.1"
40-
openblas-build = { version = "0.10.7", path = "../openblas-build" }
42+
openblas-build = { version = "0.10.7", path = "../openblas-build", default-features = false }
4143

4244
[target.'cfg(target_os="windows")'.build-dependencies]
4345
vcpkg = "0.2"

0 commit comments

Comments
 (0)