v8/tools/node/node_common.py
Andrew Grieve 58253865d8 Node: Fix FetchDeps() being able to find git.bat on Windows
This is relevent for when the only "git" in your PATH is git.bat (from
depot_tools). I'd guess this is pretty common for Googlers.

Bug: v8:5960
Change-Id: I35bc49c6054afed20481ed408cfd02b7a4c346c8
Reviewed-on: https://chromium-review.googlesource.com/1019340
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52698}
2018-04-19 19:00:25 +00:00

47 lines
1.4 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 pipes
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.py")
if os.path.isfile(gclient_path):
return depot_tools
except:
pass
if fetch_if_not_exist:
print "Checking out depot_tools."
# shell=True needed on Windows to resolve git.bat.
subprocess.check_call("git clone {} {}".format(
pipes.quote(DEPOT_TOOLS_URL),
pipes.quote(depot_tools)), shell=True)
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)