Move MoltenVK checkout directory to OUT_DIR.

build.rs scripts are not allowed to write to the current directory, which "cargo package" complained about.
This commit is contained in:
Johan Andersson 2019-06-29 00:41:11 +02:00
parent 4c32434982
commit 4dadc1e3f0

View file

@ -28,7 +28,8 @@ mod mac {
}, },
}; };
let checkout_dir = "MoltenVK"; let checkout_dir =
Path::new(&std::env::var("OUT_DIR").expect("Couldn't find OUT_DIR")).join("MoltenVK");
let exit = Arc::new(AtomicBool::new(false)); let exit = Arc::new(AtomicBool::new(false));
let wants_exit = exit.clone(); let wants_exit = exit.clone();
@ -47,9 +48,9 @@ mod mac {
} }
}); });
let git_status = if Path::new(checkout_dir).exists() { let git_status = if Path::new(&checkout_dir).exists() {
Command::new("git") Command::new("git")
.current_dir(checkout_dir) .current_dir(&checkout_dir)
.arg("pull") .arg("pull")
.spawn() .spawn()
.expect("failed to spawn git") .expect("failed to spawn git")
@ -59,6 +60,7 @@ mod mac {
Command::new("git") Command::new("git")
.arg("clone") .arg("clone")
.arg("https://github.com/KhronosGroup/MoltenVK.git") .arg("https://github.com/KhronosGroup/MoltenVK.git")
.arg(&checkout_dir)
.spawn() .spawn()
.expect("failed to spawn git") .expect("failed to spawn git")
.wait() .wait()
@ -68,7 +70,7 @@ mod mac {
assert!(git_status.success(), "failed to clone MoltenVK"); assert!(git_status.success(), "failed to clone MoltenVK");
let status = Command::new("sh") let status = Command::new("sh")
.current_dir(checkout_dir) .current_dir(&checkout_dir)
.arg("fetchDependencies") .arg("fetchDependencies")
.spawn() .spawn()
.expect("failed to spawn fetchDependencies") .expect("failed to spawn fetchDependencies")
@ -88,7 +90,7 @@ mod mac {
}; };
let status = Command::new("make") let status = Command::new("make")
.current_dir("MoltenVK") .current_dir(&checkout_dir)
.arg(target_name) .arg(target_name)
.spawn() .spawn()
.expect("failed to spawn fetchDependencies") .expect("failed to spawn fetchDependencies")
@ -134,9 +136,9 @@ fn main() {
// The 'external' feature was not enabled. Molten will be built automaticaly. // The 'external' feature was not enabled. Molten will be built automaticaly.
if !is_external_enabled() { if !is_external_enabled() {
let target_dir = Path::new("native"); let target_dir = Path::new(&std::env::var("OUT_DIR").unwrap()).join("MoltenVK-build");
let target_name = build_molten(&target_dir); let target_name = build_molten(&target_dir);
let project_dir = { let project_dir = {
let mut pb = PathBuf::from( let mut pb = PathBuf::from(
std::env::var("CARGO_MANIFEST_DIR").expect("unable to find env:CARGO_MANIFEST_DIR"), std::env::var("CARGO_MANIFEST_DIR").expect("unable to find env:CARGO_MANIFEST_DIR"),