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 LLVM_RELEASE_DIR = os.path.join(LLVM_BUILD_DIR, 'Release+Asserts') |
28 LLVM_LTO_GOLD_PLUGIN_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-lto-gold-plugin') | 28 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', |
| 30 'Release', 'lib') |
29 STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') | 31 STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') |
30 | 32 |
31 | 33 |
32 def Tee(output, logfile): | 34 def Tee(output, logfile): |
33 logfile.write(output) | 35 logfile.write(output) |
34 print output, | 36 print output, |
35 | 37 |
36 | 38 |
37 def TeeCmd(cmd, logfile, fail_hard=True): | 39 def TeeCmd(cmd, logfile, fail_hard=True): |
38 """Runs cmd and writes the output to both stdout and logfile.""" | 40 """Runs cmd and writes the output to both stdout and logfile.""" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) | 317 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) |
316 | 318 |
317 if sys.platform.startswith('linux'): | 319 if sys.platform.startswith('linux'): |
318 os.symlink('lld', os.path.join(pdir, 'bin', 'ld.lld')) | 320 os.symlink('lld', os.path.join(pdir, 'bin', 'ld.lld')) |
319 | 321 |
320 # Copy libc++ headers. | 322 # Copy libc++ headers. |
321 if sys.platform == 'darwin': | 323 if sys.platform == 'darwin': |
322 shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), | 324 shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), |
323 os.path.join(pdir, 'include', 'c++')) | 325 os.path.join(pdir, 'include', 'c++')) |
324 | 326 |
| 327 # Copy tcmalloc from the binutils package. |
| 328 # FIXME: We should eventually be building our own copy. |
| 329 if sys.platform.startswith('linux'): |
| 330 shutil.copy(os.path.join(BINUTILS_LIB_DIR, 'libtcmalloc_minimal.so.4'), |
| 331 os.path.join(pdir, 'lib')) |
| 332 |
325 # Copy buildlog over. | 333 # Copy buildlog over. |
326 shutil.copy('buildlog.txt', pdir) | 334 shutil.copy('buildlog.txt', pdir) |
327 | 335 |
328 # Create archive. | 336 # Create archive. |
329 tar_entries = ['bin', 'lib', 'buildlog.txt'] | 337 tar_entries = ['bin', 'lib', 'buildlog.txt'] |
330 if sys.platform == 'darwin': | 338 if sys.platform == 'darwin': |
331 tar_entries += ['include'] | 339 tar_entries += ['include'] |
332 with tarfile.open(pdir + '.tgz', 'w:gz') as tar: | 340 with tarfile.open(pdir + '.tgz', 'w:gz') as tar: |
333 for entry in tar_entries: | 341 for entry in tar_entries: |
334 tar.add(os.path.join(pdir, entry), arcname=entry, filter=PrintTarProgress) | 342 tar.add(os.path.join(pdir, entry), arcname=entry, filter=PrintTarProgress) |
(...skipping 23 matching lines...) Expand all Loading... |
358 MaybeUpload(args, objdumpdir, platform) | 366 MaybeUpload(args, objdumpdir, platform) |
359 | 367 |
360 if sys.platform == 'win32' and args.upload: | 368 if sys.platform == 'win32' and args.upload: |
361 UploadPDBToSymbolServer() | 369 UploadPDBToSymbolServer() |
362 | 370 |
363 # FIXME: Warn if the file already exists on the server. | 371 # FIXME: Warn if the file already exists on the server. |
364 | 372 |
365 | 373 |
366 if __name__ == '__main__': | 374 if __name__ == '__main__': |
367 sys.exit(main()) | 375 sys.exit(main()) |
OLD | NEW |