Skip to content

Commit a7776a9

Browse files
authored
Merge pull request #142 from jkawamoto/openblas-root
Export path to libopenblas for external usage
2 parents ffdb957 + 85f7996 commit a7776a9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ the variables that are renamed:
100100
| HOSTCC | OPENBLAS_HOSTCC |
101101
| RANLIB | OPENBLAS_RANLIB |
102102

103+
### Variables emitted by build.rs
104+
105+
This crate exports the following environment variables for downstream crates’ build scripts:
106+
107+
- `DEP_OPENBLAS_INCLUDE`: Absolute path to the OpenBLAS C headers directory (e.g., a directory that
108+
contains `cblas.h`, `lapacke.h` when enabled).
109+
- `DEP_OPENBLAS_LIBRARY`: Absolute path to the produced OpenBLAS library artifact (e.g., `libopenblas.a`,
110+
`libopenblas.so`, `openblas.lib`, depending on platform/linking).
111+
103112
## Cross-compile
104113

105114
Apart from providing the `--target` option to `cargo build`, one also has to

openblas-src/build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ fn feature_enabled(feature: &str) -> bool {
2828
/// - msys2 `/` is `C:\msys64\` in Windows by default install
2929
/// - It can be convert using `cygpath` command
3030
fn windows_gnu_system() {
31+
let include_path = String::from_utf8(
32+
Command::new("cygpath")
33+
.arg("-w")
34+
.arg("/mingw64/include")
35+
.output()
36+
.expect("Failed to exec cygpath")
37+
.stdout,
38+
)
39+
.expect("cygpath output includes non UTF-8 string");
3140
let lib_path = String::from_utf8(
3241
Command::new("cygpath")
3342
.arg("-w")
@@ -42,6 +51,8 @@ fn windows_gnu_system() {
4251
)
4352
.expect("cygpath output includes non UTF-8 string");
4453
println!("cargo:rustc-link-search={}", lib_path);
54+
println!("cargo:INCLUDE={}", include_path);
55+
println!("cargo:LIBRARY={}", lib_path);
4556
}
4657

4758
/// Use vcpkg for msvc "system" feature
@@ -75,6 +86,8 @@ fn macos_system() {
7586

7687
println!("cargo:rustc-link-search={}/lib", openblas.display());
7788
println!("cargo:rustc-link-search={}/lib", libomp.display());
89+
println!("cargo:INCLUDE={}", openblas.join("include").display());
90+
println!("cargo:LIBRARY={}", openblas.join("lib").display());
7891
}
7992

8093
fn main() {
@@ -219,6 +232,8 @@ fn build() {
219232
};
220233

221234
println!("cargo:rustc-link-search={}", source.display());
235+
println!("cargo:INCLUDE={}", source.display());
236+
println!("cargo:LIBRARY={}", source.display());
222237
for search_path in &make_conf.c_extra_libs.search_paths {
223238
println!("cargo:rustc-link-search={}", search_path.display());
224239
}

0 commit comments

Comments
 (0)