| 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 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 def main(): | 60 def main(): |
| 61 if sys.platform == 'win32': | 61 if sys.platform == 'win32': |
| 62 try: | 62 try: |
| 63 subprocess.check_output(['grep', '--help'], shell=True) | 63 subprocess.check_output(['grep', '--help'], shell=True) |
| 64 except subprocess.CalledProcessError: | 64 except subprocess.CalledProcessError: |
| 65 print 'Add gnuwin32 to your PATH, then try again.' | 65 print 'Add gnuwin32 to your PATH, then try again.' |
| 66 return 1 | 66 return 1 |
| 67 | 67 |
| 68 parser = argparse.ArgumentParser(description='build and package clang') | 68 parser = argparse.ArgumentParser(description='build and package clang') |
| 69 parser.add_argument('--gcc-toolchain', |
| 70 help="the prefix for the GCC version used for building. " |
| 71 "For /opt/foo/bin/gcc, pass " |
| 72 "'--gcc-toolchain '/opt/foo'") |
| 73 |
| 69 args = parser.parse_args() | 74 args = parser.parse_args() |
| 70 | 75 |
| 71 with open('buildlog.txt', 'w') as log: | 76 with open('buildlog.txt', 'w') as log: |
| 72 Tee('Diff in llvm:\n', log) | 77 Tee('Diff in llvm:\n', log) |
| 73 TeeCmd(['svn', 'stat', LLVM_DIR], log, fail_hard=False) | 78 TeeCmd(['svn', 'stat', LLVM_DIR], log, fail_hard=False) |
| 74 TeeCmd(['svn', 'diff', LLVM_DIR], log, fail_hard=False) | 79 TeeCmd(['svn', 'diff', LLVM_DIR], log, fail_hard=False) |
| 75 Tee('Diff in llvm/tools/clang:\n', log) | 80 Tee('Diff in llvm/tools/clang:\n', log) |
| 76 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'tools', 'clang')], | 81 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'tools', 'clang')], |
| 77 log, fail_hard=False) | 82 log, fail_hard=False) |
| 78 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'tools', 'clang')], | 83 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'tools', 'clang')], |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 | 103 |
| 99 Tee('Starting build\n', log) | 104 Tee('Starting build\n', log) |
| 100 | 105 |
| 101 # Do a clobber build. | 106 # Do a clobber build. |
| 102 shutil.rmtree(LLVM_BOOTSTRAP_DIR, ignore_errors=True) | 107 shutil.rmtree(LLVM_BOOTSTRAP_DIR, ignore_errors=True) |
| 103 shutil.rmtree(LLVM_BOOTSTRAP_INSTALL_DIR, ignore_errors=True) | 108 shutil.rmtree(LLVM_BOOTSTRAP_INSTALL_DIR, ignore_errors=True) |
| 104 shutil.rmtree(LLVM_BUILD_DIR, ignore_errors=True) | 109 shutil.rmtree(LLVM_BUILD_DIR, ignore_errors=True) |
| 105 | 110 |
| 106 build_cmd = [sys.executable, os.path.join(THIS_DIR, 'update.py'), | 111 build_cmd = [sys.executable, os.path.join(THIS_DIR, 'update.py'), |
| 107 '--bootstrap', '--force-local-build', '--run-tests'] | 112 '--bootstrap', '--force-local-build', '--run-tests'] |
| 113 if args.gcc_toolchain is not None: |
| 114 build_cmd.extend(['--gcc-toolchain', args.gcc_toolchain]) |
| 108 TeeCmd(build_cmd, log) | 115 TeeCmd(build_cmd, log) |
| 109 | 116 |
| 110 stamp = open(STAMP_FILE).read().rstrip() | 117 stamp = open(STAMP_FILE).read().rstrip() |
| 111 pdir = 'clang-' + stamp | 118 pdir = 'clang-' + stamp |
| 112 print pdir | 119 print pdir |
| 113 shutil.rmtree(pdir, ignore_errors=True) | 120 shutil.rmtree(pdir, ignore_errors=True) |
| 114 | 121 |
| 115 # Copy a whitelist of files to the directory we're going to tar up. | 122 # Copy a whitelist of files to the directory we're going to tar up. |
| 116 # This supports the same patterns that the fnmatch module understands. | 123 # This supports the same patterns that the fnmatch module understands. |
| 117 exe_ext = '.exe' if sys.platform == 'win32' else '' | 124 exe_ext = '.exe' if sys.platform == 'win32' else '' |
| (...skipping 14 matching lines...) Expand all Loading... |
| 132 ]) | 139 ]) |
| 133 if sys.platform == 'darwin': | 140 if sys.platform == 'darwin': |
| 134 want.extend(['bin/libc++.1.dylib', | 141 want.extend(['bin/libc++.1.dylib', |
| 135 # Copy only the OSX (ASan and profile) and iossim (ASan) | 142 # Copy only the OSX (ASan and profile) and iossim (ASan) |
| 136 # runtime libraries: | 143 # runtime libraries: |
| 137 'lib/clang/*/lib/darwin/*asan_osx*', | 144 'lib/clang/*/lib/darwin/*asan_osx*', |
| 138 'lib/clang/*/lib/darwin/*asan_iossim*', | 145 'lib/clang/*/lib/darwin/*asan_iossim*', |
| 139 'lib/clang/*/lib/darwin/*profile_osx*', | 146 'lib/clang/*/lib/darwin/*profile_osx*', |
| 140 ]) | 147 ]) |
| 141 elif sys.platform.startswith('linux'): | 148 elif sys.platform.startswith('linux'): |
| 142 # Copy the stdlibc++.so.6 we linked Clang against so it can run. | |
| 143 want.append('lib/libstdc++.so.6') | |
| 144 # Copy only | 149 # Copy only |
| 145 # lib/clang/*/lib/linux/libclang_rt.{[atm]san,san,ubsan,profile}-*.a , | 150 # lib/clang/*/lib/linux/libclang_rt.{[atm]san,san,ubsan,profile}-*.a , |
| 146 # but not dfsan. | 151 # but not dfsan. |
| 147 want.extend(['lib/clang/*/lib/linux/*[atm]san*', | 152 want.extend(['lib/clang/*/lib/linux/*[atm]san*', |
| 148 'lib/clang/*/lib/linux/*ubsan*', | 153 'lib/clang/*/lib/linux/*ubsan*', |
| 149 'lib/clang/*/lib/linux/*libclang_rt.san*', | 154 'lib/clang/*/lib/linux/*libclang_rt.san*', |
| 150 'lib/clang/*/lib/linux/*profile*', | 155 'lib/clang/*/lib/linux/*profile*', |
| 151 'lib/clang/*/msan_blacklist.txt', | 156 'lib/clang/*/msan_blacklist.txt', |
| 152 ]) | 157 ]) |
| 153 elif sys.platform == 'win32': | 158 elif sys.platform == 'win32': |
| 154 want.extend(['lib/clang/*/lib/windows/clang_rt.asan*.dll', | 159 want.extend(['lib/clang/*/lib/windows/clang_rt.asan*.dll', |
| 155 'lib/clang/*/lib/windows/clang_rt.asan*.lib', | 160 'lib/clang/*/lib/windows/clang_rt.asan*.lib', |
| 156 'lib/clang/*/include_sanitizer/*', | 161 'lib/clang/*/include_sanitizer/*', |
| 157 ]) | 162 ]) |
| 163 if args.gcc_toolchain is not None: |
| 164 # Copy the stdlibc++.so.6 we linked Clang against so it can run. |
| 165 want.append('lib/libstdc++.so.6') |
| 158 | 166 |
| 159 for root, dirs, files in os.walk(LLVM_RELEASE_DIR): | 167 for root, dirs, files in os.walk(LLVM_RELEASE_DIR): |
| 160 # root: third_party/llvm-build/Release+Asserts/lib/..., rel_root: lib/... | 168 # root: third_party/llvm-build/Release+Asserts/lib/..., rel_root: lib/... |
| 161 rel_root = root[len(LLVM_RELEASE_DIR)+1:] | 169 rel_root = root[len(LLVM_RELEASE_DIR)+1:] |
| 162 rel_files = [os.path.join(rel_root, f) for f in files] | 170 rel_files = [os.path.join(rel_root, f) for f in files] |
| 163 wanted_files = list(set(itertools.chain.from_iterable( | 171 wanted_files = list(set(itertools.chain.from_iterable( |
| 164 fnmatch.filter(rel_files, p) for p in want))) | 172 fnmatch.filter(rel_files, p) for p in want))) |
| 165 if wanted_files: | 173 if wanted_files: |
| 166 # Guaranteed to not yet exist at this point: | 174 # Guaranteed to not yet exist at this point: |
| 167 os.makedirs(os.path.join(pdir, rel_root)) | 175 os.makedirs(os.path.join(pdir, rel_root)) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 filter=PrintTarProgress) | 235 filter=PrintTarProgress) |
| 228 print ('gsutil cp -a public-read %s.tgz ' | 236 print ('gsutil cp -a public-read %s.tgz ' |
| 229 'gs://chromium-browser-clang/%s/%s.tgz') % (golddir, platform, | 237 'gs://chromium-browser-clang/%s/%s.tgz') % (golddir, platform, |
| 230 golddir) | 238 golddir) |
| 231 | 239 |
| 232 # FIXME: Warn if the file already exists on the server. | 240 # FIXME: Warn if the file already exists on the server. |
| 233 | 241 |
| 234 | 242 |
| 235 if __name__ == '__main__': | 243 if __name__ == '__main__': |
| 236 sys.exit(main()) | 244 sys.exit(main()) |
| OLD | NEW |