mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-22 04:40:01 +00:00
Download ninja and gn binaries from github (#307)
This commit is contained in:
parent
eedcb91e92
commit
3e63d63223
19
build.rs
19
build.rs
@ -47,7 +47,7 @@ fn build_v8() {
|
||||
}
|
||||
|
||||
if need_gn_ninja_download() {
|
||||
download_gn_ninja_binaries();
|
||||
download_ninja_gn_binaries();
|
||||
}
|
||||
|
||||
// On windows, rustc cannot link with a V8 debug build.
|
||||
@ -128,7 +128,7 @@ fn platform() -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
fn download_gn_ninja_binaries() {
|
||||
fn download_ninja_gn_binaries() {
|
||||
let root = env::current_dir().unwrap();
|
||||
// target/debug//build/rusty_v8-d9e5a424d4f96994/out/
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
@ -141,10 +141,11 @@ fn download_gn_ninja_binaries() {
|
||||
.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");
|
||||
let bin_dir = target_dir
|
||||
.join("ninja_gn_binaries-20191129")
|
||||
.join(platform());
|
||||
let gn = bin_dir.join("gn");
|
||||
let ninja = bin_dir.join("ninja");
|
||||
#[cfg(windows)]
|
||||
let gn = gn.with_extension("exe");
|
||||
#[cfg(windows)]
|
||||
@ -152,11 +153,11 @@ fn download_gn_ninja_binaries() {
|
||||
|
||||
if !gn.exists() || !ninja.exists() {
|
||||
let status = Command::new("python")
|
||||
.arg("./tools/gn_ninja_binaries.py")
|
||||
.arg("./tools/ninja_gn_binaries.py")
|
||||
.arg("--dir")
|
||||
.arg(&download_dir)
|
||||
.arg(&target_dir)
|
||||
.status()
|
||||
.expect("gn_ninja_binaries.py download failed");
|
||||
.expect("ninja_gn_binaries.py download failed");
|
||||
assert!(status.success());
|
||||
}
|
||||
assert!(gn.exists());
|
||||
|
@ -4,14 +4,9 @@
|
||||
# found in the LICENSE file.
|
||||
"""This script is used to download prebuilt gn/ninja binaries."""
|
||||
|
||||
# TODO: Running stand-alone won't work on Windows due to the dia dll copying.
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
@ -23,23 +18,10 @@ except ImportError: # For Py3 compatibility
|
||||
from urllib.error import HTTPError, URLError
|
||||
from urllib.request import urlopen
|
||||
|
||||
URL = "https://s3.amazonaws.com/deno.land/gn_ninja_binaries.tar.gz"
|
||||
URL = "https://github.com/denoland/ninja_gn_binaries/archive/20191129.tar.gz"
|
||||
DIR = None
|
||||
|
||||
|
||||
def RmTree(dir):
|
||||
"""Delete dir."""
|
||||
|
||||
def ChmodAndRetry(func, path, _):
|
||||
# Subversion can leave read-only files around.
|
||||
if not os.access(path, os.W_OK):
|
||||
os.chmod(path, stat.S_IWUSR)
|
||||
return func(path)
|
||||
raise
|
||||
|
||||
shutil.rmtree(dir, onerror=ChmodAndRetry)
|
||||
|
||||
|
||||
def DownloadUrl(url, output_file):
|
||||
"""Download url into output_file."""
|
||||
CHUNK_SIZE = 4096
|
||||
@ -49,25 +31,18 @@ def DownloadUrl(url, output_file):
|
||||
|
||||
while True:
|
||||
try:
|
||||
sys.stdout.write('Downloading %s ' % url)
|
||||
sys.stdout.write('Downloading %s...' % url)
|
||||
sys.stdout.flush()
|
||||
response = urlopen(url)
|
||||
total_size = int(response.info().get('Content-Length').strip())
|
||||
bytes_done = 0
|
||||
dots_printed = 0
|
||||
while True:
|
||||
chunk = response.read(CHUNK_SIZE)
|
||||
if not chunk:
|
||||
break
|
||||
output_file.write(chunk)
|
||||
bytes_done += len(chunk)
|
||||
num_dots = TOTAL_DOTS * bytes_done // total_size
|
||||
sys.stdout.write('.' * (num_dots - dots_printed))
|
||||
sys.stdout.flush()
|
||||
dots_printed = num_dots
|
||||
if bytes_done != total_size:
|
||||
raise URLError(
|
||||
"only got %d of %d bytes" % (bytes_done, total_size))
|
||||
if bytes_done == 0:
|
||||
raise URLError("empty response")
|
||||
print(' Done.')
|
||||
return
|
||||
except URLError as e:
|
||||
@ -88,9 +63,7 @@ def EnsureDirExists(path):
|
||||
|
||||
|
||||
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."""
|
||||
"""Download an archive from url and extract into output_dir."""
|
||||
with tempfile.TemporaryFile() as f:
|
||||
DownloadUrl(url, f)
|
||||
f.seek(0)
|
||||
@ -100,13 +73,10 @@ def DownloadAndUnpack(url, output_dir):
|
||||
|
||||
|
||||
def Update():
|
||||
if os.path.exists(DIR):
|
||||
RmTree(DIR)
|
||||
try:
|
||||
DownloadAndUnpack(URL, DIR)
|
||||
except URLError:
|
||||
print('Failed to download prebuilt ninja/gn binaries %s' % URL)
|
||||
print('Exiting.')
|
||||
print('Failed to download ninja/gn binaries.')
|
||||
sys.exit(1)
|
||||
|
||||
return 0
|
Loading…
Reference in New Issue
Block a user