Skip to content

Commit d3f240d

Browse files
authored
Merge pull request #119 from 9prady9/build_lib_search_options
Add more lib dir search options for build script
2 parents e96b4c3 + 4841305 commit d3f240d

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

build.rs

+38-10
Original file line numberDiff line numberDiff line change
@@ -357,19 +357,49 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
357357
if conf.use_lib {
358358
let afpath = match env::var("AF_PATH") {
359359
Ok(af_path) => PathBuf::from(&af_path),
360-
Err(_) => panic!("Error use_lib is defined, but AF_PATH is not defined"),
360+
Err(_) => {
361+
println!("WARNING! USE_LIB IS DEFINED, BUT AF_PATH IS NOT FOUND,");
362+
println!(" TRYING TO FIND LIBRARIES FROM KNOWN DEFAULT LOCATIONS");
363+
364+
if cfg!(target_os = "windows") {
365+
PathBuf::from("C:/Program Files/ArrayFire/v3/")
366+
} else {
367+
PathBuf::from("/usr/local/")
368+
}
369+
},
361370
};
371+
362372
let libpath = afpath.join("lib");
363373
backend_dirs.push(libpath.to_str().to_owned().unwrap().to_string());
374+
375+
if !cfg!(target_os = "windows") {
376+
backend_dirs.push(String::from("/opt/arrayfire-3/lib"));
377+
backend_dirs.push(String::from("/usr/lib"));
378+
}
364379
} else {
365380
backend_dirs.push(build_dir.join("package/lib").to_str().to_owned().unwrap().to_string());
366381
}
367382

368-
let lib_dir = PathBuf::from(backend_dirs.last().unwrap());
383+
let mut uni_lib_exists = false;
384+
let mut cud_lib_exists = false;
385+
let mut ocl_lib_exists = false;
386+
387+
for backend_dir in backend_dirs.iter() {
388+
let lib_dir = PathBuf::from(backend_dir);
389+
390+
let cud_lib_file_to_check = if cfg!(windows) {WIN_CUDA_LIB_NAME} else {UNIX_CUDA_LIB_NAME};
391+
cud_lib_exists = cud_lib_exists || backend_exists(&lib_dir.join(cud_lib_file_to_check).to_string_lossy());
392+
393+
let ocl_lib_file_to_check = if cfg!(windows) {WIN_OCL_LIB_NAME} else {UNIX_OCL_LIB_NAME};
394+
ocl_lib_exists = ocl_lib_exists || backend_exists(&lib_dir.join(ocl_lib_file_to_check).to_string_lossy());
395+
396+
let uni_lib_file_to_check = if cfg!(windows) {WIN_UNI_LIB_NAME} else {UNIX_UNI_LIB_NAME};
397+
uni_lib_exists = uni_lib_exists || backend_exists(&lib_dir.join(uni_lib_file_to_check).to_string_lossy());
398+
}
399+
369400
if ! conf.use_lib {
370401
// blob in cuda deps
371-
let mut lib_file_to_check = if cfg!(windows) {WIN_CUDA_LIB_NAME} else {UNIX_CUDA_LIB_NAME};
372-
if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) {
402+
if cud_lib_exists {
373403
if cfg!(windows) {
374404
backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk));
375405
backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk));
@@ -389,8 +419,8 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
389419
}
390420

391421
//blob in opencl deps
392-
lib_file_to_check = if cfg!(windows) {WIN_OCL_LIB_NAME} else {UNIX_OCL_LIB_NAME};
393-
if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) {
422+
423+
if ocl_lib_exists {
394424
if ! cfg!(target_os = "macos"){
395425
backends.push("OpenCL".to_string());
396426
}
@@ -413,14 +443,12 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
413443

414444
if conf.build_graphics=="ON" {
415445
if !conf.use_lib {
416-
backend_dirs.push(build_dir.join("third_party/forge/lib")
417-
.to_str().to_owned().unwrap().to_string());
446+
backend_dirs.push(build_dir.join("third_party/forge/lib").to_str().to_owned().unwrap().to_string());
418447
}
419448
}
420449
}
421450

422-
let lib_file_to_check = if cfg!(windows) {WIN_UNI_LIB_NAME} else {UNIX_UNI_LIB_NAME};
423-
if backend_exists(&lib_dir.join(lib_file_to_check).to_string_lossy()) {
451+
if uni_lib_exists {
424452
backends.push("af".to_string());
425453
if !conf.use_lib && conf.build_graphics=="ON" {
426454
backends.push("forge".to_string());

src/array.rs

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ extern {
104104
/// A multidimensional data container
105105
///
106106
/// Currently, Array objects can store only data until four dimensions
107+
///
108+
/// ### NOTE
109+
///
110+
/// All operators(traits) from std::ops module implemented for Array object
111+
/// carry out element wise operations. For example, `*` does multiplication of
112+
/// elements at corresponding locations in two different Arrays.
107113
pub struct Array {
108114
handle: i64,
109115
}

0 commit comments

Comments
 (0)