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

Side by Side Diff: tools/bisect_utils.py

Issue 16132012: First pass android support in bisect script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 7 years, 6 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 | « tools/bisect-perf-regression.py ('k') | tools/prepare-bisect-perf-regression.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Set of operations/utilities related to checking out the depot, and 5 """Set of operations/utilities related to checking out the depot, and
6 outputting annotations on the buildbot waterfall. These are intended to be 6 outputting annotations on the buildbot waterfall. These are intended to be
7 used by the bisection scripts.""" 7 used by the bisection scripts."""
8 8
9 import errno 9 import errno
10 import os 10 import os
11 import shutil 11 import shutil
12 import subprocess 12 import subprocess
13 import sys
13 14
14 15
15 GCLIENT_SPEC = """ 16 GCLIENT_SPEC = """
16 solutions = [ 17 solutions = [
17 { "name" : "src", 18 { "name" : "src",
18 "url" : "https://chromium.googlesource.com/chromium/src.git", 19 "url" : "https://chromium.googlesource.com/chromium/src.git",
19 "deps_file" : ".DEPS.git", 20 "deps_file" : ".DEPS.git",
20 "managed" : True, 21 "managed" : True,
21 "custom_deps" : { 22 "custom_deps" : {
22 "src/data/page_cycler": "https://chrome-internal.googlesource.com/" + 23 "src/data/page_cycler": "https://chrome-internal.googlesource.com/" +
23 "chrome/data/page_cycler/.git", 24 "chrome/data/page_cycler/.git",
24 "src/tools/perf/data": "https://chrome-internal.googlesource.com/" + 25 "src/tools/perf/data": "https://chrome-internal.googlesource.com/" +
25 "chrome/tools/perf/data/.git", 26 "chrome/tools/perf/data/.git",
26 "src/v8_bleeding_edge": "git://github.com/v8/v8.git", 27 "src/v8_bleeding_edge": "git://github.com/v8/v8.git",
27 }, 28 },
28 "safesync_url": "", 29 "safesync_url": "",
29 }, 30 },
30 ] 31 ]
31 """ 32 """
32 GCLIENT_SPEC = ''.join([l for l in GCLIENT_SPEC.splitlines()]) 33 GCLIENT_SPEC = ''.join([l for l in GCLIENT_SPEC.splitlines()])
34 GCLIENT_SPEC_ANDROID = GCLIENT_SPEC + "\ntarget_os = ['android']"
33 FILE_DEPS_GIT = '.DEPS.git' 35 FILE_DEPS_GIT = '.DEPS.git'
34 36
35 REPO_PARAMS = [ 37 REPO_PARAMS = [
36 'https://chrome-internal.googlesource.com/chromeos/manifest-internal/', 38 'https://chrome-internal.googlesource.com/chromeos/manifest-internal/',
37 '--repo-url', 39 '--repo-url',
38 'https://git.chromium.org/external/repo.git' 40 'https://git.chromium.org/external/repo.git'
39 ] 41 ]
40 42
41 REPO_SYNC_COMMAND = 'git checkout -f $(git rev-list --max-count=1 '\ 43 REPO_SYNC_COMMAND = 'git checkout -f $(git rev-list --max-count=1 '\
42 '--before=%d remotes/m/master)' 44 '--before=%d remotes/m/master)'
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 params: Unix timestamp to sync to. 137 params: Unix timestamp to sync to.
136 138
137 Returns: 139 Returns:
138 The return code of the call. 140 The return code of the call.
139 """ 141 """
140 repo_sync = REPO_SYNC_COMMAND % timestamp 142 repo_sync = REPO_SYNC_COMMAND % timestamp
141 cmd = ['forall', '-c', REPO_SYNC_COMMAND % timestamp] 143 cmd = ['forall', '-c', REPO_SYNC_COMMAND % timestamp]
142 return RunRepo(cmd) 144 return RunRepo(cmd)
143 145
144 146
145 def RunGClientAndCreateConfig(): 147 def RunGClientAndCreateConfig(opts):
146 """Runs gclient and creates a config containing both src and src-internal. 148 """Runs gclient and creates a config containing both src and src-internal.
147 149
150 Args:
151 opts: The options parsed from the command line through parse_args().
152
148 Returns: 153 Returns:
149 The return code of the call. 154 The return code of the call.
150 """ 155 """
156 spec = GCLIENT_SPEC
157 if opts.target_platform == 'android':
158 spec = GCLIENT_SPEC_ANDROID
159
151 return_code = RunGClient( 160 return_code = RunGClient(
152 ['config', '--spec=%s' % GCLIENT_SPEC, '--git-deps']) 161 ['config', '--spec=%s' % spec, '--git-deps'])
153 return return_code 162 return return_code
154 163
155 164
156 def IsDepsFileBlink(): 165 def IsDepsFileBlink():
157 """Reads .DEPS.git and returns whether or not we're using blink. 166 """Reads .DEPS.git and returns whether or not we're using blink.
158 167
159 Returns: 168 Returns:
160 True if blink, false if webkit. 169 True if blink, false if webkit.
161 """ 170 """
162 locals = {'Var': lambda _: locals["vars"][_], 171 locals = {'Var': lambda _: locals["vars"][_],
(...skipping 20 matching lines...) Expand all
183 192
184 def RunGClientAndSync(reset): 193 def RunGClientAndSync(reset):
185 """Runs gclient and does a normal sync. 194 """Runs gclient and does a normal sync.
186 195
187 Args: 196 Args:
188 reset: Whether to reset any changes to the depot. 197 reset: Whether to reset any changes to the depot.
189 198
190 Returns: 199 Returns:
191 The return code of the call. 200 The return code of the call.
192 """ 201 """
193 params = ['sync', '--verbose'] 202 params = ['sync', '--verbose', '--nohooks']
194 if reset: 203 if reset:
195 params.extend(['--reset', '--force', '--delete_unversioned_trees']) 204 params.extend(['--reset', '--force', '--delete_unversioned_trees'])
196 return RunGClient(params) 205 return RunGClient(params)
197 206
198 207
199 def SetupGitDepot(output_buildbot_annotations, reset): 208 def SetupGitDepot(opts, reset):
200 """Sets up the depot for the bisection. The depot will be located in a 209 """Sets up the depot for the bisection. The depot will be located in a
201 subdirectory called 'bisect'. 210 subdirectory called 'bisect'.
202 211
203 Args: 212 Args:
213 opts: The options parsed from the command line through parse_args().
204 reset: Whether to reset any changes to the depot. 214 reset: Whether to reset any changes to the depot.
205 215
206 Returns: 216 Returns:
207 True if gclient successfully created the config file and did a sync, False 217 True if gclient successfully created the config file and did a sync, False
208 otherwise. 218 otherwise.
209 """ 219 """
210 name = 'Setting up Bisection Depot' 220 name = 'Setting up Bisection Depot'
211 221
212 if output_buildbot_annotations: 222 if opts.output_buildbot_annotations:
213 OutputAnnotationStepStart(name) 223 OutputAnnotationStepStart(name)
214 224
215 passed = False 225 passed = False
216 226
217 if not RunGClientAndCreateConfig(): 227 if not RunGClientAndCreateConfig(opts):
218 passed_deps_check = True 228 passed_deps_check = True
219 if os.path.isfile(os.path.join('src', FILE_DEPS_GIT)): 229 if os.path.isfile(os.path.join('src', FILE_DEPS_GIT)):
220 cwd = os.getcwd() 230 cwd = os.getcwd()
221 os.chdir('src') 231 os.chdir('src')
222 if not IsDepsFileBlink(): 232 if not IsDepsFileBlink():
223 passed_deps_check = RemoveThirdPartyWebkitDirectory() 233 passed_deps_check = RemoveThirdPartyWebkitDirectory()
224 else: 234 else:
225 passed_deps_check = True 235 passed_deps_check = True
226 os.chdir(cwd) 236 os.chdir(cwd)
227 237
228 if passed_deps_check and not RunGClientAndSync(reset): 238 if passed_deps_check and not RunGClientAndSync(reset):
229 passed = True 239 passed = True
230 240
231 if output_buildbot_annotations: 241 if opts.output_buildbot_annotations:
232 print 242 print
233 OutputAnnotationStepClosed() 243 OutputAnnotationStepClosed()
234 244
235 return passed 245 return passed
236 246
237 247
238 def SetupCrosRepo(): 248 def SetupCrosRepo():
239 """Sets up cros repo for bisecting chromeos. 249 """Sets up cros repo for bisecting chromeos.
240 250
241 Returns: 251 Returns:
(...skipping 12 matching lines...) Expand all
254 passed = False 264 passed = False
255 265
256 if not RunRepo(cmd): 266 if not RunRepo(cmd):
257 if not RunRepo(['sync']): 267 if not RunRepo(['sync']):
258 passed = True 268 passed = True
259 os.chdir(cwd) 269 os.chdir(cwd)
260 270
261 return passed 271 return passed
262 272
263 273
274 def SetupAndroidBuildEnvironment(opts):
275 """Sets up the android build environment.
276
277 Args:
278 opts: The options parsed from the command line through parse_args().
279 path_to_file: Path to the bisect script's directory.
280
281 Returns:
282 True if successful.
283 """
284 cwd = os.getcwd()
285 os.chdir('src')
tonyg 2013/06/07 22:02:26 Rather than doing this dance of changing the dir a
shatch 2013/06/07 22:29:05 Done.
286 path_to_file = os.path.join('build', 'android', 'envsetup.sh')
287 proc = subprocess.Popen(['bash', '-c', 'source %s && env' % path_to_file],
288 stdout=subprocess.PIPE,
289 stderr=subprocess.PIPE,
290 bufsize=0)
tonyg 2013/06/07 22:02:26 bufsize isn't necessary, is it?
shatch 2013/06/07 22:29:05 Done.
291 (out, _) = proc.communicate()
292 os.chdir(cwd)
293
294 for line in out.splitlines():
295 (k, _, v) = line.partition('=')
296 os.environ[k] = v
297 return not proc.returncode
298
299
300 def SetupPlatformBuildEnvironment(opts):
301 """Performs any platform specific setup.
302
303 Args:
304 opts: The options parsed from the command line through parse_args().
305 path_to_file: Path to the bisect script's directory.
306
307 Returns:
308 True if successful.
309 """
310 if opts.target_platform == 'android':
311 return SetupAndroidBuildEnvironment(opts)
312 elif opts.target_platform == 'cros':
313 return SetupCrosRepo()
314
315 return False
316
317
264 def CreateBisectDirectoryAndSetupDepot(opts, reset=False): 318 def CreateBisectDirectoryAndSetupDepot(opts, reset=False):
265 """Sets up a subdirectory 'bisect' and then retrieves a copy of the depot 319 """Sets up a subdirectory 'bisect' and then retrieves a copy of the depot
266 there using gclient. 320 there using gclient.
267 321
268 Args: 322 Args:
269 opts: The options parsed from the command line through parse_args(). 323 opts: The options parsed from the command line through parse_args().
270 reset: Whether to reset any changes to the depot. 324 reset: Whether to reset any changes to the depot.
271 325
272 Returns: 326 Returns:
273 Returns 0 on success, otherwise 1. 327 Returns 0 on success, otherwise 1.
274 """ 328 """
275 if not CreateAndChangeToSourceDirectory(opts.working_directory): 329 if not CreateAndChangeToSourceDirectory(opts.working_directory):
276 print 'Error: Could not create bisect directory.' 330 print 'Error: Could not create bisect directory.'
277 print 331 print
278 return 1 332 return 1
279 333
280 if not SetupGitDepot(opts.output_buildbot_annotations, reset): 334 if not SetupGitDepot(opts, reset):
281 print 'Error: Failed to grab source.' 335 print 'Error: Failed to grab source.'
282 print 336 print
283 return 1 337 return 1
284 338
285 return 0 339 return 0
OLDNEW
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | tools/prepare-bisect-perf-regression.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698