Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: tools/clang/scripts/update.py

Issue 737943002: Update from https://crrev.com/304715 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/clang/scripts/package.sh ('k') | tools/valgrind/chrome_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/scripts/update.py
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
index 25aa5a50ee1cc646a2985927974e126b151fa706..041087f68731db3350a77e9b513718ee3f7de281 100755
--- a/tools/clang/scripts/update.py
+++ b/tools/clang/scripts/update.py
@@ -10,7 +10,9 @@ import os
import re
import shutil
import subprocess
+import stat
import sys
+import time
# Do NOT CHANGE this if you don't know what you're doing -- see
# https://code.google.com/p/chromium/wiki/UpdatingClang
@@ -58,16 +60,16 @@ def WriteStampFile(s):
f.write(s)
-def DeleteFiles(dir, pattern):
- """Delete all files in dir matching pattern."""
- n = 0
- regex = re.compile(r'^' + pattern + r'$')
- for root, _, files in os.walk(dir):
- for f in files:
- if regex.match(f):
- os.remove(os.path.join(root, f))
- n += 1
- return n
+def RmTree(dir):
+ """Delete dir."""
+ def ChmodAndRetry(func, path, _):
+ # Subversion can leave read-only files around.
+ if not os.access(path, os.W_OK):
+ os.chmod(path, stat.S_IWUSR)
+ return func(path)
+ raise
+
+ shutil.rmtree(dir, onerror=ChmodAndRetry)
def ClobberChromiumBuildFiles():
@@ -75,18 +77,21 @@ def ClobberChromiumBuildFiles():
print 'Clobbering Chromium build files...'
out_dir = os.path.join(CHROMIUM_DIR, 'out')
if os.path.isdir(out_dir):
- shutil.rmtree(out_dir)
+ RmTree(out_dir)
print 'Removed Chromium out dir: %s.' % (out_dir)
-def RunCommand(command, tries=1):
- """Run a command, possibly with multiple retries."""
- for i in range(0, tries):
- print 'Running %s (try #%d)' % (str(command), i + 1)
- if subprocess.call(command, shell=True) == 0:
- return
- print 'Failed.'
- sys.exit(1)
+def RunCommand(command, fail_hard=True):
+ """Run command and return success (True) or failure; or if fail_hard is
+ True, exit on failure."""
+
+ print 'Running %s' % (str(command))
+ if subprocess.call(command, shell=True) == 0:
+ return True
+ print 'Failed.'
+ if fail_hard:
+ sys.exit(1)
+ return False
def CopyFile(src, dst):
@@ -110,8 +115,17 @@ def CopyDirectoryContents(src, dst, filename_filter=None):
def Checkout(name, url, dir):
"""Checkout the SVN module at url into dir. Use name for the log message."""
print "Checking out %s r%s into '%s'" % (name, LLVM_WIN_REVISION, dir)
- RunCommand(['svn', 'checkout', '--force',
- url + '@' + LLVM_WIN_REVISION, dir], tries=2)
+
+ command = ['svn', 'checkout', '--force', url + '@' + LLVM_WIN_REVISION, dir]
+ if RunCommand(command, fail_hard=False):
+ return
+
+ if os.path.isdir(dir):
+ print "Removing %s." % (dir)
+ RmTree(dir)
+
+ print "Retrying."
+ RunCommand(command)
def AddCMakeToPath():
« no previous file with comments | « tools/clang/scripts/package.sh ('k') | tools/valgrind/chrome_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698