@@ -10,6 +10,15 @@ use std::path::PathBuf;
10
10
use std:: process:: Command ;
11
11
use std:: convert:: AsRef ;
12
12
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
+
13
22
#[ allow( dead_code) ]
14
23
#[ derive( RustcDecodable ) ]
15
24
struct Config {
@@ -356,53 +365,64 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
356
365
}
357
366
358
367
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
+ }
377
388
}
378
- }
379
389
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
+ }
384
411
}
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 ( ) ) ;
393
417
}
394
418
}
395
419
}
396
420
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 ( ) ) {
398
423
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 ( ) ) ;
406
426
}
407
427
}
408
428
0 commit comments