0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-24 15:19:31 -05:00

Make RUSTY_V8_MIRROR understand file paths (#488)

Fixes #470
This commit is contained in:
Ben Noordhuis 2020-10-07 08:39:02 +02:00 committed by GitHub
parent 6993fd3a30
commit 1149ee3ada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 3 deletions

View file

@ -39,12 +39,42 @@ Binaries builds are turned on by default: `cargo build` will initiate a download
from github to get the static lib. To disable this build using the
`V8_FROM_SOURCE` environmental variable.
If you prefer another location for downloading binaries,
use the`RUSTY_V8_MIRROR` environmental variable.
When making changes to rusty_v8 itself, it should be tested by build from
source. The CI always builds from source.
## The `RUSTY_V8_MIRROR` environment variable
Tells the build script where to get binary builds from. Understands
`http://` and `https://` URLs, and file paths. The default is
https://github.com/denoland/rusty_v8/releases/download.
File-based mirrors are good for using cached downloads. First, point
the environment variable to a suitable location:
# you might want to add this to your .bashrc
$ export RUSTY_V8_MIRROR=$HOME/.cache/rusty_v8
Then populate the cache:
```bash
#!/bin/bash
# see https://github.com/denoland/rusty_v8/releases
for REL in v0.9.0 v0.10.0; do
mkdir -p $RUSTY_V8_MIRROR/$REL
for FILE in \
librusty_v8_debug_x86_64-unknown-linux-gnu.a \
librusty_v8_release_x86_64-unknown-linux-gnu.a \
; do
if [ ! -f $RUSTY_V8_MIRROR/$REL/$FILE ]; then
wget -O $CACHE_DIR/$REL/$FILE \
https://github.com/denoland/rusty_v8/releases/download/$REL/$FILE
fi
done
done
```
## Build V8 from Source
Use `V8_FROM_SOURCE=1 cargo build -vv` to build the crate completely from

View file

@ -1,5 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use std::env;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::process::exit;
@ -199,6 +200,11 @@ fn static_lib_url() -> (String, String) {
}
fn download_file(url: String, filename: PathBuf) {
if !url.starts_with("http:") && !url.starts_with("https:") {
fs::copy(&url, filename).unwrap();
return;
}
// Try downloading with python first. Python is a V8 build dependency,
// so this saves us from adding a Rust HTTP client dependency.
println!("Downloading {}", url);