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 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(): | |
|
Nico
2014/08/05 18:48:51
nit: CMake
hans
2014/08/05 18:52:40
Done.
| |
| 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 print "Already on path." | |
|
Nico
2014/08/05 18:48:51
remove
hans
2014/08/05 18:52:40
Gah! Well, at least now you know I tested it ;)
| |
| 108 return | |
| 109 except OSError as e: | |
| 110 if e.errno != os.errno.ENOENT: | |
| 111 raise | |
| 112 | |
| 113 cmake_locations = ['C:\\Program Files (x86)\\CMake\\bin', | |
| 114 'C:\\Program Files (x86)\\CMake 2.8\\bin'] | |
| 115 for d in cmake_locations: | |
| 116 print "Searching %s" % (d) | |
|
Nico
2014/08/05 18:48:51
remove
hans
2014/08/05 18:52:40
Done.
| |
| 117 if os.path.isdir(d): | |
| 118 os.environ['PATH'] = os.environ.get('PATH', '') + os.pathsep + d | |
| 119 print "PATH: %s" % (os.environ['PATH']) | |
|
Nico
2014/08/05 18:48:51
remove (can be added back temporarily if we need t
hans
2014/08/05 18:52:40
Done.
| |
| 120 return | |
| 121 print 'Failed to find CMake!' | |
| 122 sys.exit(1) | |
| 123 | |
| 124 | |
| 102 vs_version = None | 125 vs_version = None |
| 103 def GetVSVersion(): | 126 def GetVSVersion(): |
| 104 global vs_version | 127 global vs_version |
| 105 if not vs_version: | 128 if not vs_version: |
| 106 # TODO(hans): Find a less hacky way to find the MSVS installation. | 129 # TODO(hans): Find a less hacky way to find the MSVS installation. |
| 107 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) | 130 sys.path.append(os.path.join(CHROMIUM_DIR, 'tools', 'gyp', 'pylib')) |
| 108 import gyp.MSVSVersion | 131 import gyp.MSVSVersion |
| 109 # We request VS 2013 because Clang won't build with 2010, and 2013 will be | 132 # We request VS 2013 because Clang won't build with 2010, and 2013 will be |
| 110 # the default for Chromium soon anyway. | 133 # the default for Chromium soon anyway. |
| 111 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') | 134 vs_version = gyp.MSVSVersion.SelectVisualStudioVersion('2013') |
| 112 return vs_version | 135 return vs_version |
| 113 | 136 |
| 114 | 137 |
| 115 def UpdateClang(): | 138 def UpdateClang(): |
| 116 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) | 139 print 'Updating Clang to %s...' % (LLVM_WIN_REVISION) |
| 117 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: | 140 if LLVM_WIN_REVISION != 'HEAD' and ReadStampFile() == LLVM_WIN_REVISION: |
| 118 print 'Already up to date.' | 141 print 'Already up to date.' |
| 119 return 0 | 142 return 0 |
| 120 | 143 |
| 144 AddCmakeToPath() | |
| 121 ClobberChromiumBuildFiles() | 145 ClobberChromiumBuildFiles() |
| 122 | 146 |
| 123 # Reset the stamp file in case the build is unsuccessful. | 147 # Reset the stamp file in case the build is unsuccessful. |
| 124 WriteStampFile('') | 148 WriteStampFile('') |
| 125 | 149 |
| 126 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) | 150 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) |
| 127 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) | 151 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) |
| 128 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) | 152 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) |
| 129 | 153 |
| 130 if not os.path.exists(LLVM_BUILD_DIR): | 154 if not os.path.exists(LLVM_BUILD_DIR): |
| 131 os.makedirs(LLVM_BUILD_DIR) | 155 os.makedirs(LLVM_BUILD_DIR) |
| 132 os.chdir(LLVM_BUILD_DIR) | 156 os.chdir(LLVM_BUILD_DIR) |
| 133 | 157 |
| 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') + | 158 RunCommand(GetVSVersion().SetupScript('x64') + |
| 139 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', | 159 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', |
| 140 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) | 160 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) |
| 141 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) | 161 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) |
| 142 | 162 |
| 143 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. | 163 # 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. | 164 # TODO(hans): Remove once the regular build above produces this. |
| 145 if not os.path.exists(COMPILER_RT_BUILD_DIR): | 165 if not os.path.exists(COMPILER_RT_BUILD_DIR): |
| 146 os.makedirs(COMPILER_RT_BUILD_DIR) | 166 os.makedirs(COMPILER_RT_BUILD_DIR) |
| 147 os.chdir(COMPILER_RT_BUILD_DIR) | 167 os.chdir(COMPILER_RT_BUILD_DIR) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 229 |
| 210 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): | 230 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).' | 231 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' |
| 212 return 0 | 232 return 0 |
| 213 | 233 |
| 214 return UpdateClang() | 234 return UpdateClang() |
| 215 | 235 |
| 216 | 236 |
| 217 if __name__ == '__main__': | 237 if __name__ == '__main__': |
| 218 sys.exit(main()) | 238 sys.exit(main()) |
| OLD | NEW |