0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00

add depot_tools to path in build.rs (#6)

This commit is contained in:
Ry Dahl 2019-11-02 14:51:37 -04:00 committed by GitHub
parent 7dbde4e6fb
commit 72d622bb4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 47 deletions

View file

@ -25,11 +25,6 @@ jobs:
with:
rust-version: "1.38.0"
- name: Install python
uses: actions/setup-python@v1
with:
python-version: "2.7.16"
- name: Remove unused versions of Python
# Depot_tools bootstraps its own copy of virtualenv. This fails on
# windows when multiple versions of python are in present in PATH,
@ -45,10 +40,7 @@ jobs:
ForEach-Object { Move-Item "$_" "$_.disabled" }
- name: Environment (common)
run: |
echo ::set-env name=GH_ACTIONS::1
echo ::set-env name=RUSTC_WRAPPER::sccache
echo ::set-env name=DENO_BUILD_MODE::release
run: echo ::set-env name=RUSTC_WRAPPER::sccache
- name: Environment (linux)
if: startsWith(matrix.os, 'ubuntu')
@ -60,7 +52,6 @@ jobs:
curl -LO https://github.com/mozilla/sccache/releases/download/0.2.12/sccache-0.2.12-x86_64-unknown-linux-musl.tar.gz
tar -xzvf sccache-0.2.12-x86_64-unknown-linux-musl.tar.gz
echo ::add-path::`pwd`/sccache-0.2.12-x86_64-unknown-linux-musl/
echo ::add-path::`pwd`/third_party/depot_tools/
- name: Environment (mac)
if: startsWith(matrix.os, 'macOS')
@ -68,7 +59,6 @@ jobs:
curl -LO https://github.com/mozilla/sccache/releases/download/0.2.12/sccache-0.2.12-x86_64-apple-darwin.tar.gz
tar -xzvf sccache-0.2.12-x86_64-apple-darwin.tar.gz
echo ::add-path::`pwd`/sccache-0.2.12-x86_64-apple-darwin/
echo ::add-path::`pwd`/third_party/depot_tools/
- name: Environment (windows)
if: startsWith(matrix.os, 'windows')

View file

@ -2,14 +2,12 @@
use cargo_gn;
use std::env;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use which::which;
fn main() {
if cfg!(windows) {
init_depot_tools_windows();
}
init_depot_tools();
if !Path::new("third_party/v8/src").is_dir()
|| env::var_os("GCLIENT_SYNC").is_some()
{
@ -50,71 +48,77 @@ fn main() {
}
}
fn init_depot_tools_windows() {
fn init_depot_tools() {
env::set_var("DEPOT_TOOLS_WIN_TOOLCHAIN", "0");
env::set_var("DEPOT_TOOLS_UPDATE", "0");
env::set_var("DEPOT_TOOLS_METRICS", "0");
let depot_tools = env::current_dir()
.unwrap()
.join("third_party")
.join("depot_tools");
// Bootstrap depot_tools.
if !depot_tools.join("git.bat").is_file() {
let status = Command::new("cmd.exe")
.arg("/c")
.arg("bootstrap\\win_tools.bat")
.current_dir(&depot_tools)
.status()
.expect("bootstrapping depot_tools failed");
assert!(status.success());
}
// Add third_party/depot_tools and buildtools/win to PATH.
// TODO: this should be done on all platforms.
// TODO: buildtools/win should not be added; instead, cargo_gn should invoke
// depot_tools/gn.bat.
let buildtools_win =
env::current_dir().unwrap().join("buildtools").join("win");
// Bootstrap depot_tools.
let path = env::var_os("PATH").unwrap();
let paths = vec![depot_tools, buildtools_win]
// "Add depot_tools to the start of your PATH (must be ahead of any installs
// of Python)."
// https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
let paths = vec![depot_tools.clone(), buildtools_win]
.into_iter()
.chain(env::split_paths(&path))
.collect::<Vec<_>>();
let path = env::join_paths(paths).unwrap();
env::set_var("PATH", &path);
// TODO: cargo_gn should do this.
env::set_var("DEPOT_TOOLS_WIN_TOOLCHAIN", "0");
}
fn git_submodule_update() {
Command::new("git")
.arg("submodule")
.arg("update")
.arg("--init")
.status()
.expect("git submodule update failed");
env::set_var("GN", which("gn").unwrap());
if cfg!(windows) {
// Bootstrap depot_tools.
if !depot_tools.join("git.bat").is_file() {
let status = Command::new("cmd.exe")
.arg("/c")
.arg("bootstrap\\win_tools.bat")
.current_dir(&depot_tools)
.status()
.expect("bootstrapping depot_tools failed");
assert!(status.success());
}
}
}
fn gclient_sync() {
let root = env::current_dir().unwrap();
let third_party = root.join("third_party");
let gclient_rel = PathBuf::from("depot_tools/gclient.py");
let depot_tools = third_party.join("depot_tools");
let gclient_file = third_party.join("gclient_config.py");
assert!(gclient_file.exists());
if !third_party.join(&gclient_rel).exists() {
git_submodule_update();
let gclient = depot_tools.join(if cfg!(windows) {
"gclient.bat"
} else {
"gclient"
});
if !gclient.is_file() {
panic!(
"Could not find gclient {}. Maybe run git submodule update?",
gclient.display()
);
}
println!("Running gclient sync to download V8. This could take a while.");
let status = Command::new("python")
let status = Command::new(gclient)
.current_dir(&third_party)
.arg(&gclient_rel)
.arg("sync")
.arg("--no-history")
.arg("--shallow")
.env("DEPOT_TOOLS_UPDATE", "0")
.env("DEPOT_TOOLS_METRICS", "0")
.env("GCLIENT_FILE", gclient_file)
.env("DEPOT_TOOLS_WIN_TOOLCHAIN", "0")
.status()
.expect("gclient sync failed");
assert!(status.success());