OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Windows can't run .sh files, so this is a Python implementation of | 6 """Windows can't run .sh files, so this is a Python implementation of |
7 update.sh. This script should replace update.sh on all platforms eventually.""" | 7 update.sh. This script should replace update.sh on all platforms eventually.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import contextlib | 10 import contextlib |
11 import cStringIO | 11 import cStringIO |
| 12 import glob |
12 import os | 13 import os |
| 14 import pipes |
13 import re | 15 import re |
14 import shutil | 16 import shutil |
15 import subprocess | 17 import subprocess |
16 import stat | 18 import stat |
17 import sys | 19 import sys |
18 import tarfile | 20 import tarfile |
19 import time | 21 import time |
20 import urllib2 | 22 import urllib2 |
21 import zipfile | 23 import zipfile |
22 | 24 |
(...skipping 22 matching lines...) Expand all Loading... |
45 LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap') | 47 LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap') |
46 LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR, | 48 LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR, |
47 'llvm-bootstrap-install') | 49 'llvm-bootstrap-install') |
48 CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'chrometools') | 50 CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'chrometools') |
49 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', | 51 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', |
50 'Release+Asserts') | 52 'Release+Asserts') |
51 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') | 53 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') |
52 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') | 54 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') |
53 LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld') | 55 LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld') |
54 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') | 56 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') |
| 57 LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx') |
| 58 LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi') |
55 LLVM_BUILD_TOOLS_DIR = os.path.abspath( | 59 LLVM_BUILD_TOOLS_DIR = os.path.abspath( |
56 os.path.join(LLVM_DIR, '..', 'llvm-build-tools')) | 60 os.path.join(LLVM_DIR, '..', 'llvm-build-tools')) |
57 STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision') | 61 STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision') |
58 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils') | 62 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils') |
59 VERSION = '3.7.0' | 63 VERSION = '3.7.0' |
60 | 64 |
61 # URL for pre-built binaries. | 65 # URL for pre-built binaries. |
62 CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang' | 66 CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang' |
63 | 67 |
64 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' | 68 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' |
(...skipping 28 matching lines...) Expand all Loading... |
93 """Return the contents of the stamp file, or '' if it doesn't exist.""" | 97 """Return the contents of the stamp file, or '' if it doesn't exist.""" |
94 try: | 98 try: |
95 with open(STAMP_FILE, 'r') as f: | 99 with open(STAMP_FILE, 'r') as f: |
96 return f.read(); | 100 return f.read(); |
97 except IOError: | 101 except IOError: |
98 return '' | 102 return '' |
99 | 103 |
100 | 104 |
101 def WriteStampFile(s): | 105 def WriteStampFile(s): |
102 """Write s to the stamp file.""" | 106 """Write s to the stamp file.""" |
103 if not os.path.exists(LLVM_BUILD_DIR): | 107 if not os.path.exists(os.path.dirname(STAMP_FILE)): |
104 os.makedirs(LLVM_BUILD_DIR) | 108 os.makedirs(os.path.dirname(STAMP_FILE)) |
105 with open(STAMP_FILE, 'w') as f: | 109 with open(STAMP_FILE, 'w') as f: |
106 f.write(s) | 110 f.write(s) |
107 | 111 |
108 | 112 |
109 def GetSvnRevision(svn_repo): | 113 def GetSvnRevision(svn_repo): |
110 """Returns current revision of the svn repo at svn_repo.""" | 114 """Returns current revision of the svn repo at svn_repo.""" |
111 svn_info = subprocess.check_output(['svn', 'info', svn_repo], shell=True) | 115 svn_info = subprocess.check_output('svn info ' + svn_repo, shell=True) |
112 m = re.search(r'Revision: (\d+)', svn_info) | 116 m = re.search(r'Revision: (\d+)', svn_info) |
113 return m.group(1) | 117 return m.group(1) |
114 | 118 |
115 | 119 |
116 def RmTree(dir): | 120 def RmTree(dir): |
117 """Delete dir.""" | 121 """Delete dir.""" |
118 def ChmodAndRetry(func, path, _): | 122 def ChmodAndRetry(func, path, _): |
119 # Subversion can leave read-only files around. | 123 # Subversion can leave read-only files around. |
120 if not os.access(path, os.W_OK): | 124 if not os.access(path, os.W_OK): |
121 os.chmod(path, stat.S_IWUSR) | 125 os.chmod(path, stat.S_IWUSR) |
122 return func(path) | 126 return func(path) |
123 raise | 127 raise |
124 | 128 |
125 shutil.rmtree(dir, onerror=ChmodAndRetry) | 129 shutil.rmtree(dir, onerror=ChmodAndRetry) |
126 | 130 |
127 | 131 |
128 def RunCommand(command, fail_hard=True): | 132 def RunCommand(command, env=None, fail_hard=True): |
129 """Run command and return success (True) or failure; or if fail_hard is | 133 """Run command and return success (True) or failure; or if fail_hard is |
130 True, exit on failure.""" | 134 True, exit on failure.""" |
131 | 135 |
132 print 'Running %s' % (str(command)) | 136 # https://docs.python.org/2/library/subprocess.html: |
133 if subprocess.call(command, shell=True) == 0: | 137 # "On Unix with shell=True [...] if args is a sequence, the first item |
| 138 # specifies the command string, and any additional items will be treated as |
| 139 # additional arguments to the shell itself. That is to say, Popen does the |
| 140 # equivalent of: |
| 141 # Popen(['/bin/sh', '-c', args[0], args[1], ...])" |
| 142 # |
| 143 # We want to pass additional arguments to command[0], not to the shell, |
| 144 # so manually join everything into a single string. |
| 145 command = ' '.join([pipes.quote(c) for c in command]) |
| 146 print 'Running', command |
| 147 if subprocess.call(command, env=env, shell=True) == 0: |
134 return True | 148 return True |
135 print 'Failed.' | 149 print 'Failed.' |
136 if fail_hard: | 150 if fail_hard: |
137 sys.exit(1) | 151 sys.exit(1) |
138 return False | 152 return False |
139 | 153 |
140 | 154 |
141 def CopyFile(src, dst): | 155 def CopyFile(src, dst): |
142 """Copy a file from src to dst.""" | 156 """Copy a file from src to dst.""" |
143 shutil.copy(src, dst) | 157 shutil.copy(src, dst) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 if not os.path.exists(cmake_dir): | 228 if not os.path.exists(cmake_dir): |
215 if not os.path.exists(LLVM_BUILD_TOOLS_DIR): | 229 if not os.path.exists(LLVM_BUILD_TOOLS_DIR): |
216 os.makedirs(LLVM_BUILD_TOOLS_DIR) | 230 os.makedirs(LLVM_BUILD_TOOLS_DIR) |
217 # The cmake archive is smaller than 20 MB, small enough to keep in memory: | 231 # The cmake archive is smaller than 20 MB, small enough to keep in memory: |
218 with contextlib.closing(cStringIO.StringIO()) as f: | 232 with contextlib.closing(cStringIO.StringIO()) as f: |
219 DownloadUrl(CDS_URL + '/tools/' + zip_name, f) | 233 DownloadUrl(CDS_URL + '/tools/' + zip_name, f) |
220 f.seek(0) | 234 f.seek(0) |
221 if zip_name.endswith('.zip'): | 235 if zip_name.endswith('.zip'): |
222 zipfile.ZipFile(f).extractall(path=LLVM_BUILD_TOOLS_DIR) | 236 zipfile.ZipFile(f).extractall(path=LLVM_BUILD_TOOLS_DIR) |
223 else: | 237 else: |
224 tarfile.open(mode='r:gz', fileobj=f).extractall(path=LLVM_BUILD_DIR) | 238 tarfile.open(mode='r:gz', fileobj=f).extractall(path= |
| 239 LLVM_BUILD_TOOLS_DIR) |
225 os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '') | 240 os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '') |
226 | 241 |
227 vs_version = None | 242 vs_version = None |
228 def GetVSVersion(): | 243 def GetVSVersion(): |
229 global vs_version | 244 global vs_version |
230 if vs_version: | 245 if vs_version: |
231 return vs_version | 246 return vs_version |
232 | 247 |
233 # Try using the toolchain in depot_tools. | 248 # Try using the toolchain in depot_tools. |
234 # This sets environment variables used by SelectVisualStudioVersion below. | 249 # This sets environment variables used by SelectVisualStudioVersion below. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 WriteStampFile(PACKAGE_VERSION) | 287 WriteStampFile(PACKAGE_VERSION) |
273 return 0 | 288 return 0 |
274 except urllib2.HTTPError: | 289 except urllib2.HTTPError: |
275 print 'Did not find prebuilt clang %s, building locally' % cds_file | 290 print 'Did not find prebuilt clang %s, building locally' % cds_file |
276 | 291 |
277 AddCMakeToPath() | 292 AddCMakeToPath() |
278 | 293 |
279 DeleteChromeToolsShim(); | 294 DeleteChromeToolsShim(); |
280 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) | 295 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) |
281 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) | 296 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) |
282 Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR) | 297 if sys.platform == 'win32': |
| 298 Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR) |
283 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) | 299 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) |
| 300 if sys.platform == 'darwin': |
| 301 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes |
| 302 # (i.e. this is needed for bootstrap builds). |
| 303 Checkout('libcxx', LLVM_REPO_URL + '/libcxx/trunk', LIBCXX_DIR) |
| 304 # While we're bundling our own libc++ on OS X, we need to compile libc++abi |
| 305 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either). |
| 306 Checkout('libcxxabi', LLVM_REPO_URL + '/libcxxabi/trunk', LIBCXXABI_DIR) |
| 307 |
284 CreateChromeToolsShim(); | 308 CreateChromeToolsShim(); |
285 | 309 |
286 # If building at head, define a macro that plugins can use for #ifdefing | 310 cc, cxx = None, None |
287 # out code that builds at head, but not at CLANG_REVISION or vice versa. | 311 cflags = cxxflags = ldflags = [] |
288 cflags = cxxflags = '' | |
289 | 312 |
290 # If building at head, define a macro that plugins can use for #ifdefing | 313 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is |
291 # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa. | 314 # needed, on OS X it requires libc++. clang only automatically links to libc++ |
292 if use_head_revision: | 315 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run |
293 cflags += ' -DLLVM_FORCE_HEAD_REVISION' | 316 # on OS X versions as old as 10.7. |
294 cxxflags += ' -DLLVM_FORCE_HEAD_REVISION' | 317 # TODO(thakis): Some bots are still on 10.6 (nacl...), so for now bundle |
| 318 # libc++.dylib. Remove this once all bots are on 10.7+, then use |
| 319 # -DLLVM_ENABLE_LIBCXX=ON and change deployment_target to 10.7. |
| 320 deployment_target = '' |
| 321 |
| 322 if sys.platform == 'darwin': |
| 323 # When building on 10.9, /usr/include usually doesn't exist, and while |
| 324 # Xcode's clang automatically sets a sysroot, self-built clangs don't. |
| 325 cflags = ['-isysroot', subprocess.check_output( |
| 326 ['xcrun', '--show-sdk-path']).rstrip()] |
| 327 cxxflags = ['-stdlib=libc++', '-nostdinc++', |
| 328 '-I' + os.path.join(LIBCXX_DIR, 'include')] + cflags |
| 329 if args.bootstrap: |
| 330 deployment_target = '10.6' |
295 | 331 |
296 base_cmake_args = ['-GNinja', | 332 base_cmake_args = ['-GNinja', |
297 '-DCMAKE_BUILD_TYPE=Release', | 333 '-DCMAKE_BUILD_TYPE=Release', |
298 '-DLLVM_ENABLE_ASSERTIONS=ON', | 334 '-DLLVM_ENABLE_ASSERTIONS=ON', |
299 '-DLLVM_ENABLE_THREADS=OFF', | 335 '-DLLVM_ENABLE_THREADS=OFF', |
300 ] | 336 ] |
301 | 337 |
302 cc, cxx = None, None | |
303 if args.bootstrap: | 338 if args.bootstrap: |
304 print 'Building bootstrap compiler' | 339 print 'Building bootstrap compiler' |
305 if not os.path.exists(LLVM_BOOTSTRAP_DIR): | 340 if not os.path.exists(LLVM_BOOTSTRAP_DIR): |
306 os.makedirs(LLVM_BOOTSTRAP_DIR) | 341 os.makedirs(LLVM_BOOTSTRAP_DIR) |
307 os.chdir(LLVM_BOOTSTRAP_DIR) | 342 os.chdir(LLVM_BOOTSTRAP_DIR) |
308 bootstrap_args = base_cmake_args + [ | 343 bootstrap_args = base_cmake_args + [ |
309 '-DLLVM_TARGETS_TO_BUILD=host', | 344 '-DLLVM_TARGETS_TO_BUILD=host', |
310 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR, | 345 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR, |
311 '-DCMAKE_C_FLAGS=' + cflags, | 346 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
312 '-DCMAKE_CXX_FLAGS=' + cxxflags, | 347 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), |
313 ] | 348 ] |
314 if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc) | 349 if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc) |
315 if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx) | 350 if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx) |
316 RunCommand(GetVSVersion().SetupScript('x64') + | 351 RunCommand(GetVSVersion().SetupScript('x64') + |
317 ['&&', 'cmake'] + bootstrap_args + [LLVM_DIR]) | 352 ['&&', 'cmake'] + bootstrap_args + [LLVM_DIR]) |
318 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja']) | 353 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja']) |
319 if args.run_tests: | 354 if args.run_tests: |
320 RunCommand(GetVSVersion().SetupScript('x64') + | 355 RunCommand(GetVSVersion().SetupScript('x64') + |
321 ['&&', 'ninja', 'check-all']) | 356 ['&&', 'ninja', 'check-all']) |
322 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'install']) | 357 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'install']) |
323 # TODO(thakis): Set these to clang / clang++ on posix once this script | 358 # TODO(thakis): Set these to clang / clang++ on posix once this script |
324 # is used on posix. | 359 # is used on posix. |
325 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') | 360 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') |
326 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') | 361 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') |
327 # CMake has a hard time with backslashes in compiler paths: | 362 # CMake has a hard time with backslashes in compiler paths: |
328 # https://stackoverflow.com/questions/13050827 | 363 # https://stackoverflow.com/questions/13050827 |
329 cc = cc.replace('\\', '/') | 364 cc = cc.replace('\\', '/') |
330 cxx = cxx.replace('\\', '/') | 365 cxx = cxx.replace('\\', '/') |
331 print 'Building final compiler' | 366 print 'Building final compiler' |
332 | 367 |
| 368 if sys.platform == 'darwin': |
| 369 # Build libc++.dylib while some bots are still on OS X 10.6. |
| 370 libcxxbuild = os.path.join(LLVM_BUILD_DIR, 'libcxxbuild') |
| 371 if os.path.isdir(libcxxbuild): |
| 372 RmTree(libcxxbuild) |
| 373 libcxxflags = ['-O3', '-std=c++11', '-fstrict-aliasing'] |
| 374 |
| 375 # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files |
| 376 # into different subdirectories. |
| 377 os.makedirs(os.path.join(libcxxbuild, 'libcxx')) |
| 378 os.chdir(os.path.join(libcxxbuild, 'libcxx')) |
| 379 RunCommand(['c++', '-c'] + cxxflags + libcxxflags + |
| 380 glob.glob(os.path.join(LIBCXX_DIR, 'src', '*.cpp'))) |
| 381 |
| 382 os.makedirs(os.path.join(libcxxbuild, 'libcxxabi')) |
| 383 os.chdir(os.path.join(libcxxbuild, 'libcxxabi')) |
| 384 RunCommand(['c++', '-c'] + cxxflags + libcxxflags + |
| 385 glob.glob(os.path.join(LIBCXXABI_DIR, 'src', '*.cpp')) + |
| 386 ['-I' + os.path.join(LIBCXXABI_DIR, 'include')]) |
| 387 |
| 388 os.chdir(libcxxbuild) |
| 389 libdir = os.path.join(LIBCXX_DIR, 'lib') |
| 390 RunCommand(['cc'] + glob.glob('libcxx/*.o') + glob.glob('libcxxabi/*.o') + |
| 391 ['-o', 'libc++.1.dylib', '-dynamiclib', '-nodefaultlibs', |
| 392 '-current_version', '1', '-compatibility_version', '1', '-lSystem', |
| 393 '-install_name', '@executable_path/libc++.dylib', |
| 394 '-Wl,-unexported_symbols_list,' + libdir + '/libc++unexp.exp', |
| 395 '-Wl,-force_symbols_not_weak_list,' + libdir + '/notweak.exp', |
| 396 '-Wl,-force_symbols_weak_list,' + libdir + '/weak.exp']) |
| 397 if os.path.exists('libc++.dylib'): |
| 398 os.remove('libc++.dylib') |
| 399 os.symlink('libc++.1.dylib', 'libc++.dylib') |
| 400 ldflags += ['-stdlib=libc++', '-L' + libcxxbuild] |
| 401 |
333 # Build clang. | 402 # Build clang. |
334 binutils_incdir = '' | 403 binutils_incdir = '' |
335 if sys.platform.startswith('linux'): | 404 if sys.platform.startswith('linux'): |
336 binutils_incdir = os.path.join(BINUTILS_DIR, 'Linux_x64/Release/include') | 405 binutils_incdir = os.path.join(BINUTILS_DIR, 'Linux_x64/Release/include') |
337 | 406 |
| 407 # If building at head, define a macro that plugins can use for #ifdefing |
| 408 # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa. |
| 409 if use_head_revision: |
| 410 cflags += ['-DLLVM_FORCE_HEAD_REVISION'] |
| 411 cxxflags += ['-DLLVM_FORCE_HEAD_REVISION'] |
| 412 |
| 413 deployment_env = os.environ.copy() |
| 414 if deployment_target: |
| 415 deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target |
| 416 |
338 cmake_args = base_cmake_args + [ | 417 cmake_args = base_cmake_args + [ |
339 '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir, | 418 '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir, |
340 '-DCMAKE_C_FLAGS=' + cflags, | 419 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
341 '-DCMAKE_CXX_FLAGS=' + cxxflags, | 420 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), |
| 421 '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags), |
| 422 '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags), |
| 423 '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags), |
342 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'), | 424 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'), |
343 '-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)] | 425 '-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)] |
344 # TODO(thakis): Append this to base_cmake_args instead once compiler-rt | 426 # TODO(thakis): Append this to base_cmake_args instead once compiler-rt |
345 # can build with clang-cl (http://llvm.org/PR23698) | 427 # can build with clang-cl (http://llvm.org/PR23698) |
346 if cc is not None: cmake_args.append('-DCMAKE_C_COMPILER=' + cc) | 428 if cc is not None: cmake_args.append('-DCMAKE_C_COMPILER=' + cc) |
347 if cxx is not None: cmake_args.append('-DCMAKE_CXX_COMPILER=' + cxx) | 429 if cxx is not None: cmake_args.append('-DCMAKE_CXX_COMPILER=' + cxx) |
348 | 430 |
349 if not os.path.exists(LLVM_BUILD_DIR): | 431 if not os.path.exists(LLVM_BUILD_DIR): |
350 os.makedirs(LLVM_BUILD_DIR) | 432 os.makedirs(LLVM_BUILD_DIR) |
351 os.chdir(LLVM_BUILD_DIR) | 433 os.chdir(LLVM_BUILD_DIR) |
352 RunCommand(GetVSVersion().SetupScript('x64') + | 434 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'cmake'] + cmake_args + |
353 ['&&', 'cmake'] + cmake_args + [LLVM_DIR]) | 435 [LLVM_DIR], env=deployment_env) |
354 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) | 436 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) |
355 | 437 |
| 438 # TODO(thakis): Run `strip bin/clang` on posix (with -x on darwin) |
| 439 |
| 440 if sys.platform == 'darwin': |
| 441 CopyFile(os.path.join(LLVM_BUILD_DIR, 'libc++.1.dylib'), |
| 442 os.path.join(LLVM_BUILD_DIR, 'bin')) |
| 443 |
356 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. | 444 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. |
357 # TODO(hans): Remove once the regular build above produces this. | 445 # TODO(hans): Remove once the regular build above produces this. |
358 if not os.path.exists(COMPILER_RT_BUILD_DIR): | 446 if not os.path.exists(COMPILER_RT_BUILD_DIR): |
359 os.makedirs(COMPILER_RT_BUILD_DIR) | 447 os.makedirs(COMPILER_RT_BUILD_DIR) |
360 os.chdir(COMPILER_RT_BUILD_DIR) | 448 os.chdir(COMPILER_RT_BUILD_DIR) |
361 # TODO(thakis): Add this once compiler-rt can build with clang-cl (see | 449 # TODO(thakis): Add this once compiler-rt can build with clang-cl (see |
362 # above). | 450 # above). |
363 #if args.bootstrap: | 451 #if args.bootstrap: |
364 # The bootstrap compiler produces 64-bit binaries by default. | 452 # The bootstrap compiler produces 64-bit binaries by default. |
365 #cflags += ' -m32' | 453 #cflags += ['-m32'] |
366 #cxxflags += ' -m32' | 454 #cxxflags += ['-m32'] |
367 compiler_rt_args = base_cmake_args + [ | 455 compiler_rt_args = base_cmake_args + [ |
368 '-DCMAKE_C_FLAGS=' + cflags, | 456 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
369 '-DCMAKE_CXX_FLAGS=' + cxxflags] | 457 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)] |
370 RunCommand(GetVSVersion().SetupScript('x86') + | 458 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'cmake'] + |
371 ['&&', 'cmake'] + compiler_rt_args + [LLVM_DIR]) | 459 compiler_rt_args + [LLVM_DIR], env=deployment_env) |
372 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) | 460 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) |
373 | 461 |
374 # TODO(hans): Make this (and the .gypi and .isolate files) version number | 462 # TODO(hans): Make this (and the .gypi and .isolate files) version number |
375 # independent. | 463 # independent. |
376 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang', | 464 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang', |
377 VERSION, 'lib', 'windows') | 465 VERSION, 'lib', 'windows') |
378 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', | 466 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', |
379 VERSION, 'lib', 'windows') | 467 VERSION, 'lib', 'windows') |
380 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir, | 468 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir, |
381 r'^.*-i386\.lib$') | 469 r'^.*-i386\.lib$') |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 # Use a real revision number rather than HEAD to make sure that the stamp | 579 # Use a real revision number rather than HEAD to make sure that the stamp |
492 # file logic works. | 580 # file logic works. |
493 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) | 581 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) |
494 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' | 582 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' |
495 | 583 |
496 return UpdateClang(args) | 584 return UpdateClang(args) |
497 | 585 |
498 | 586 |
499 if __name__ == '__main__': | 587 if __name__ == '__main__': |
500 sys.exit(main()) | 588 sys.exit(main()) |
OLD | NEW |