From 1c114c1c61cae0d7d3074285e620b4ac1540da3a Mon Sep 17 00:00:00 2001 From: pradeep Date: Tue, 8 Dec 2015 11:11:43 -0500 Subject: [PATCH 1/5] Fixed build options for OS specific cases --- build.rs | 98 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 39 deletions(-) diff --git a/build.rs b/build.rs index 9c2fa743c..b45c5e5ad 100644 --- a/build.rs +++ b/build.rs @@ -10,6 +10,15 @@ use std::path::PathBuf; use std::process::Command; use std::convert::AsRef; +// Windows specific library file names +static WIN_CUDA_LIB_NAME: &'static str = "afcuda"; +static WIN_OCL_LIB_NAME: &'static str = "afopencl"; +static WIN_UNI_LIB_NAME: &'static str = "af"; +// Linux & OSX specific library file names +static UNIX_CUDA_LIB_NAME: &'static str = "libafcuda"; +static UNIX_OCL_LIB_NAME: &'static str = "libafopencl"; +static UNIX_UNI_LIB_NAME: &'static str = "libaf"; + #[allow(dead_code)] #[derive(RustcDecodable)] struct Config { @@ -356,53 +365,64 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec, } let lib_dir = PathBuf::from(backend_dirs.last().unwrap()); - - // blob in cuda deps - if backend_exists(&lib_dir.join("libafcuda").to_string_lossy()) { - if cfg!(windows) { - backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk)); - backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk)); - } else { - let sdk_dir = format!("{}/{}", conf.cuda_sdk, "lib64"); - match dir_exists(&sdk_dir){ - true => { - backend_dirs.push(sdk_dir); - backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib64")); - }, - false => { - backend_dirs.push(format!("{}/{}", conf.cuda_sdk, "lib")); - backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib")); - }, - }; + if ! conf.use_lib { + // blob in cuda deps + let mut lib_file_to_check = if cfg!(windows) {WIN_CUDA_LIB_NAME} else {UNIX_CUDA_LIB_NAME}; + if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) { + if cfg!(windows) { + backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk)); + backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk)); + } else { + let sdk_dir = format!("{}/{}", conf.cuda_sdk, "lib64"); + match dir_exists(&sdk_dir){ + true => { + backend_dirs.push(sdk_dir); + backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib64")); + }, + false => { + backend_dirs.push(format!("{}/{}", conf.cuda_sdk, "lib")); + backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, "lib")); + }, + }; + } } - } - //blob in opencl deps - if backend_exists(&lib_dir.join("libafopencl").to_string_lossy()) { - if ! cfg!(target_os = "macos"){ - backends.push("OpenCL".to_string()); + //blob in opencl deps + lib_file_to_check = if cfg!(windows) {WIN_OCL_LIB_NAME} else {UNIX_OCL_LIB_NAME}; + if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) { + if ! cfg!(target_os = "macos"){ + backends.push("OpenCL".to_string()); + } + if cfg!(windows) { + let sdk_dir = format!("{}\\lib\\x64", conf.opencl_sdk); + if dir_exists(&sdk_dir){ + backend_dirs.push(sdk_dir); + }else { + backend_dirs.push(format!("{}\\lib\\x86_64", conf.opencl_sdk)); + } + } else { + let sdk_dir = format!("{}/{}", conf.opencl_sdk, "lib64"); + if dir_exists(&sdk_dir){ + backend_dirs.push(sdk_dir); + }else { + backend_dirs.push(format!("{}/{}", conf.opencl_sdk, "lib")); + } + } } - if cfg!(windows) { - backend_dirs.push(format!("{}\\lib\\x64", conf.opencl_sdk)); - } else { - let sdk_dir = format!("{}/{}", conf.opencl_sdk, "lib64"); - if dir_exists(&sdk_dir){ - backend_dirs.push(sdk_dir); - }else { - backend_dirs.push(format!("{}/{}", conf.opencl_sdk, "lib")); + + if conf.build_graphics=="ON" { + if !conf.use_lib { + backend_dirs.push(build_dir.join("third_party/forge/lib") + .to_str().to_owned().unwrap().to_string()); } } } - if backend_exists(&lib_dir.join("libaf").to_string_lossy()) { + let lib_file_to_check = if cfg!(windows) {WIN_UNI_LIB_NAME} else {UNIX_UNI_LIB_NAME}; + if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) { backends.push("af".to_string()); - } - - if conf.build_graphics=="ON" { - backends.push("forge".to_string()); - if !conf.use_lib { - backend_dirs.push(build_dir.join("third_party/forge/lib") - .to_str().to_owned().unwrap().to_string()); + if !conf.use_lib && conf.build_graphics=="ON" { + backends.push("forge".to_string()); } } From 99dcb49230dd08d768c827ffc0757edc6ebb0a30 Mon Sep 17 00:00:00 2001 From: pradeep Date: Tue, 8 Dec 2015 14:59:25 -0500 Subject: [PATCH 2/5] updated arrayfire submodule to v3.2.1 --- arrayfire | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrayfire b/arrayfire index c9b22d58f..f263db079 160000 --- a/arrayfire +++ b/arrayfire @@ -1 +1 @@ -Subproject commit c9b22d58f49da06a7b13ad594b807d5c1230cfab +Subproject commit f263db079443f7818a73ee94e237dd53ef017d01 From d2274269b17c4dce987206bbfb7d1afb13601562 Mon Sep 17 00:00:00 2001 From: pradeep Date: Thu, 10 Dec 2015 16:58:49 -0500 Subject: [PATCH 3/5] Updated readme with crates.io badge Also, updated platform support section with Windows related details. --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0085aac05..c74eeda00 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,13 @@ You can find the most recent updated documentation [here](http://arrayfire.githu ## Supported platforms -Currently, only Linux and OSX. With Rust 1.4(MSVC binary), we soon expect to get the Windows support available. +Linux and OSX: The bindings have been tested with Rust 1.x. +Windows: Rust 1.5 (MSVC ABI) is the first version that works with our bindings and ArrayFire +library(built using MSVC compiler). -## Use from Crates.io +We recommend using Rust 1.5 and higher. + +## Use from Crates.io [![](http://meritbadge.herokuapp.com/arrayfire)](https://crates.io/crates/arrayfire) To use the rust bindings for ArrayFire from crates.io, the following requirements are to be met first. From 3ce28c638b4e66e734a1469024f102d5939c095d Mon Sep 17 00:00:00 2001 From: pradeep Date: Thu, 10 Dec 2015 17:00:23 -0500 Subject: [PATCH 4/5] style fixes --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c74eeda00..381f883e4 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,8 @@ You can find the most recent updated documentation [here](http://arrayfire.githu ## Supported platforms -Linux and OSX: The bindings have been tested with Rust 1.x. -Windows: Rust 1.5 (MSVC ABI) is the first version that works with our bindings and ArrayFire -library(built using MSVC compiler). +- Linux and OSX: The bindings have been tested with Rust 1.x. +- Windows: Rust 1.5 (MSVC ABI) is the first version that works with our bindings and ArrayFire library(built using MSVC compiler). We recommend using Rust 1.5 and higher. From 27d90728c0b15e63702344c858276b4df15b34c0 Mon Sep 17 00:00:00 2001 From: pradeep Date: Thu, 10 Dec 2015 17:06:38 -0500 Subject: [PATCH 5/5] Version bump to 3.2.0 from 3.2.0-rc0 This version is going to work with ArrayFire 3.2.1 or higher versions of ArrayFire library. 3.2.0 has a known issue with the wrapper, so recommed using 3.2.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4adf0b90a..93fd8e562 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "arrayfire" 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." -version = "3.2.0-rc0" +version = "3.2.0" documentation = "http://arrayfire.github.io/arrayfire-rust/arrayfire/index.html" homepage = "https://github.com/arrayfire/arrayfire" repository = "https://github.com/arrayfire/arrayfire-rust"