2017-12-18 09:19:46 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Use this script to fetch all dependencies for V8 to run build_gn.py.
|
|
|
|
|
|
|
|
Usage: fetch_deps.py <v8-path>
|
|
|
|
"""
|
|
|
|
|
2019-02-19 08:28:26 +00:00
|
|
|
# for py2/py3 compatibility
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-12-18 09:19:46 +00:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import node_common
|
|
|
|
|
|
|
|
GCLIENT_SOLUTION = [
|
|
|
|
{ "name" : "v8",
|
|
|
|
"url" : "https://chromium.googlesource.com/v8/v8.git",
|
|
|
|
"deps_file" : "DEPS",
|
|
|
|
"managed" : False,
|
|
|
|
"custom_deps" : {
|
|
|
|
# These deps are already part of Node.js.
|
2018-04-06 12:16:11 +00:00
|
|
|
"v8/base/trace_event/common" : None,
|
|
|
|
"v8/third_party/googletest/src" : None,
|
2017-12-18 09:19:46 +00:00
|
|
|
# These deps are unnecessary for building.
|
|
|
|
"v8/test/benchmarks/data" : None,
|
|
|
|
"v8/testing/gmock" : None,
|
|
|
|
"v8/test/mozilla/data" : None,
|
|
|
|
"v8/test/test262/data" : None,
|
|
|
|
"v8/test/test262/harness" : None,
|
2018-09-04 08:32:13 +00:00
|
|
|
"v8/third_party/android_ndk" : None,
|
2019-03-20 23:17:36 +00:00
|
|
|
"v8/third_party/android_sdk" : None,
|
2018-10-04 07:43:23 +00:00
|
|
|
"v8/third_party/catapult" : None,
|
2017-12-18 09:19:46 +00:00
|
|
|
"v8/third_party/colorama/src" : None,
|
2018-09-04 08:32:13 +00:00
|
|
|
"v8/third_party/fuchsia-sdk" : None,
|
2017-12-18 09:19:46 +00:00
|
|
|
"v8/third_party/instrumented_libraries" : None,
|
|
|
|
"v8/tools/luci-go" : None,
|
|
|
|
"v8/tools/swarming_client" : None,
|
2018-09-04 08:32:13 +00:00
|
|
|
"v8/third_party/qemu-linux-x64" : None,
|
2017-12-18 09:19:46 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
def EnsureGit(v8_path):
|
2018-04-19 13:42:55 +00:00
|
|
|
def git(args):
|
|
|
|
# shell=True needed on Windows to resolve git.bat.
|
|
|
|
return subprocess.check_output(
|
|
|
|
"git " + args, cwd=v8_path, shell=True).strip()
|
|
|
|
|
2017-12-18 09:19:46 +00:00
|
|
|
expected_git_dir = os.path.join(v8_path, ".git")
|
2018-04-19 13:42:55 +00:00
|
|
|
actual_git_dir = git("rev-parse --absolute-git-dir")
|
2017-12-18 09:19:46 +00:00
|
|
|
if expected_git_dir == actual_git_dir:
|
2019-02-19 08:28:26 +00:00
|
|
|
print("V8 is tracked stand-alone by git.")
|
2017-12-18 09:19:46 +00:00
|
|
|
return False
|
2019-02-19 08:28:26 +00:00
|
|
|
print("Initializing temporary git repository in v8.")
|
2018-04-19 13:42:55 +00:00
|
|
|
git("init")
|
|
|
|
git("config user.name \"Ada Lovelace\"")
|
|
|
|
git("config user.email ada@lovela.ce")
|
|
|
|
git("commit --allow-empty -m init")
|
2017-12-18 09:19:46 +00:00
|
|
|
return True
|
|
|
|
|
2018-01-12 08:57:41 +00:00
|
|
|
def FetchDeps(v8_path):
|
|
|
|
# Verify path.
|
|
|
|
v8_path = os.path.abspath(v8_path)
|
|
|
|
assert os.path.isdir(v8_path)
|
|
|
|
|
|
|
|
# Check out depot_tools if necessary.
|
|
|
|
depot_tools = node_common.EnsureDepotTools(v8_path, True)
|
|
|
|
|
2017-12-18 09:19:46 +00:00
|
|
|
temporary_git = EnsureGit(v8_path)
|
|
|
|
try:
|
2019-02-19 08:28:26 +00:00
|
|
|
print("Fetching dependencies.")
|
2018-01-05 22:06:26 +00:00
|
|
|
env = os.environ.copy()
|
|
|
|
# gclient needs to have depot_tools in the PATH.
|
|
|
|
env["PATH"] = depot_tools + os.pathsep + env["PATH"]
|
2018-04-05 14:03:46 +00:00
|
|
|
gclient = os.path.join(depot_tools, "gclient.py")
|
2017-12-18 09:19:46 +00:00
|
|
|
spec = "solutions = %s" % GCLIENT_SOLUTION
|
2018-04-05 14:03:46 +00:00
|
|
|
subprocess.check_call([sys.executable, gclient, "sync", "--spec", spec],
|
|
|
|
cwd=os.path.join(v8_path, os.path.pardir),
|
|
|
|
env=env)
|
2017-12-18 09:19:46 +00:00
|
|
|
except:
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
if temporary_git:
|
|
|
|
node_common.UninitGit(v8_path)
|
2018-01-12 08:57:41 +00:00
|
|
|
# Clean up .gclient_entries file.
|
2018-01-12 12:21:11 +00:00
|
|
|
gclient_entries = os.path.normpath(
|
|
|
|
os.path.join(v8_path, os.pardir, ".gclient_entries"))
|
2018-01-12 08:57:41 +00:00
|
|
|
if os.path.isfile(gclient_entries):
|
|
|
|
os.remove(gclient_entries)
|
2018-04-24 14:10:46 +00:00
|
|
|
|
|
|
|
return depot_tools
|
2017-12-18 09:19:46 +00:00
|
|
|
|
2018-01-16 10:02:14 +00:00
|
|
|
|
2017-12-18 09:19:46 +00:00
|
|
|
if __name__ == "__main__":
|
2018-01-12 08:57:41 +00:00
|
|
|
FetchDeps(sys.argv[1])
|