OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Windows can't run .sh files, so this is a Python implementation of | 6 """Windows can't run .sh files, so this is a Python implementation of |
7 update.sh. This script should replace update.sh on all platforms eventually.""" | 7 update.sh. This script should replace update.sh on all platforms eventually.""" |
8 | 8 |
9 import os | 9 import os |
10 import re | 10 import re |
11 import shutil | 11 import shutil |
12 import subprocess | 12 import subprocess |
13 import sys | 13 import sys |
14 | 14 |
15 # Do NOT CHANGE this if you don't know what you're doing -- see | 15 # Do NOT CHANGE this if you don't know what you're doing -- see |
16 # https://code.google.com/p/chromium/wiki/UpdatingClang | 16 # https://code.google.com/p/chromium/wiki/UpdatingClang |
17 # Reverting problematic clang rolls is safe, though. | 17 # Reverting problematic clang rolls is safe, though. |
18 # Note: this revision is only used for Windows. Other platforms use update.sh. | 18 # Note: this revision is only used for Windows. Other platforms use update.sh. |
19 LLVM_WIN_REVISION = 'HEAD' | 19 LLVM_WIN_REVISION = 'HEAD' |
20 | 20 |
21 # ASan on Windows is useful enough to use it even while the clang/win is still | 21 # ASan on Windows is useful enough to use it even while the clang/win is still |
22 # in bringup. Use a pinned revision to make it slightly more stable. | 22 # in bringup. Use a pinned revision to make it slightly more stable. |
23 if (re.search(r'\b(asan)=1', os.environ.get('GYP_DEFINES', '')) and | 23 if (re.search(r'\b(asan)=1', os.environ.get('GYP_DEFINES', '')) and |
24 not 'LLVM_FORCE_HEAD_REVISION' in os.environ): | 24 not 'LLVM_FORCE_HEAD_REVISION' in os.environ): |
25 LLVM_WIN_REVISION = '217738' | 25 LLVM_WIN_REVISION = '217738' |
26 LLVM_WIN_REVISION = '217738' | |
dcheng
2014/11/11 23:36:10
I temporarily pinned the revision when I was build
| |
26 | 27 |
27 # Path constants. (All of these should be absolute paths.) | 28 # Path constants. (All of these should be absolute paths.) |
28 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 29 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
29 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) | 30 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) |
30 LLVM_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm') | 31 LLVM_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm') |
31 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', | 32 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', |
32 'Release+Asserts') | 33 'Release+Asserts') |
33 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') | 34 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') |
34 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') | 35 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') |
35 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') | 36 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') |
(...skipping 28 matching lines...) Expand all Loading... | |
64 for root, _, files in os.walk(dir): | 65 for root, _, files in os.walk(dir): |
65 for f in files: | 66 for f in files: |
66 if regex.match(f): | 67 if regex.match(f): |
67 os.remove(os.path.join(root, f)) | 68 os.remove(os.path.join(root, f)) |
68 n += 1 | 69 n += 1 |
69 return n | 70 return n |
70 | 71 |
71 | 72 |
72 def ClobberChromiumBuildFiles(): | 73 def ClobberChromiumBuildFiles(): |
73 """Clobber Chomium build files.""" | 74 """Clobber Chomium build files.""" |
75 return | |
dcheng
2014/11/11 23:36:10
Rebuilds were getting really long =(
| |
74 print 'Clobbering Chromium build files...' | 76 print 'Clobbering Chromium build files...' |
75 out_dir = os.path.join(CHROMIUM_DIR, 'out') | 77 out_dir = os.path.join(CHROMIUM_DIR, 'out') |
76 if os.path.isdir(out_dir): | 78 if os.path.isdir(out_dir): |
77 shutil.rmtree(out_dir) | 79 shutil.rmtree(out_dir) |
78 print 'Removed Chromium out dir: %s.' % (out_dir) | 80 print 'Removed Chromium out dir: %s.' % (out_dir) |
79 | 81 |
80 | 82 |
81 def RunCommand(command, tries=1): | 83 def RunCommand(command, tries=1): |
82 """Run a command, possibly with multiple retries.""" | 84 """Run a command, possibly with multiple retries.""" |
83 for i in range(0, tries): | 85 for i in range(0, tries): |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 candidate = os.path.join(path, 'svn' + ext) | 164 candidate = os.path.join(path, 'svn' + ext) |
163 if os.path.isfile(candidate): | 165 if os.path.isfile(candidate): |
164 return '-DSubversion_SVN_EXECUTABLE=%s' % candidate | 166 return '-DSubversion_SVN_EXECUTABLE=%s' % candidate |
165 return '' | 167 return '' |
166 | 168 |
167 | 169 |
168 def UpdateClang(): | 170 def UpdateClang(): |
169 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) | 171 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) |
170 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: | 172 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: |
171 print 'Already up to date.' | 173 print 'Already up to date.' |
172 return 0 | 174 # return 0 |
173 | 175 |
174 AddCMakeToPath() | 176 AddCMakeToPath() |
175 ClobberChromiumBuildFiles() | 177 ClobberChromiumBuildFiles() |
176 | 178 |
177 # Reset the stamp file in case the build is unsuccessful. | 179 # Reset the stamp file in case the build is unsuccessful. |
178 WriteStampFile('') | 180 WriteStampFile('') |
179 | 181 |
180 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) | 182 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) |
181 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) | 183 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) |
182 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) | 184 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) |
183 | 185 |
184 if not os.path.exists(LLVM_BUILD_DIR): | 186 if not os.path.exists(LLVM_BUILD_DIR): |
185 os.makedirs(LLVM_BUILD_DIR) | 187 os.makedirs(LLVM_BUILD_DIR) |
186 os.chdir(LLVM_BUILD_DIR) | 188 os.chdir(LLVM_BUILD_DIR) |
187 | 189 |
188 RunCommand(GetVSVersion().SetupScript('x64') + | 190 RunCommand(GetVSVersion().SetupScript('x64') + |
189 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', | 191 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', |
192 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'c lang'), | |
193 '-DCHROMIUM_TOOLS=rewrite_scoped_refptr', | |
190 '-DLLVM_ENABLE_ASSERTIONS=ON', SubversionCmakeArg(), LLVM_DIR]) | 194 '-DLLVM_ENABLE_ASSERTIONS=ON', SubversionCmakeArg(), LLVM_DIR]) |
191 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) | 195 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) |
192 | 196 |
197 WriteStampFile(LLVM_WIN_REVISION) | |
dcheng
2014/11/11 23:36:10
The small CMakeLists.txt shim in third_party/llvm/
| |
198 print 'Clang update was successful.' | |
199 return 0 | |
200 | |
193 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. | 201 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. |
194 # TODO(hans): Remove once the regular build above produces this. | 202 # TODO(hans): Remove once the regular build above produces this. |
195 if not os.path.exists(COMPILER_RT_BUILD_DIR): | 203 if not os.path.exists(COMPILER_RT_BUILD_DIR): |
196 os.makedirs(COMPILER_RT_BUILD_DIR) | 204 os.makedirs(COMPILER_RT_BUILD_DIR) |
197 os.chdir(COMPILER_RT_BUILD_DIR) | 205 os.chdir(COMPILER_RT_BUILD_DIR) |
198 RunCommand(GetVSVersion().SetupScript('x86') + | 206 RunCommand(GetVSVersion().SetupScript('x86') + |
199 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', | 207 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', |
200 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) | 208 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) |
201 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) | 209 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) |
202 | 210 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 | 267 |
260 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): | 268 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): |
261 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' | 269 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' |
262 return 0 | 270 return 0 |
263 | 271 |
264 return UpdateClang() | 272 return UpdateClang() |
265 | 273 |
266 | 274 |
267 if __name__ == '__main__': | 275 if __name__ == '__main__': |
268 sys.exit(main()) | 276 sys.exit(main()) |
OLD | NEW |