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