| 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 os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 shutil.copy(src, dst) | 92 shutil.copy(src, dst) |
| 93 print "Copying %s to %s" % (src, dst) | 93 print "Copying %s to %s" % (src, dst) |
| 94 | 94 |
| 95 def Checkout(name, url, dir): | 95 def Checkout(name, url, dir): |
| 96 """Checkout the SVN module at url into dir. Use name for the log message.""" | 96 """Checkout the SVN module at url into dir. Use name for the log message.""" |
| 97 print "Checking out %s r%s into '%s'" % (name, LLVM_WIN_REVISION, dir) | 97 print "Checking out %s r%s into '%s'" % (name, LLVM_WIN_REVISION, dir) |
| 98 RunCommand(['svn', 'checkout', '--force', | 98 RunCommand(['svn', 'checkout', '--force', |
| 99 url + '@' + LLVM_WIN_REVISION, dir], tries=2) | 99 url + '@' + LLVM_WIN_REVISION, dir], tries=2) |
| 100 | 100 |
| 101 | 101 |
| 102 def AddCMakeToPath(): |
| 103 """Look for CMake and add it to PATH if it's not there already.""" |
| 104 try: |
| 105 # First check if cmake is already on PATH. |
| 106 subprocess.call(['cmake', '--version']) |
| 107 return |
| 108 except OSError as e: |
| 109 if e.errno != os.errno.ENOENT: |
| 110 raise |
| 111 |
| 112 cmake_locations = ['C:\\Program Files (x86)\\CMake\\bin', |
| 113 'C:\\Program Files (x86)\\CMake 2.8\\bin'] |
| 114 for d in cmake_locations: |
| 115 if os.path.isdir(d): |
| 116 os.environ['PATH'] = os.environ.get('PATH', '') + os.pathsep + d |
| 117 return |
| 118 print 'Failed to find CMake!' |
| 119 sys.exit(1) |
| 120 |
| 121 |
| 102 vs_version = None | 122 vs_version = None |
| 103 def GetVSVersion(): | 123 def GetVSVersion(): |
| 104 global vs_version | 124 global vs_version |
| 105 if not vs_version: | 125 if not vs_version: |
| 106 # TODO(hans): Find a less hacky way to find the MSVS installation. | 126 # TODO(hans): Find a less hacky way to find the MSVS installation. |
| 107 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) | 127 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) |
| 108 import gyp.MSVSVersion | 128 import gyp.MSVSVersion |
| 109 # We request VS 2013 because Clang won't build with 2010, and 2013 will be | 129 # We request VS 2013 because Clang won't build with 2010, and 2013 will be |
| 110 # the default for Chromium soon anyway. | 130 # the default for Chromium soon anyway. |
| 111 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') | 131 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') |
| 112 return vs_version | 132 return vs_version |
| 113 | 133 |
| 114 | 134 |
| 115 def UpdateClang(): | 135 def UpdateClang(): |
| 116 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) | 136 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) |
| 117 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: | 137 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: |
| 118 print 'Already up to date.' | 138 print 'Already up to date.' |
| 119 return 0 | 139 return 0 |
| 120 | 140 |
| 141 AddCMakeToPath() |
| 121 ClobberChromiumBuildFiles() | 142 ClobberChromiumBuildFiles() |
| 122 | 143 |
| 123 # Reset the stamp file in case the build is unsuccessful. | 144 # Reset the stamp file in case the build is unsuccessful. |
| 124 WriteStampFile('') | 145 WriteStampFile('') |
| 125 | 146 |
| 126 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) | 147 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) |
| 127 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) | 148 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) |
| 128 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) | 149 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) |
| 129 | 150 |
| 130 if not os.path.exists(LLVM_BUILD_DIR): | 151 if not os.path.exists(LLVM_BUILD_DIR): |
| 131 os.makedirs(LLVM_BUILD_DIR) | 152 os.makedirs(LLVM_BUILD_DIR) |
| 132 os.chdir(LLVM_BUILD_DIR) | 153 os.chdir(LLVM_BUILD_DIR) |
| 133 | 154 |
| 134 if not re.search(r'cmake', os.environ['PATH'], flags=re.IGNORECASE): | |
| 135 # If CMake is not on the path, try looking in a standard location. | |
| 136 os.environ['PATH'] += os.pathsep + 'C:\\Program Files (x86)\\CMake 2.8\\bin' | |
| 137 | |
| 138 RunCommand(GetVSVersion().SetupScript('x64') + | 155 RunCommand(GetVSVersion().SetupScript('x64') + |
| 139 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', | 156 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', |
| 140 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) | 157 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) |
| 141 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) | 158 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) |
| 142 | 159 |
| 143 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. | 160 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. |
| 144 # TODO(hans): Remove once the regular build above produces this. | 161 # TODO(hans): Remove once the regular build above produces this. |
| 145 if not os.path.exists(COMPILER_RT_BUILD_DIR): | 162 if not os.path.exists(COMPILER_RT_BUILD_DIR): |
| 146 os.makedirs(COMPILER_RT_BUILD_DIR) | 163 os.makedirs(COMPILER_RT_BUILD_DIR) |
| 147 os.chdir(COMPILER_RT_BUILD_DIR) | 164 os.chdir(COMPILER_RT_BUILD_DIR) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 226 |
| 210 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): | 227 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): |
| 211 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' | 228 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' |
| 212 return 0 | 229 return 0 |
| 213 | 230 |
| 214 return UpdateClang() | 231 return UpdateClang() |
| 215 | 232 |
| 216 | 233 |
| 217 if __name__ == '__main__': | 234 if __name__ == '__main__': |
| 218 sys.exit(main()) | 235 sys.exit(main()) |
| OLD | NEW |