v8/tools/node/node_common.py
Yang Guo 952cfd58fd [node] scripts to fetch deps and build monolithic .a for node.
Once this CL lands and is included in Node.js, we can
- run `tools/node/fetch_deps.py <v8_path>` to fetch necessary deps.
- run `tools/node/build_gn.py <build mode> <v8_path> <out_dir>` to build.
- use new v8_monolith target in v8.gyp to call build_gn.py.

R=machenbach@chromium.org

Bug: v8:6105
Change-Id: I482bfddb40f77df62394a913335bd43627cc0c43
Reviewed-on: https://chromium-review.googlesource.com/792944
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50152}
2017-12-18 09:57:28 +00:00

44 lines
1.3 KiB
Python
Executable File

#!/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.
import os
import shutil
import stat
import subprocess
DEPOT_TOOLS_URL = \
"https://chromium.googlesource.com/chromium/tools/depot_tools.git"
def EnsureDepotTools(v8_path, fetch_if_not_exist):
def _Get(v8_path):
depot_tools = os.path.join(v8_path, "_depot_tools")
try:
gclient_path = os.path.join(depot_tools, "gclient")
gclient_check = subprocess.check_output([gclient_path, "--version"])
if "gclient.py" in gclient_check:
return depot_tools
except:
pass
if fetch_if_not_exist:
print "Checking out depot_tools."
subprocess.check_call(["git", "clone", DEPOT_TOOLS_URL, depot_tools])
return depot_tools
return None
depot_tools = _Get(v8_path)
assert depot_tools is not None
print "Using depot tools in %s" % depot_tools
return depot_tools
def UninitGit(v8_path):
print "Uninitializing temporary git repository"
target = os.path.join(v8_path, ".git")
if os.path.isdir(target):
print ">> Cleaning up %s" % target
def OnRmError(func, path, exec_info):
# This might happen on Windows
os.chmod(path, stat.S_IWRITE)
os.unlink(path)
shutil.rmtree(target, onerror=OnRmError)