Skip to content

Commit f668c4b

Browse files
committed
Merge pull request #50 from arrayfire/build_fixes
Fixed build options for OS specific cases
2 parents 13dcd15 + 27d9072 commit f668c4b

File tree

4 files changed

+66
-43
lines changed

4 files changed

+66
-43
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "arrayfire"
33
description = "ArrayFire is a high performance software library for parallel computing with an easy-to-use API. Its array based function set makes parallel programming simple. ArrayFire's multiple backends (CUDA, OpenCL and native CPU) make it platform independent and highly portable. A few lines of code in ArrayFire can replace dozens of lines of parallel computing code, saving you valuable time and lowering development costs. This crate provides Rust bindings for ArrayFire library."
4-
version = "3.2.0-rc0"
4+
version = "3.2.0"
55
documentation = "http://arrayfire.github.io/arrayfire-rust/arrayfire/index.html"
66
homepage = "https://github.com/arrayfire/arrayfire"
77
repository = "https://github.com/arrayfire/arrayfire-rust"

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ You can find the most recent updated documentation [here](http://arrayfire.githu
88

99
## Supported platforms
1010

11-
Currently, only Linux and OSX. With Rust 1.4(MSVC binary), we soon expect to get the Windows support available.
11+
- Linux and OSX: The bindings have been tested with Rust 1.x.
12+
- Windows: Rust 1.5 (MSVC ABI) is the first version that works with our bindings and ArrayFire library(built using MSVC compiler).
1213

13-
## Use from Crates.io
14+
We recommend using Rust 1.5 and higher.
15+
16+
## Use from Crates.io [![](http://meritbadge.herokuapp.com/arrayfire)](https://crates.io/crates/arrayfire)
1417

1518
To use the rust bindings for ArrayFire from crates.io, the following requirements are to be met
1619
first.

build.rs

+59-39
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ use std::path::PathBuf;
1010
use std::process::Command;
1111
use std::convert::AsRef;
1212

13+
// Windows specific library file names
14+
static WIN_CUDA_LIB_NAME: &'static str = "afcuda";
15+
static WIN_OCL_LIB_NAME: &'static str = "afopencl";
16+
static WIN_UNI_LIB_NAME: &'static str = "af";
17+
// Linux & OSX specific library file names
18+
static UNIX_CUDA_LIB_NAME: &'static str = "libafcuda";
19+
static UNIX_OCL_LIB_NAME: &'static str = "libafopencl";
20+
static UNIX_UNI_LIB_NAME: &'static str = "libaf";
21+
1322
#[allow(dead_code)]
1423
#[derive(RustcDecodable)]
1524
struct Config {
@@ -356,53 +365,64 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
356365
}
357366

358367
let lib_dir = PathBuf::from(backend_dirs.last().unwrap());
359-
360-
// blob in cuda deps
361-
if backend_exists(&lib_dir.join("libafcuda").to_string_lossy()) {
362-
if cfg!(windows) {
363-
backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk));
364-
backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk));
365-
} else {
366-
let sdk_dir = format!("{}/{}", conf.cuda_sdk, "lib64");
367-
match dir_exists(&sdk_dir){
368-
true => {
369-
backend_dirs.push(sdk_dir);
370-
backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib64"));
371-
},
372-
false => {
373-
backend_dirs.push(format!("{}/{}", conf.cuda_sdk, "lib"));
374-
backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib"));
375-
},
376-
};
368+
if ! conf.use_lib {
369+
// blob in cuda deps
370+
let mut lib_file_to_check = if cfg!(windows) {WIN_CUDA_LIB_NAME} else {UNIX_CUDA_LIB_NAME};
371+
if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) {
372+
if cfg!(windows) {
373+
backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk));
374+
backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk));
375+
} else {
376+
let sdk_dir = format!("{}/{}", conf.cuda_sdk, "lib64");
377+
match dir_exists(&sdk_dir){
378+
true => {
379+
backend_dirs.push(sdk_dir);
380+
backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib64"));
381+
},
382+
false => {
383+
backend_dirs.push(format!("{}/{}", conf.cuda_sdk, "lib"));
384+
backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib"));
385+
},
386+
};
387+
}
377388
}
378-
}
379389

380-
//blob in opencl deps
381-
if backend_exists(&lib_dir.join("libafopencl").to_string_lossy()) {
382-
if ! cfg!(target_os = "macos"){
383-
backends.push("OpenCL".to_string());
390+
//blob in opencl deps
391+
lib_file_to_check = if cfg!(windows) {WIN_OCL_LIB_NAME} else {UNIX_OCL_LIB_NAME};
392+
if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) {
393+
if ! cfg!(target_os = "macos"){
394+
backends.push("OpenCL".to_string());
395+
}
396+
if cfg!(windows) {
397+
let sdk_dir = format!("{}\\lib\\x64", conf.opencl_sdk);
398+
if dir_exists(&sdk_dir){
399+
backend_dirs.push(sdk_dir);
400+
}else {
401+
backend_dirs.push(format!("{}\\lib\\x86_64", conf.opencl_sdk));
402+
}
403+
} else {
404+
let sdk_dir = format!("{}/{}", conf.opencl_sdk, "lib64");
405+
if dir_exists(&sdk_dir){
406+
backend_dirs.push(sdk_dir);
407+
}else {
408+
backend_dirs.push(format!("{}/{}", conf.opencl_sdk, "lib"));
409+
}
410+
}
384411
}
385-
if cfg!(windows) {
386-
backend_dirs.push(format!("{}\\lib\\x64", conf.opencl_sdk));
387-
} else {
388-
let sdk_dir = format!("{}/{}", conf.opencl_sdk, "lib64");
389-
if dir_exists(&sdk_dir){
390-
backend_dirs.push(sdk_dir);
391-
}else {
392-
backend_dirs.push(format!("{}/{}", conf.opencl_sdk, "lib"));
412+
413+
if conf.build_graphics=="ON" {
414+
if !conf.use_lib {
415+
backend_dirs.push(build_dir.join("third_party/forge/lib")
416+
.to_str().to_owned().unwrap().to_string());
393417
}
394418
}
395419
}
396420

397-
if backend_exists(&lib_dir.join("libaf").to_string_lossy()) {
421+
let lib_file_to_check = if cfg!(windows) {WIN_UNI_LIB_NAME} else {UNIX_UNI_LIB_NAME};
422+
if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) {
398423
backends.push("af".to_string());
399-
}
400-
401-
if conf.build_graphics=="ON" {
402-
backends.push("forge".to_string());
403-
if !conf.use_lib {
404-
backend_dirs.push(build_dir.join("third_party/forge/lib")
405-
.to_str().to_owned().unwrap().to_string());
424+
if !conf.use_lib && conf.build_graphics=="ON" {
425+
backends.push("forge".to_string());
406426
}
407427
}
408428

0 commit comments

Comments
 (0)