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

Side by Side Diff: win_toolchain/get_toolchain_if_necessary.py

Issue 144823003: Automatic toolchain: Use src-internal as signal for Pro (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: check svn access too Created 6 years, 10 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 | Annotate | Revision Log
« 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Downloads and unpacks a toolchain for building on Windows. The contents are 6 """Downloads and unpacks a toolchain for building on Windows. The contents are
7 matched by sha1 which will be updated when the toolchain is updated. 7 matched by sha1 which will be updated when the toolchain is updated.
8 8
9 Having a toolchain script in depot_tools means that it's not versioned 9 Having a toolchain script in depot_tools means that it's not versioned
10 directly with the source code. That is, if the toolchain is upgraded, but 10 directly with the source code. That is, if the toolchain is upgraded, but
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 next time.""" 107 next time."""
108 file_list = GetFileList(root) 108 file_list = GetFileList(root)
109 timestamps_data = { 109 timestamps_data = {
110 'files': [[f, os.stat(f).st_mtime] for f in file_list], 110 'files': [[f, os.stat(f).st_mtime] for f in file_list],
111 'sha1': sha1, 111 'sha1': sha1,
112 } 112 }
113 with open(MakeTimestampsFileName(root), 'wb') as f: 113 with open(MakeTimestampsFileName(root), 'wb') as f:
114 json.dump(timestamps_data, f) 114 json.dump(timestamps_data, f)
115 115
116 116
117 def HaveSrcInternalAccess():
118 """Checks whether access to src-internal is available."""
119 with open(os.devnull, 'w') as nul:
120 git_rc = subprocess.call(
121 ['git', 'remote', 'show',
122 'https://chrome-internal.googlesource.com/chrome/src-internal/'],
123 shell=True, stdout=nul, stderr=nul)
124 svn_rc = subprocess.call(
125 ['svn', 'ls',
126 'svn://svn.chromium.org/chrome-internal/trunk/src-internal/'],
127 shell=True, stdout=nul, stderr=nul)
iannucci 2014/02/04 21:28:29 maybe stdin=nul as well? Why shell=True?
scottmg 2014/02/04 21:37:04 Done.
iannucci 2014/02/04 21:43:58 #!@*#!)$!@(
128 return git_rc == 0 or svn_rc == 0
iannucci 2014/02/04 21:28:29 Probably prefer svn for now, since we know it's fa
scottmg 2014/02/04 21:37:04 Done.
129
130
117 def main(): 131 def main():
118 if not sys.platform.startswith(('cygwin', 'win32')): 132 if not sys.platform.startswith(('cygwin', 'win32')):
119 return 0 133 return 0
120 134
121 if len(sys.argv) != 1: 135 if len(sys.argv) != 1:
122 print >> sys.stderr, 'Unexpected arguments.' 136 print >> sys.stderr, 'Unexpected arguments.'
123 return 1 137 return 1
124 138
125 # Move to depot_tools\win_toolchain where we'll store our files, and where 139 # Move to depot_tools\win_toolchain where we'll store our files, and where
126 # the downloader script is. 140 # the downloader script is.
127 os.chdir(os.path.normpath(os.path.join(BASEDIR))) 141 os.chdir(os.path.normpath(os.path.join(BASEDIR)))
128 # TODO(scottmg): http://crbug.com/323300 Attempt to locate a src-internal
129 # pull and use that as a signal to install Pro also.
130 should_get_pro = os.path.isfile(os.path.join(BASEDIR, '.vspro'))
131 toolchain_dir = '.' 142 toolchain_dir = '.'
132 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files')) 143 target_dir = os.path.normpath(os.path.join(toolchain_dir, 'vs2013_files'))
133 144
134 sha1path = os.path.join(toolchain_dir, 'toolchain_vs2013.hash') 145 sha1path = os.path.join(toolchain_dir, 'toolchain_vs2013.hash')
135 desired_hashes = set() 146 desired_hashes = set()
136 if os.path.isfile(sha1path): 147 if os.path.isfile(sha1path):
137 with open(sha1path, 'rb') as f: 148 with open(sha1path, 'rb') as f:
138 desired_hashes = set(f.read().strip().splitlines()) 149 desired_hashes = set(f.read().strip().splitlines())
139 150
140 # If the current hash doesn't match what we want in the file, nuke and pave. 151 # If the current hash doesn't match what we want in the file, nuke and pave.
141 # Typically this script is only run when the .sha1 one file is updated, but 152 # Typically this script is only run when the .sha1 one file is updated, but
142 # directly calling "gclient runhooks" will also run it, so we cache 153 # directly calling "gclient runhooks" will also run it, so we cache
143 # based on timestamps to make that case fast. 154 # based on timestamps to make that case fast.
144 current_hash = CalculateHash(target_dir) 155 current_hash = CalculateHash(target_dir)
145 if current_hash not in desired_hashes: 156 if current_hash not in desired_hashes:
157 should_get_pro = (os.path.isfile(os.path.join(BASEDIR, '.vspro')) or
158 HaveSrcInternalAccess())
146 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' % 159 print('Windows toolchain out of date or doesn\'t exist, updating (%s)...' %
147 ('Pro' if should_get_pro else 'Express')) 160 ('Pro' if should_get_pro else 'Express'))
148 # This stays resident and will make the rmdir below fail. 161 # This stays resident and will make the rmdir below fail.
149 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe']) 162 subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'])
150 if os.path.isdir(target_dir): 163 if os.path.isdir(target_dir):
151 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True) 164 subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True)
152 args = [sys.executable, 165 args = [sys.executable,
153 'toolchain2013.py', 166 'toolchain2013.py',
154 '--targetdir', target_dir] 167 '--targetdir', target_dir]
155 if not should_get_pro: 168 if not should_get_pro:
156 args.append('--express') 169 args.append('--express')
157 subprocess.check_call(args) 170 subprocess.check_call(args)
158 current_hash = CalculateHash(target_dir) 171 current_hash = CalculateHash(target_dir)
159 if current_hash not in desired_hashes: 172 if current_hash not in desired_hashes:
160 print >> sys.stderr, ( 173 print >> sys.stderr, (
161 'Got wrong hash after pulling a new toolchain. ' 174 'Got wrong hash after pulling a new toolchain. '
162 'Wanted one of \'%s\', got \'%s\'.' % ( 175 'Wanted one of \'%s\', got \'%s\'.' % (
163 desired_hashes, current_hash)) 176 desired_hashes, current_hash))
164 return 1 177 return 1
165 SaveTimestampsAndHash(target_dir, current_hash) 178 SaveTimestampsAndHash(target_dir, current_hash)
166 179
167 return 0 180 return 0
168 181
169 182
170 if __name__ == '__main__': 183 if __name__ == '__main__':
171 sys.exit(main()) 184 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