Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: tools/clang/scripts/update.py

Issue 519823002: Clang/Windows update script: copy the dynamic ASan RTL if present (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 def RunCommand(command, tries=1): 81 def RunCommand(command, tries=1):
82 """Run a command, possibly with multiple retries.""" 82 """Run a command, possibly with multiple retries."""
83 for i in range(0, tries): 83 for i in range(0, tries):
84 print 'Running %s (try #%d)' % (str(command), i + 1) 84 print 'Running %s (try #%d)' % (str(command), i + 1)
85 if subprocess.call(command, shell=True) == 0: 85 if subprocess.call(command, shell=True) == 0:
86 return 86 return
87 print 'Failed.' 87 print 'Failed.'
88 sys.exit(1) 88 sys.exit(1)
89 89
90
90 def CopyFile(src, dst): 91 def CopyFile(src, dst):
91 """Copy a file from src to dst.""" 92 """Copy a file from src to dst."""
92 shutil.copy(src, dst) 93 shutil.copy(src, dst)
93 print "Copying %s to %s" % (src, dst) 94 print "Copying %s to %s" % (src, dst)
94 95
96
97 def CopyDirectoryContents(src, dst, filename_filter=None):
98 """Copy the files from directory src to dst
99 with an optional filename filter."""
100 if not os.path.exists(dst):
101 os.makedirs(dst)
102 for root, _, files in os.walk(src):
103 for f in files:
104 if filename_filter and not re.match(filename_filter, f):
105 continue
106 CopyFile(os.path.join(root, f), dst)
107
108
95 def Checkout(name, url, dir): 109 def Checkout(name, url, dir):
96 """Checkout the SVN module at url into dir. Use name for the log message.""" 110 """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) 111 print "Checking out %s r%s into '%s'" % (name, LLVM_WIN_REVISION, dir)
98 RunCommand(['svn', 'checkout', '--force', 112 RunCommand(['svn', 'checkout', '--force',
99 url + '@' + LLVM_WIN_REVISION, dir], tries=2) 113 url + '@' + LLVM_WIN_REVISION, dir], tries=2)
100 114
101 115
102 def AddCMakeToPath(): 116 def AddCMakeToPath():
103 """Look for CMake and add it to PATH if it's not there already.""" 117 """Look for CMake and add it to PATH if it's not there already."""
104 try: 118 try:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. 174 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time.
161 # TODO(hans): Remove once the regular build above produces this. 175 # TODO(hans): Remove once the regular build above produces this.
162 if not os.path.exists(COMPILER_RT_BUILD_DIR): 176 if not os.path.exists(COMPILER_RT_BUILD_DIR):
163 os.makedirs(COMPILER_RT_BUILD_DIR) 177 os.makedirs(COMPILER_RT_BUILD_DIR)
164 os.chdir(COMPILER_RT_BUILD_DIR) 178 os.chdir(COMPILER_RT_BUILD_DIR)
165 RunCommand(GetVSVersion().SetupScript('x86') + 179 RunCommand(GetVSVersion().SetupScript('x86') +
166 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release', 180 ['&&', 'cmake', '-GNinja', '-DCMAKE_BUILD_TYPE=Release',
167 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR]) 181 '-DLLVM_ENABLE_ASSERTIONS=ON', LLVM_DIR])
168 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) 182 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt'])
169 183
184 asan_rt_bin_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'bin')
185 asan_rt_bin_dst_dir = os.path.join(LLVM_BUILD_DIR, 'bin')
186 CopyDirectoryContents(asan_rt_bin_src_dir, asan_rt_bin_dst_dir,
187 r'^.*-i386\.dll$')
188
170 # TODO(hans): Make this (and the .gypi file) version number independent. 189 # TODO(hans): Make this (and the .gypi file) version number independent.
171 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang', 190 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang',
172 '3.6.0', 'lib', 'windows') 191 '3.6.0', 'lib', 'windows')
173 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', 192 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
174 '3.6.0', 'lib', 'windows') 193 '3.6.0', 'lib', 'windows')
175 194 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir,
176 if not os.path.exists(asan_rt_lib_dst_dir): 195 r'^.*-i386\.lib$')
177 os.makedirs(asan_rt_lib_dst_dir)
178 for root, _, files in os.walk(asan_rt_lib_src_dir):
179 for f in files:
180 if re.match(r'^.*-i386\.lib$', f):
181 CopyFile(os.path.join(root, f), asan_rt_lib_dst_dir)
182 196
183 CopyFile(os.path.join(asan_rt_lib_src_dir, '..', '..', 'asan_blacklist.txt'), 197 CopyFile(os.path.join(asan_rt_lib_src_dir, '..', '..', 'asan_blacklist.txt'),
184 os.path.join(asan_rt_lib_dst_dir, '..', '..')) 198 os.path.join(asan_rt_lib_dst_dir, '..', '..'))
185 199
186 # Make an extra copy of the sanitizer headers, to be put on the include path 200 # Make an extra copy of the sanitizer headers, to be put on the include path
187 # of the fallback compiler. 201 # of the fallback compiler.
188 sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', '3.6.0', 202 sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', '3.6.0',
189 'include', 'sanitizer') 203 'include', 'sanitizer')
190 aux_sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', 204 aux_sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
191 '3.6.0', 'include_sanitizer', 205 '3.6.0', 'include_sanitizer',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 240
227 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')): 241 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')):
228 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).' 242 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).'
229 return 0 243 return 0
230 244
231 return UpdateClang() 245 return UpdateClang()
232 246
233 247
234 if __name__ == '__main__': 248 if __name__ == '__main__':
235 sys.exit(main()) 249 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698