Skip to content

Commit 0673ede

Browse files
committed
tools: take ownership of deps/v8/tools/node
The files are not maintained nor used upstream anymore. PR-URL: #39222 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3ed0499 commit 0673ede

File tree

4 files changed

+157
-2
lines changed

4 files changed

+157
-2
lines changed

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ tools/*/*.i.tmp
133133
/deps/uv/.github/
134134
/deps/uv/docs/code/
135135
/deps/uv/docs/src/guide/
136-
# Ignore dependencies fetched by deps/v8/tools/node/fetch_deps.py
136+
# Ignore dependencies fetched by tools/v8/fetch_deps.py
137137
/deps/.cipd
138138

139139
# === Rules for Windows vcbuild.bat ===

‎tools/make-v8.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ V8_BUILD_OPTIONS=$2
77

88
cd deps/v8 ||exit
99
find . -type d -name .git -print0 | xargs -0 rm -rf
10-
tools/node/fetch_deps.py .
10+
../../tools/v8/fetch_deps.py .
1111

1212
ARCH="`arch`"
1313
if [ "$ARCH"="s390x" ] || [ "$ARCH"="ppc64le" ];then

‎tools/v8/fetch_deps.py‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env python
2+
# Copyright 2017 the V8 project authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
"""
7+
Use this script to fetch all dependencies for V8 to run build_gn.py.
8+
9+
Usage: fetch_deps.py <v8-path>
10+
"""
11+
12+
# for py2/py3 compatibility
13+
from __future__ importprint_function
14+
15+
importos
16+
importsubprocess
17+
importsys
18+
19+
importnode_common
20+
21+
GCLIENT_SOLUTION= [
22+
{"name" : "v8",
23+
"url" : "https://chromium.googlesource.com/v8/v8.git",
24+
"deps_file" : "DEPS",
25+
"managed" : False,
26+
"custom_deps" :{
27+
# These deps are already part of Node.js.
28+
"v8/base/trace_event/common" : None,
29+
"v8/third_party/googletest/src" : None,
30+
# These deps are unnecessary for building.
31+
"v8/test/benchmarks/data" : None,
32+
"v8/testing/gmock" : None,
33+
"v8/test/mozilla/data" : None,
34+
"v8/test/test262/data" : None,
35+
"v8/test/test262/harness" : None,
36+
"v8/third_party/android_ndk" : None,
37+
"v8/third_party/android_sdk" : None,
38+
"v8/third_party/catapult" : None,
39+
"v8/third_party/colorama/src" : None,
40+
"v8/third_party/fuchsia-sdk" : None,
41+
"v8/third_party/instrumented_libraries" : None,
42+
"v8/tools/luci-go" : None,
43+
"v8/tools/swarming_client" : None,
44+
"v8/third_party/qemu-linux-x64" : None,
45+
},
46+
},
47+
]
48+
49+
defEnsureGit(v8_path):
50+
defgit(args):
51+
# shell=True needed on Windows to resolve git.bat.
52+
returnsubprocess.check_output(
53+
"git "+args, cwd=v8_path, shell=True).strip()
54+
55+
expected_git_dir=os.path.join(v8_path, ".git")
56+
actual_git_dir=git("rev-parse --absolute-git-dir")
57+
ifexpected_git_dir==actual_git_dir:
58+
print("V8 is tracked stand-alone by git.")
59+
returnFalse
60+
print("Initializing temporary git repository in v8.")
61+
git("init")
62+
git("config user.name \"Ada Lovelace\"")
63+
git("config user.email [email protected]")
64+
git("commit --allow-empty -m init")
65+
returnTrue
66+
67+
defFetchDeps(v8_path):
68+
# Verify path.
69+
v8_path=os.path.abspath(v8_path)
70+
assertos.path.isdir(v8_path)
71+
72+
# Check out depot_tools if necessary.
73+
depot_tools=node_common.EnsureDepotTools(v8_path, True)
74+
75+
temporary_git=EnsureGit(v8_path)
76+
try:
77+
print("Fetching dependencies.")
78+
env=os.environ.copy()
79+
# gclient needs to have depot_tools in the PATH.
80+
env["PATH"] =depot_tools+os.pathsep+env["PATH"]
81+
gclient=os.path.join(depot_tools, "gclient.py")
82+
spec="solutions = %s"%GCLIENT_SOLUTION
83+
subprocess.check_call([sys.executable, gclient, "sync", "--spec", spec],
84+
cwd=os.path.join(v8_path, os.path.pardir),
85+
env=env)
86+
except:
87+
raise
88+
finally:
89+
iftemporary_git:
90+
node_common.UninitGit(v8_path)
91+
# Clean up .gclient_entries file.
92+
gclient_entries=os.path.normpath(
93+
os.path.join(v8_path, os.pardir, ".gclient_entries"))
94+
ifos.path.isfile(gclient_entries):
95+
os.remove(gclient_entries)
96+
97+
returndepot_tools
98+
99+
100+
if__name__=="__main__":
101+
FetchDeps(sys.argv[1])

‎tools/v8/node_common.py‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
# Copyright 2017 the V8 project authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# for py2/py3 compatibility
7+
from __future__ importprint_function
8+
9+
importos
10+
importpipes
11+
importshutil
12+
importstat
13+
importsubprocess
14+
importsys
15+
16+
DEPOT_TOOLS_URL= \
17+
"https://chromium.googlesource.com/chromium/tools/depot_tools.git"
18+
19+
defEnsureDepotTools(v8_path, fetch_if_not_exist):
20+
def_Get(v8_path):
21+
depot_tools=os.path.join(v8_path, "_depot_tools")
22+
try:
23+
gclient_path=os.path.join(depot_tools, "gclient.py")
24+
ifos.path.isfile(gclient_path):
25+
returndepot_tools
26+
except:
27+
pass
28+
iffetch_if_not_exist:
29+
print("Checking out depot_tools.")
30+
# shell=True needed on Windows to resolve git.bat.
31+
subprocess.check_call("git clone{}{}".format(
32+
pipes.quote(DEPOT_TOOLS_URL),
33+
pipes.quote(depot_tools)), shell=True)
34+
# Using check_output to hide warning messages.
35+
subprocess.check_output(
36+
[sys.executable, gclient_path, "metrics", "--opt-out"],
37+
cwd=depot_tools)
38+
returndepot_tools
39+
returnNone
40+
depot_tools=_Get(v8_path)
41+
assertdepot_toolsisnotNone
42+
print("Using depot tools in %s"%depot_tools)
43+
returndepot_tools
44+
45+
defUninitGit(v8_path):
46+
print("Uninitializing temporary git repository")
47+
target=os.path.join(v8_path, ".git")
48+
ifos.path.isdir(target):
49+
print(">> Cleaning up %s"%target)
50+
defOnRmError(func, path, exec_info):
51+
# This might happen on Windows
52+
os.chmod(path, stat.S_IWRITE)
53+
os.unlink(path)
54+
shutil.rmtree(target, onerror=OnRmError)

0 commit comments

Comments
(0)