| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 print 'Failed:', cmd | 51 print 'Failed:', cmd |
| 52 sys.exit(1) | 52 sys.exit(1) |
| 53 | 53 |
| 54 | 54 |
| 55 def PrintTarProgress(tarinfo): | 55 def PrintTarProgress(tarinfo): |
| 56 print 'Adding', tarinfo.name | 56 print 'Adding', tarinfo.name |
| 57 return tarinfo | 57 return tarinfo |
| 58 | 58 |
| 59 | 59 |
| 60 def main(): | 60 def main(): |
| 61 if sys.platform == 'win32': |
| 62 try: |
| 63 subprocess.check_output(['grep', '--help'], shell=True) |
| 64 except subprocess.CalledProcessError: |
| 65 print 'Add gnuwin32 to your PATH, then try again.' |
| 66 return 1 |
| 67 |
| 61 parser = argparse.ArgumentParser(description='build and package clang') | 68 parser = argparse.ArgumentParser(description='build and package clang') |
| 62 parser.add_argument('--gcc-toolchain', | 69 parser.add_argument('--gcc-toolchain', |
| 63 help="the prefix for the GCC version used for building. " | 70 help="the prefix for the GCC version used for building. " |
| 64 "For /opt/foo/bin/gcc, pass " | 71 "For /opt/foo/bin/gcc, pass " |
| 65 "'--gcc-toolchain '/opt/foo'") | 72 "'--gcc-toolchain '/opt/foo'") |
| 66 | 73 |
| 67 args = parser.parse_args() | 74 args = parser.parse_args() |
| 68 | 75 |
| 69 with open('buildlog.txt', 'w') as log: | 76 with open('buildlog.txt', 'w') as log: |
| 70 Tee('Diff in llvm:\n', log) | 77 Tee('Diff in llvm:\n', log) |
| 71 TeeCmd(['svn', 'stat', LLVM_DIR], log, fail_hard=False) | 78 TeeCmd(['svn', 'stat', LLVM_DIR], log, fail_hard=False) |
| 72 TeeCmd(['svn', 'diff', LLVM_DIR], log, fail_hard=False) | 79 TeeCmd(['svn', 'diff', LLVM_DIR], log, fail_hard=False) |
| 73 Tee('Diff in llvm/tools/clang:\n', log) | 80 Tee('Diff in llvm/tools/clang:\n', log) |
| 74 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'tools', 'clang')], | 81 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'tools', 'clang')], |
| 75 log, fail_hard=False) | 82 log, fail_hard=False) |
| 76 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'tools', 'clang')], | 83 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'tools', 'clang')], |
| 77 log, fail_hard=False) | 84 log, fail_hard=False) |
| 85 # TODO(thakis): compiler-rt is in projects/compiler-rt on Windows but |
| 86 # llvm/compiler-rt elsewhere. So this diff call is currently only right on |
| 87 # Windows. |
| 78 Tee('Diff in llvm/compiler-rt:\n', log) | 88 Tee('Diff in llvm/compiler-rt:\n', log) |
| 79 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'compiler-rt')], | 89 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'projects', 'compiler-rt')], |
| 80 log, fail_hard=False) | 90 log, fail_hard=False) |
| 81 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'compiler-rt')], | 91 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'compiler-rt')], |
| 82 log, fail_hard=False) | 92 log, fail_hard=False) |
| 83 Tee('Diff in llvm/projects/libcxx:\n', log) | 93 Tee('Diff in llvm/projects/libcxx:\n', log) |
| 84 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'projects', 'libcxx')], | 94 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'projects', 'libcxx')], |
| 85 log, fail_hard=False) | 95 log, fail_hard=False) |
| 86 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'libcxx')], | 96 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'libcxx')], |
| 87 log, fail_hard=False) | 97 log, fail_hard=False) |
| 88 Tee('Diff in llvm/projects/libcxxabi:\n', log) | 98 Tee('Diff in llvm/projects/libcxxabi:\n', log) |
| 89 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'projects', 'libcxxabi')], | 99 TeeCmd(['svn', 'stat', os.path.join(LLVM_DIR, 'projects', 'libcxxabi')], |
| 90 log, fail_hard=False) | 100 log, fail_hard=False) |
| 91 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'libcxxabi')], | 101 TeeCmd(['svn', 'diff', os.path.join(LLVM_DIR, 'projects', 'libcxxabi')], |
| (...skipping 16 matching lines...) Expand all Loading... |
| 108 stamp = open(STAMP_FILE).read().rstrip() | 118 stamp = open(STAMP_FILE).read().rstrip() |
| 109 pdir = 'clang-' + stamp | 119 pdir = 'clang-' + stamp |
| 110 print pdir | 120 print pdir |
| 111 shutil.rmtree(pdir, ignore_errors=True) | 121 shutil.rmtree(pdir, ignore_errors=True) |
| 112 | 122 |
| 113 # Copy a whitelist of files to the directory we're going to tar up. | 123 # Copy a whitelist of files to the directory we're going to tar up. |
| 114 # This supports the same patterns that the fnmatch module understands. | 124 # This supports the same patterns that the fnmatch module understands. |
| 115 exe_ext = '.exe' if sys.platform == 'win32' else '' | 125 exe_ext = '.exe' if sys.platform == 'win32' else '' |
| 116 want = ['bin/llvm-symbolizer' + exe_ext, | 126 want = ['bin/llvm-symbolizer' + exe_ext, |
| 117 'lib/clang/*/asan_blacklist.txt', | 127 'lib/clang/*/asan_blacklist.txt', |
| 128 'lib/clang/*/cfi_blacklist.txt', |
| 118 # Copy built-in headers (lib/clang/3.x.y/include). | 129 # Copy built-in headers (lib/clang/3.x.y/include). |
| 119 'lib/clang/*/include/*', | 130 'lib/clang/*/include/*', |
| 120 ] | 131 ] |
| 121 if sys.platform == 'win32': | 132 if sys.platform == 'win32': |
| 122 want.append('bin/clang-cl.exe') | 133 want.append('bin/clang-cl.exe') |
| 134 want.append('bin/lld-link.exe') |
| 123 else: | 135 else: |
| 124 so_ext = 'dylib' if sys.platform == 'darwin' else 'so' | 136 so_ext = 'dylib' if sys.platform == 'darwin' else 'so' |
| 125 want.extend(['bin/clang', | 137 want.extend(['bin/clang', |
| 126 'lib/libFindBadConstructs.' + so_ext, | 138 'lib/libFindBadConstructs.' + so_ext, |
| 127 'lib/libBlinkGCPlugin.' + so_ext, | 139 'lib/libBlinkGCPlugin.' + so_ext, |
| 128 ]) | 140 ]) |
| 129 if sys.platform == 'darwin': | 141 if sys.platform == 'darwin': |
| 130 want.extend(['bin/libc++.1.dylib', | 142 want.extend(['bin/libc++.1.dylib', |
| 131 # Copy only the OSX (ASan and profile) and iossim (ASan) | 143 # Copy only the OSX (ASan and profile) and iossim (ASan) |
| 132 # runtime libraries: | 144 # runtime libraries: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 subprocess.call(['install_name_tool', '-id', | 188 subprocess.call(['install_name_tool', '-id', |
| 177 '@executable_path/' + os.path.basename(dest), dest]) | 189 '@executable_path/' + os.path.basename(dest), dest]) |
| 178 subprocess.call(['strip', '-x', dest]) | 190 subprocess.call(['strip', '-x', dest]) |
| 179 elif (sys.platform.startswith('linux') and | 191 elif (sys.platform.startswith('linux') and |
| 180 os.path.splitext(f)[1] in ['.so', '.a']): | 192 os.path.splitext(f)[1] in ['.so', '.a']): |
| 181 subprocess.call(['strip', '-g', dest]) | 193 subprocess.call(['strip', '-g', dest]) |
| 182 | 194 |
| 183 # Set up symlinks. | 195 # Set up symlinks. |
| 184 if sys.platform != 'win32': | 196 if sys.platform != 'win32': |
| 185 os.symlink('clang', os.path.join(pdir, 'bin', 'clang++')) | 197 os.symlink('clang', os.path.join(pdir, 'bin', 'clang++')) |
| 198 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) |
| 186 if sys.platform == 'darwin': | 199 if sys.platform == 'darwin': |
| 187 os.symlink('libc++.1.dylib', os.path.join(pdir, 'bin', 'libc++.dylib')) | 200 os.symlink('libc++.1.dylib', os.path.join(pdir, 'bin', 'libc++.dylib')) |
| 188 # Also copy libc++ headers. | 201 # Also copy libc++ headers. |
| 189 shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), | 202 shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), |
| 190 os.path.join(pdir, 'include', 'c++')) | 203 os.path.join(pdir, 'include', 'c++')) |
| 191 | 204 |
| 192 # Copy buildlog over. | 205 # Copy buildlog over. |
| 193 shutil.copy('buildlog.txt', pdir) | 206 shutil.copy('buildlog.txt', pdir) |
| 194 | 207 |
| 195 # Create archive. | 208 # Create archive. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 223 filter=PrintTarProgress) | 236 filter=PrintTarProgress) |
| 224 print ('gsutil cp -a public-read %s.tgz ' | 237 print ('gsutil cp -a public-read %s.tgz ' |
| 225 'gs://chromium-browser-clang/%s/%s.tgz') % (golddir, platform, | 238 'gs://chromium-browser-clang/%s/%s.tgz') % (golddir, platform, |
| 226 golddir) | 239 golddir) |
| 227 | 240 |
| 228 # FIXME: Warn if the file already exists on the server. | 241 # FIXME: Warn if the file already exists on the server. |
| 229 | 242 |
| 230 | 243 |
| 231 if __name__ == '__main__': | 244 if __name__ == '__main__': |
| 232 sys.exit(main()) | 245 sys.exit(main()) |
| OLD | NEW |