Commit 17ccae2c authored by Hans Wennborg's avatar Hans Wennborg Committed by Commit Bot

Clang build.py: Nuke the source dir if there is a local diff

Bug: 1014241
Change-Id: I6a3a6c93e93db1ed693c001b9297da5e46cacbce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862394
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705927}
parent 9a87ded4
...@@ -28,7 +28,6 @@ from update import (CDS_URL, CHROMIUM_DIR, CLANG_REVISION, LLVM_BUILD_DIR, ...@@ -28,7 +28,6 @@ from update import (CDS_URL, CHROMIUM_DIR, CLANG_REVISION, LLVM_BUILD_DIR,
DownloadAndUnpack, EnsureDirExists, GetWinSDKDir, DownloadAndUnpack, EnsureDirExists, GetWinSDKDir,
ReadStampFile, RmTree, WriteStampFile) ReadStampFile, RmTree, WriteStampFile)
# Path constants. (All of these should be absolute paths.) # Path constants. (All of these should be absolute paths.)
THIRD_PARTY_DIR = os.path.join(CHROMIUM_DIR, 'third_party') THIRD_PARTY_DIR = os.path.join(CHROMIUM_DIR, 'third_party')
LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm') LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm')
...@@ -100,31 +99,31 @@ def CheckoutLLVM(commit, dir): ...@@ -100,31 +99,31 @@ def CheckoutLLVM(commit, dir):
modifications in dir will be lost.""" modifications in dir will be lost."""
print('Checking out LLVM monorepo %s into %s' % (commit, dir)) print('Checking out LLVM monorepo %s into %s' % (commit, dir))
git_dir = os.path.join(dir, '.git')
fetch_cmd = ['git', '--git-dir', git_dir, 'fetch']
checkout_cmd = ['git', 'checkout', commit]
# Do a somewhat shallow clone to save on bandwidth for GitHub and for us.
# The depth was whosen to be deep enough to contain the version we're
# building, and shallow enough to save significantly on bandwidth compared to
# a full clone.
clone_cmd = ['git', 'clone', '--depth', '10000',
'https://github.com/llvm/llvm-project/', dir]
# Try updating the current repo. # Try updating the current repo if it exists and has no local diff.
if RunCommand(fetch_cmd, fail_hard=False): if os.path.isdir(dir):
os.chdir(dir) os.chdir(dir)
if RunCommand(checkout_cmd, fail_hard=False): # git diff-index --quiet returns success when there is no diff.
if (RunCommand(['git', 'diff-index', '--quiet', 'HEAD'], fail_hard=False)
and RunCommand(['git', 'fetch'], fail_hard=False)
and RunCommand(['git', 'checkout', commit], fail_hard=False)):
return return
# Otherwise, do a fresh clone. # If we can't use the current repo, delete it.
if os.path.isdir(dir):
os.chdir(CHROMIUM_DIR) # Can't remove dir if we're in it. os.chdir(CHROMIUM_DIR) # Can't remove dir if we're in it.
print('Removing %s.' % dir) print('Removing %s.' % dir)
RmTree(dir) RmTree(dir)
# Do a somewhat shallow clone to save on bandwidth for GitHub and for us.
# The depth was chosen to be deep enough to contain the version we're
# building, and shallow enough to save significantly on bandwidth compared to
# a full clone.
clone_cmd = ['git', 'clone', '--depth', '10000',
'https://github.com/llvm/llvm-project/', dir]
if RunCommand(clone_cmd, fail_hard=False): if RunCommand(clone_cmd, fail_hard=False):
os.chdir(dir) os.chdir(dir)
if RunCommand(checkout_cmd, fail_hard=False): if RunCommand(['git', 'checkout', commit], fail_hard=False):
return return
print('CheckoutLLVM failed.') print('CheckoutLLVM failed.')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment