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 |
| 11 import shutil |
11 import subprocess | 12 import subprocess |
12 import sys | 13 import sys |
13 | 14 |
14 # Do NOT CHANGE this if you don't know what you're doing -- see | 15 # Do NOT CHANGE this if you don't know what you're doing -- see |
15 # https://code.google.com/p/chromium/wiki/UpdatingClang | 16 # https://code.google.com/p/chromium/wiki/UpdatingClang |
16 # Reverting problematic clang rolls is safe, though. | 17 # Reverting problematic clang rolls is safe, though. |
17 # Note: this revision is only used for Windows. Other platforms use update.sh. | 18 # Note: this revision is only used for Windows. Other platforms use update.sh. |
18 LLVM_WINDOWS_REVISION = '201859' | 19 LLVM_WINDOWS_REVISION = '201860' |
19 | 20 |
20 # Path constants. (All of these should be absolute paths.) | 21 # Path constants. (All of these should be absolute paths.) |
21 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 22 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
22 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) | 23 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) |
23 LLVM_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm') | 24 LLVM_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm') |
24 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', | 25 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', |
25 'Release+Asserts') | 26 'Release+Asserts') |
| 27 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') |
26 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') | 28 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') |
27 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') | 29 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') |
28 STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') | 30 STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') |
29 | 31 |
30 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' | 32 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' |
31 if 'LLVM_REPO_URL' in os.environ: | 33 if 'LLVM_REPO_URL' in os.environ: |
32 LLVM_REPO_URL = os.environ['LLVM_REPO_URL'] | 34 LLVM_REPO_URL = os.environ['LLVM_REPO_URL'] |
33 | 35 |
34 | 36 |
35 def ReadStampFile(): | 37 def ReadStampFile(): |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 os.makedirs(LLVM_BUILD_DIR) | 129 os.makedirs(LLVM_BUILD_DIR) |
128 os.chdir(LLVM_BUILD_DIR) | 130 os.chdir(LLVM_BUILD_DIR) |
129 | 131 |
130 if not re.search(r'cmake', os.environ['PATH'], flags=re.IGNORECASE): | 132 if not re.search(r'cmake', os.environ['PATH'], flags=re.IGNORECASE): |
131 # If CMake is not on the path, try looking in a standard location. | 133 # If CMake is not on the path, try looking in a standard location. |
132 os.environ['PATH'] += os.pathsep + 'C:\\Program Files (x86)\\CMake 2.8\\bin' | 134 os.environ['PATH'] += os.pathsep + 'C:\\Program Files (x86)\\CMake 2.8\\bin' |
133 | 135 |
134 RunCommand(GetVSVersion().SetupScript('x64') + | 136 RunCommand(GetVSVersion().SetupScript('x64') + |
135 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', | 137 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', |
136 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) | 138 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) |
| 139 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) |
137 | 140 |
138 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) | 141 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. |
| 142 # TODO(hans): Remove once the regular build above produces this. |
| 143 if not os.path.exists(COMPILER_RT_BUILD_DIR): |
| 144 os.makedirs(COMPILER_RT_BUILD_DIR) |
| 145 os.chdir(COMPILER_RT_BUILD_DIR) |
| 146 RunCommand(GetVSVersion().SetupScript('x86') + |
| 147 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', |
| 148 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) |
| 149 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) |
| 150 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang', |
| 151 '3.5', 'lib', 'windows') |
| 152 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', |
| 153 '3.5', 'lib', 'windows') |
| 154 if not os.path.exists(asan_rt_lib_dst_dir): |
| 155 os.makedirs(asan_rt_lib_dst_dir) |
| 156 for root, _, files in os.walk(asan_rt_lib_src_dir): |
| 157 for f in files: |
| 158 if re.match(r'^.*-i386\.lib$', f): |
| 159 shutil.copy(os.path.join(root, f), asan_rt_lib_dst_dir) |
| 160 print "Copying %s to %s" % (f, asan_rt_lib_dst_dir) |
139 | 161 |
140 WriteStampFile(LLVM_WINDOWS_REVISION) | 162 WriteStampFile(LLVM_WINDOWS_REVISION) |
141 print 'Clang update was successful.' | 163 print 'Clang update was successful.' |
142 return 0 | 164 return 0 |
143 | 165 |
144 | 166 |
145 def main(): | 167 def main(): |
146 if not sys.platform in ['win32', 'cygwin']: | 168 if not sys.platform in ['win32', 'cygwin']: |
147 # For non-Windows, fall back to update.sh. | 169 # For non-Windows, fall back to update.sh. |
148 # TODO(hans): Make update.py replace update.sh completely. | 170 # TODO(hans): Make update.py replace update.sh completely. |
149 | 171 |
150 # This script is called by gclient. gclient opens its hooks subprocesses | 172 # This script is called by gclient. gclient opens its hooks subprocesses |
151 # with (stdout=subprocess.PIPE, stderr=subprocess.STDOUT) and then does | 173 # with (stdout=subprocess.PIPE, stderr=subprocess.STDOUT) and then does |
152 # custom output processing that breaks printing '\r' characters for | 174 # custom output processing that breaks printing '\r' characters for |
153 # single-line updating status messages as printed by curl and wget. | 175 # single-line updating status messages as printed by curl and wget. |
154 # Work around this by setting stderr of the update.sh process to stdin (!): | 176 # Work around this by setting stderr of the update.sh process to stdin (!): |
155 # gclient doesn't redirect stdin, and while stdin itself is read-only, a | 177 # gclient doesn't redirect stdin, and while stdin itself is read-only, a |
156 # dup()ed sys.stdin is writable, try | 178 # dup()ed sys.stdin is writable, try |
157 # fd2 = os.dup(sys.stdin.fileno()); os.write(fd2, 'hi') | 179 # fd2 = os.dup(sys.stdin.fileno()); os.write(fd2, 'hi') |
158 # TODO: Fix gclient instead, http://crbug.com/95350 | 180 # TODO: Fix gclient instead, http://crbug.com/95350 |
159 return subprocess.call( | 181 return subprocess.call( |
160 [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:], | 182 [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:], |
161 stderr=os.fdopen(os.dup(sys.stdin.fileno()))) | 183 stderr=os.fdopen(os.dup(sys.stdin.fileno()))) |
162 | 184 |
163 if not re.search('clang=1', os.environ.get('GYP_DEFINES', '')): | 185 if not re.search('(clang|asan)=1', os.environ.get('GYP_DEFINES', '')): |
164 print 'Skipping Clang update (clang=1 was not set in GYP_DEFINES).' | 186 print 'Skipping Clang update (clang=1 was not set in GYP_DEFINES).' |
165 return 0 | 187 return 0 |
166 | 188 |
167 return UpdateClang() | 189 return UpdateClang() |
168 | 190 |
169 | 191 |
170 if __name__ == '__main__': | 192 if __name__ == '__main__': |
171 sys.exit(main()) | 193 sys.exit(main()) |
OLD | NEW |