diff --git a/build.rs b/build.rs index c83e7125..22535318 100644 --- a/build.rs +++ b/build.rs @@ -108,8 +108,19 @@ fn platform() -> &'static str { fn download_gn_ninja_binaries() { let root = env::current_dir().unwrap(); - let out_dir = root.join(env::var_os("OUT_DIR").unwrap()); - let d = out_dir.join("gn_ninja_binaries").join(platform()); + // target/debug//build/rusty_v8-d9e5a424d4f96994/out/ + let out_dir = env::var_os("OUT_DIR").unwrap(); + let out_dir_abs = root.join(out_dir); + // This would be target/debug or target/release + let target_dir = out_dir_abs + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap(); + let download_dir = target_dir.join("gn_ninja_binaries"); + let d = download_dir.join("gn_ninja_binaries").join(platform()); let gn = d.join("gn"); let ninja = d.join("ninja"); #[cfg(windows)] @@ -121,7 +132,7 @@ fn download_gn_ninja_binaries() { let status = Command::new("python") .arg("./tools/gn_ninja_binaries.py") .arg("--dir") - .arg(&out_dir) + .arg(&download_dir) .status() .expect("gn_ninja_binaries.py download failed"); assert!(status.success()); diff --git a/tools/gn_ninja_binaries.py b/tools/gn_ninja_binaries.py index 7aa84d24..0047ea9b 100755 --- a/tools/gn_ninja_binaries.py +++ b/tools/gn_ninja_binaries.py @@ -87,7 +87,7 @@ def EnsureDirExists(path): os.makedirs(path) -def DownloadAndUnpack(url, output_dir, path_prefixes=None): +def DownloadAndUnpack(url, output_dir): """Download an archive from url and extract into output_dir. If path_prefixes is not None, only extract files whose paths within the archive start with any prefix in path_prefixes.""" @@ -96,20 +96,14 @@ def DownloadAndUnpack(url, output_dir, path_prefixes=None): f.seek(0) EnsureDirExists(output_dir) t = tarfile.open(mode='r:gz', fileobj=f) - members = None - if path_prefixes is not None: - members = [ - m for m in t.getmembers() if any( - m.name.startswith(p) for p in path_prefixes) - ] - t.extractall(path=output_dir, members=members) + t.extractall(path=output_dir) def Update(): if os.path.exists(DIR): RmTree(DIR) try: - DownloadAndUnpack(URL, DIR, None) + DownloadAndUnpack(URL, DIR) except URLError: print('Failed to download prebuilt ninja/gn binaries %s' % URL) print('Exiting.')