OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 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 """This script will check out llvm and clang, and then package the results up | 6 """This script will check out llvm and clang, and then package the results up |
7 to a tgz file.""" | 7 to a tgz file.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import fnmatch | 10 import fnmatch |
11 import itertools | 11 import itertools |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import subprocess | 14 import subprocess |
15 import sys | 15 import sys |
16 import tarfile | 16 import tarfile |
17 | 17 |
18 # Path constants. | 18 # Path constants. |
19 THIS_DIR = os.path.dirname(__file__) | 19 THIS_DIR = os.path.dirname(__file__) |
20 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) | 20 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) |
21 THIRD_PARTY_DIR = os.path.join(THIS_DIR, '..', '..', '..', 'third_party') | 21 THIRD_PARTY_DIR = os.path.join(THIS_DIR, '..', '..', '..', 'third_party') |
22 LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm') | 22 LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm') |
23 LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap') | 23 LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap') |
24 LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR, | 24 LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR, |
25 'llvm-bootstrap-install') | 25 'llvm-bootstrap-install') |
26 LLVM_BUILD_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-build') | 26 LLVM_BUILD_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-build') |
27 LLVM_RELEASE_DIR = os.path.join(LLVM_BUILD_DIR, 'Release+Asserts') | 27 |
| 28 if sys.platform == 'win32': |
| 29 LLVM_RELEASE_DIR = os.path.join(LLVM_BUILD_DIR, 'Release+Asserts', 'tools', |
| 30 'clang', 'stage2-bins') |
| 31 else: |
| 32 LLVM_RELEASE_DIR = os.path.join(LLVM_BUILD_DIR, 'Release+Asserts', 'tools', |
| 33 'clang', 'stage2-instrumented-bins', 'tools', |
| 34 'clang', 'stage2-bins') |
28 LLVM_LTO_GOLD_PLUGIN_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-lto-gold-plugin') | 35 LLVM_LTO_GOLD_PLUGIN_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-lto-gold-plugin') |
29 BINUTILS_LIB_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils', 'Linux_x64', | 36 BINUTILS_LIB_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils', 'Linux_x64', |
30 'Release', 'lib') | 37 'Release', 'lib') |
31 STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') | 38 STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') |
32 | 39 |
33 | 40 |
34 def Tee(output, logfile): | 41 def Tee(output, logfile): |
35 logfile.write(output) | 42 logfile.write(output) |
36 print output, | 43 print output, |
37 | 44 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'libcxx')], | 228 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'libcxx')], |
222 log, fail_hard=False) | 229 log, fail_hard=False) |
223 | 230 |
224 Tee('Starting build\n', log) | 231 Tee('Starting build\n', log) |
225 | 232 |
226 # Do a clobber build. | 233 # Do a clobber build. |
227 shutil.rmtree(LLVM_BOOTSTRAP_DIR, ignore_errors=True) | 234 shutil.rmtree(LLVM_BOOTSTRAP_DIR, ignore_errors=True) |
228 shutil.rmtree(LLVM_BOOTSTRAP_INSTALL_DIR, ignore_errors=True) | 235 shutil.rmtree(LLVM_BOOTSTRAP_INSTALL_DIR, ignore_errors=True) |
229 shutil.rmtree(LLVM_BUILD_DIR, ignore_errors=True) | 236 shutil.rmtree(LLVM_BUILD_DIR, ignore_errors=True) |
230 | 237 |
231 opt_flags = [] | 238 opt_flags = ['--bootstrap' if sys.platform == 'win32' else '--enable-pgo'] |
232 if sys.platform.startswith('linux'): | 239 if sys.platform.startswith('linux'): |
233 opt_flags += ['--lto-gold-plugin'] | 240 opt_flags += ['--lto-gold-plugin'] |
| 241 |
234 build_cmd = [sys.executable, os.path.join(THIS_DIR, 'update.py'), | 242 build_cmd = [sys.executable, os.path.join(THIS_DIR, 'update.py'), |
235 '--bootstrap', '--force-local-build', | 243 '--force-local-build', '--run-tests'] + opt_flags |
236 '--run-tests'] + opt_flags | |
237 TeeCmd(build_cmd, log) | 244 TeeCmd(build_cmd, log) |
238 | 245 |
239 stamp = open(STAMP_FILE).read().rstrip() | 246 stamp = open(STAMP_FILE).read().rstrip() |
240 if stamp != expected_stamp: | 247 if stamp != expected_stamp: |
241 print 'Actual stamp (%s) != expected stamp (%s).' % (stamp, expected_stamp) | 248 print 'Actual stamp (%s) != expected stamp (%s).' % (stamp, expected_stamp) |
242 return 1 | 249 return 1 |
243 | 250 |
244 shutil.rmtree(pdir, ignore_errors=True) | 251 shutil.rmtree(pdir, ignore_errors=True) |
245 | 252 |
246 # Copy a whitelist of files to the directory we're going to tar up. | 253 # Copy a whitelist of files to the directory we're going to tar up. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 # Set up symlinks. | 321 # Set up symlinks. |
315 if sys.platform != 'win32': | 322 if sys.platform != 'win32': |
316 os.symlink('clang', os.path.join(pdir, 'bin', 'clang++')) | 323 os.symlink('clang', os.path.join(pdir, 'bin', 'clang++')) |
317 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) | 324 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) |
318 | 325 |
319 if sys.platform.startswith('linux'): | 326 if sys.platform.startswith('linux'): |
320 os.symlink('lld', os.path.join(pdir, 'bin', 'ld.lld')) | 327 os.symlink('lld', os.path.join(pdir, 'bin', 'ld.lld')) |
321 | 328 |
322 # Copy libc++ headers. | 329 # Copy libc++ headers. |
323 if sys.platform == 'darwin': | 330 if sys.platform == 'darwin': |
324 shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), | 331 shutil.copytree(os.path.join(LLVM_RELEASE_DIR, 'include', 'c++'), |
325 os.path.join(pdir, 'include', 'c++')) | 332 os.path.join(pdir, 'include', 'c++')) |
326 | 333 |
327 # Copy tcmalloc from the binutils package. | 334 # Copy tcmalloc from the binutils package. |
328 # FIXME: We should eventually be building our own copy. | 335 # FIXME: We should eventually be building our own copy. |
329 if sys.platform.startswith('linux'): | 336 if sys.platform.startswith('linux'): |
330 shutil.copy(os.path.join(BINUTILS_LIB_DIR, 'libtcmalloc_minimal.so.4'), | 337 shutil.copy(os.path.join(BINUTILS_LIB_DIR, 'libtcmalloc_minimal.so.4'), |
331 os.path.join(pdir, 'lib')) | 338 os.path.join(pdir, 'lib')) |
332 | 339 |
333 # Copy buildlog over. | 340 # Copy buildlog over. |
334 shutil.copy('buildlog.txt', pdir) | 341 shutil.copy('buildlog.txt', pdir) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 MaybeUpload(args, objdumpdir, platform) | 373 MaybeUpload(args, objdumpdir, platform) |
367 | 374 |
368 if sys.platform == 'win32' and args.upload: | 375 if sys.platform == 'win32' and args.upload: |
369 UploadPDBToSymbolServer() | 376 UploadPDBToSymbolServer() |
370 | 377 |
371 # FIXME: Warn if the file already exists on the server. | 378 # FIXME: Warn if the file already exists on the server. |
372 | 379 |
373 | 380 |
374 if __name__ == '__main__': | 381 if __name__ == '__main__': |
375 sys.exit(main()) | 382 sys.exit(main()) |
OLD | NEW |