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