Skip to content

remove the lib directory dependency from conf and add a message for when AF_PATH is not set #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@
"boost_dir": "E:\\Libraries\\boost_1_56_0",

"cuda_sdk": "/usr/local/cuda",
"opencl_sdk": "/usr",
"sdk_lib_dir": "lib64"
"opencl_sdk": "/usr"
}
33 changes: 28 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct Config {
// GPU backends
cuda_sdk: String,
opencl_sdk: String,
sdk_lib_dir: String,
}

macro_rules! t {
Expand All @@ -57,6 +56,13 @@ fn fail(s: &str) -> ! {
panic!("\n{}\n\nbuild script failed, must exit now", s)
}

fn dir_exists(location: &str) -> bool {
match fs::metadata(location) {
Ok(f) => f.is_dir(),
Err(_) => false,
}
}

fn file_exists(location: &str) -> bool {
match fs::metadata(location) {
Ok(f) => f.is_file(),
Expand Down Expand Up @@ -339,7 +345,10 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
let mut backends :Vec<String> = Vec::new();

if conf.use_lib {
let afpath = PathBuf::from(&env::var("AF_PATH").unwrap());
let afpath = match env::var("AF_PATH") {
Ok(af_path) => PathBuf::from(&af_path),
Err(_) => panic!("Error use_lib is defined, but AF_PATH is not defined"),
};
let libpath = afpath.join("lib");
backend_dirs.push(libpath.to_str().to_owned().unwrap().to_string());
} else {
Expand All @@ -354,8 +363,17 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
backend_dirs.push(format!("{}\\lib\\x64", conf.cuda_sdk));
backend_dirs.push(format!("{}\\nvvm\\lib\\x64", conf.cuda_sdk));
} else {
backend_dirs.push(format!("{}/{}", conf.cuda_sdk, conf.sdk_lib_dir));
backend_dirs.push(format!("{}/nvvm/{}", conf.cuda_sdk, conf.sdk_lib_dir));
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"));
},
};
}
}

Expand All @@ -367,7 +385,12 @@ fn blob_backends(conf: &Config, build_dir: &std::path::PathBuf) -> (Vec<String>,
if cfg!(windows) {
backend_dirs.push(format!("{}\\lib\\x64", conf.opencl_sdk));
} else {
backend_dirs.push(format!("{}/{}", conf.opencl_sdk, conf.sdk_lib_dir));
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"));
}
}
}

Expand Down