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

Side by Side Diff: build/android/buildbot/bb_host_steps.py

Issue 15817022: [Android] Refactor bb_host_steps to prepare for downstream usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not use collections.OrderedDict as the botr might be running Python less than 2.7 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 | Annotate | Revision Log
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 import os 6 import os
7 import sys 7 import sys
8 8
9 import bb_utils 9 import bb_utils
10 10
11 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 11 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
12 from pylib import buildbot_report 12 from pylib import buildbot_report
13 from pylib import constants 13 from pylib import constants
14 14
15 15
16 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') 16 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave')
17 VALID_HOST_TESTS = set(['check_webview_licenses', 'findbugs']) 17 VALID_HOST_TESTS = set(['check_webview_licenses', 'findbugs'])
18 EXPERIMENTAL_TARGETS = ['android_experimental'] 18 EXPERIMENTAL_TARGETS = ['android_experimental']
19 19
20 # Short hand for RunCmd which is used extensively in this file. 20 # Short hand for RunCmd which is used extensively in this file.
21 RunCmd = bb_utils.RunCmd 21 RunCmd = bb_utils.RunCmd
22 22
23 23
24 def SrcPath(*path): 24 def SrcPath(*path):
25 return os.path.join(constants.DIR_SOURCE_ROOT, *path) 25 return os.path.join(constants.DIR_SOURCE_ROOT, *path)
26 26
27 27
28 def CheckWebViewLicenses(): 28 def CheckWebViewLicenses(_):
29 buildbot_report.PrintNamedStep('check_licenses') 29 buildbot_report.PrintNamedStep('check_licenses')
30 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'], 30 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'],
31 warning_code=1) 31 warning_code=1)
32 32
33 33
34 def RunHooks(build_type): 34 def RunHooks(options):
35 RunCmd([SrcPath('build', 'landmines.py')]) 35 RunCmd([SrcPath('build', 'landmines.py')])
36 build_type = options.factory_properties.get('target', 'Debug')
Isaac (away) 2013/06/12 19:49:05 check out bb_device_steps for how to put this into
Siva Chandra 2013/06/12 21:21:35 Done.
36 build_path = SrcPath('out', build_type) 37 build_path = SrcPath('out', build_type)
37 landmine_path = os.path.join(build_path, '.landmines_triggered') 38 landmine_path = os.path.join(build_path, '.landmines_triggered')
38 clobber_env = os.environ.get('BUILDBOT_CLOBBER') 39 clobber_env = os.environ.get('BUILDBOT_CLOBBER')
39 if clobber_env or os.path.isfile(landmine_path): 40 if clobber_env or os.path.isfile(landmine_path):
40 buildbot_report.PrintNamedStep('Clobber') 41 buildbot_report.PrintNamedStep('Clobber')
41 if not clobber_env: 42 if not clobber_env:
42 print 'Clobbering due to triggered landmines:' 43 print 'Clobbering due to triggered landmines:'
43 with open(landmine_path) as f: 44 with open(landmine_path) as f:
44 print f.read() 45 print f.read()
45 RunCmd(['rm', '-rf', build_path]) 46 RunCmd(['rm', '-rf', build_path])
46 47
47 buildbot_report.PrintNamedStep('runhooks') 48 buildbot_report.PrintNamedStep('runhooks')
48 RunCmd(['gclient', 'runhooks'], halt_on_failure=True) 49 RunCmd(['gclient', 'runhooks'], halt_on_failure=True)
49 50
50 51
51 def Compile(build_type, args, experimental=False): 52 def Compile(options):
52 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'), 53 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'),
53 '--build-tool=ninja', 54 '--build-tool=ninja',
54 '--compiler=goma', 55 '--compiler=goma',
55 '--target=%s' % build_type, 56 '--target=%s' % options.factory_properties.get('target', 'Debug'),
56 '--goma-dir=%s' % bb_utils.GOMA_DIR] 57 '--goma-dir=%s' % bb_utils.GOMA_DIR]
57 if experimental: 58 build_args = ' '.join(options.build_args.split(','))
58 for compile_target in args: 59 buildbot_report.PrintNamedStep('compile')
60 RunCmd(cmd + ['--build-args=%s' % build_args], halt_on_failure=True)
61 if options.experimental:
62 for compile_target in EXPERIMENTAL_TARGETS:
59 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target) 63 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target)
60 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False) 64 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False)
61 else:
Isaac (away) 2013/06/12 19:49:05 what happened here?
Siva Chandra 2013/06/12 21:21:35 This change assumes that one would not request an
62 buildbot_report.PrintNamedStep('compile')
63 RunCmd(cmd + ['--build-args=%s' % ' '.join(args)], halt_on_failure=True)
64 65
65 66
66 def ZipBuild(properties): 67 def ZipBuild(options):
67 buildbot_report.PrintNamedStep('zip_build') 68 buildbot_report.PrintNamedStep('zip_build')
68 RunCmd([ 69 RunCmd([
69 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'), 70 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'),
70 '--src-dir', constants.DIR_SOURCE_ROOT, 71 '--src-dir', constants.DIR_SOURCE_ROOT,
71 '--build-dir', SrcPath('out'), 72 '--build-dir', SrcPath('out'),
72 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests'] 73 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests']
73 + properties) 74 + bb_utils.EncodeProperties(options))
74 75
75 76
76 def ExtractBuild(properties): 77 def ExtractBuild(options):
77 buildbot_report.PrintNamedStep('extract_build') 78 buildbot_report.PrintNamedStep('extract_build')
78 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'), 79 RunCmd(
79 '--build-dir', SrcPath('build'), 80 [os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'),
80 '--build-output-dir', SrcPath('out')] + properties, 81 '--build-dir', SrcPath('build'), '--build-output-dir',
81 warning_code=1) 82 SrcPath('out')] + bb_utils.EncodeProperties(options),
83 warning_code=1)
82 84
83 85
84 def FindBugs(is_release): 86 def FindBugs(options):
85 buildbot_report.PrintNamedStep('findbugs') 87 buildbot_report.PrintNamedStep('findbugs')
86 build_type = [] 88 build_type = []
87 if is_release: 89 if options.factory_properties.get('target', 'Debug') == 'Release':
88 build_type = ['--release-build'] 90 build_type = ['--release-build']
89 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type) 91 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type)
90 RunCmd([SrcPath( 92 RunCmd([SrcPath(
91 'tools', 'android', 'findbugs_plugin', 'test', 93 'tools', 'android', 'findbugs_plugin', 'test',
92 'run_findbugs_plugin_tests.py')] + build_type) 94 'run_findbugs_plugin_tests.py')] + build_type)
93 95
94 96
95 def BisectPerfRegression(): 97 def BisectPerfRegression(_):
96 buildbot_report.PrintNamedStep('Bisect Perf Regression') 98 buildbot_report.PrintNamedStep('Bisect Perf Regression')
97 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'), 99 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'),
98 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)]) 100 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)])
99 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'), 101 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'),
100 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir), 102 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir),
101 '-p', bb_utils.GOMA_DIR]) 103 '-p', bb_utils.GOMA_DIR])
102 104
103 105
106 def GetHostSteps():
107 return [
108 ('runhooks', RunHooks),
Isaac (away) 2013/06/12 19:49:05 this should not be a separate step, it should be c
Siva Chandra 2013/06/12 21:21:35 Done.
109 ('check_webview_licenses', CheckWebViewLicenses),
110 ('bisect_perf_regression', BisectPerfRegression),
111 ('compile', Compile),
112 ('extract_build', ExtractBuild),
113 ('findbugs', FindBugs),
114 ('zip_build', ZipBuild)
115 ]
116
117
104 def main(argv): 118 def main(argv):
105 parser = bb_utils.GetParser() 119 parser = bb_utils.GetParser()
106 parser.add_option('--host-tests', help='Comma separated list of host tests.') 120 parser.add_option('--steps', help='Comma separated list of host tests.')
107 parser.add_option('--build-args', default='All', 121 parser.add_option('--build-args', default='All',
108 help='Comma separated list of build targets.') 122 help='Comma separated list of build targets.')
109 parser.add_option('--compile', action='store_true',
110 help='Indicate whether a compile step should be run.')
111 parser.add_option('--experimental', action='store_true', 123 parser.add_option('--experimental', action='store_true',
112 help='Indicate whether to compile experimental targets.') 124 help='Indicate whether to compile experimental targets.')
113 parser.add_option('--zip-build', action='store_true',
114 help='Indicate whether the build should be zipped.')
115 parser.add_option('--extract-build', action='store_true',
116 help='Indicate whether a build should be downloaded.')
117 parser.add_option('--bisect-perf-regression', action='store_true',
118 help='Bisect a perf regression.')
119 125
120 options, args = parser.parse_args(argv[1:]) 126 options, args = parser.parse_args(argv[1:])
121 if args: 127 if args:
122 return sys.exit('Unused args %s' % args) 128 return sys.exit('Unused args %s' % args)
123 129
124 host_tests = [] 130 steps = []
125 if options.host_tests: 131 host_steps = GetHostSteps()
126 host_tests = options.host_tests.split(',') 132 if options.steps:
Isaac (away) 2013/06/12 19:49:05 lines 132-140 should be moved to a function, like
Siva Chandra 2013/06/12 21:21:35 Done.
127 unknown_tests = set(host_tests) - VALID_HOST_TESTS 133 steps = options.steps.split(',')
128 if unknown_tests: 134 unknown_steps = set(steps) - set([x for x, _ in host_steps])
Isaac (away) 2013/06/12 19:49:05 generator is preferred style: set(step for step,
Siva Chandra 2013/06/12 21:21:35 Done.
129 return sys.exit('Unknown host tests %s' % list(unknown_tests)) 135 if unknown_steps:
136 return sys.exit('Unknown host steps %s' % list(unknown_steps))
130 137
131 build_type = options.factory_properties.get('target', 'Debug') 138 for step, cmd in host_steps:
132 139 if step in steps:
133 if options.bisect_perf_regression: 140 cmd(options)
134 BisectPerfRegression()
135 if options.compile:
136 if 'check_webview_licenses' in host_tests:
137 CheckWebViewLicenses()
138 RunHooks(build_type)
139 Compile(build_type, options.build_args.split(','))
140 if options.experimental:
141 Compile(build_type, EXPERIMENTAL_TARGETS, True)
142 if 'findbugs' in host_tests:
143 FindBugs(build_type == 'Release')
144 if options.zip_build:
145 ZipBuild(bb_utils.EncodeProperties(options))
146 if options.extract_build:
147 ExtractBuild(bb_utils.EncodeProperties(options))
148 141
149 142
150 if __name__ == '__main__': 143 if __name__ == '__main__':
151 sys.exit(main(sys.argv)) 144 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/buildbot/bb_run_bot.py » ('j') | build/android/buildbot/bb_run_bot.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698