OLD | NEW |
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(build_type): |
35 RunCmd([SrcPath('build', 'landmines.py')]) | 35 RunCmd([SrcPath('build', 'landmines.py')]) |
36 build_path = SrcPath('out', build_type) | 36 build_path = SrcPath('out', build_type) |
37 landmine_path = os.path.join(build_path, '.landmines_triggered') | 37 landmine_path = os.path.join(build_path, '.landmines_triggered') |
38 clobber_env = os.environ.get('BUILDBOT_CLOBBER') | 38 clobber_env = os.environ.get('BUILDBOT_CLOBBER') |
39 if clobber_env or os.path.isfile(landmine_path): | 39 if clobber_env or os.path.isfile(landmine_path): |
40 buildbot_report.PrintNamedStep('Clobber') | 40 buildbot_report.PrintNamedStep('Clobber') |
41 if not clobber_env: | 41 if not clobber_env: |
42 print 'Clobbering due to triggered landmines:' | 42 print 'Clobbering due to triggered landmines:' |
43 with open(landmine_path) as f: | 43 with open(landmine_path) as f: |
44 print f.read() | 44 print f.read() |
45 RunCmd(['rm', '-rf', build_path]) | 45 RunCmd(['rm', '-rf', build_path]) |
46 | 46 |
47 buildbot_report.PrintNamedStep('runhooks') | 47 buildbot_report.PrintNamedStep('runhooks') |
48 RunCmd(['gclient', 'runhooks'], halt_on_failure=True) | 48 RunCmd(['gclient', 'runhooks'], halt_on_failure=True) |
49 | 49 |
50 | 50 |
51 def Compile(build_type, args, experimental=False): | 51 def Compile(options): |
| 52 RunHooks(options.target) |
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.target, |
56 '--goma-dir=%s' % bb_utils.GOMA_DIR] | 57 '--goma-dir=%s' % bb_utils.GOMA_DIR] |
57 if experimental: | 58 build_targets = options.build_targets.split(',') |
58 for compile_target in args: | 59 buildbot_report.PrintNamedStep('compile') |
| 60 for build_target in build_targets: |
| 61 RunCmd(cmd + ['--build-args=%s' % build_target], halt_on_failure=True) |
| 62 if options.experimental: |
| 63 for compile_target in EXPERIMENTAL_TARGETS: |
59 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target) | 64 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target) |
60 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False) | 65 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False) |
61 else: | |
62 buildbot_report.PrintNamedStep('compile') | |
63 RunCmd(cmd + ['--build-args=%s' % ' '.join(args)], halt_on_failure=True) | |
64 | 66 |
65 | 67 |
66 def ZipBuild(properties): | 68 def ZipBuild(options): |
67 buildbot_report.PrintNamedStep('zip_build') | 69 buildbot_report.PrintNamedStep('zip_build') |
68 RunCmd([ | 70 RunCmd([ |
69 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'), | 71 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'), |
70 '--src-dir', constants.DIR_SOURCE_ROOT, | 72 '--src-dir', constants.DIR_SOURCE_ROOT, |
71 '--build-dir', SrcPath('out'), | 73 '--build-dir', SrcPath('out'), |
72 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests'] | 74 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests'] |
73 + properties) | 75 + bb_utils.EncodeProperties(options)) |
74 | 76 |
75 | 77 |
76 def ExtractBuild(properties): | 78 def ExtractBuild(options): |
77 buildbot_report.PrintNamedStep('extract_build') | 79 buildbot_report.PrintNamedStep('extract_build') |
78 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'), | 80 RunCmd( |
79 '--build-dir', SrcPath('build'), | 81 [os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'), |
80 '--build-output-dir', SrcPath('out')] + properties, | 82 '--build-dir', SrcPath('build'), '--build-output-dir', |
81 warning_code=1) | 83 SrcPath('out')] + bb_utils.EncodeProperties(options), |
| 84 warning_code=1) |
82 | 85 |
83 | 86 |
84 def FindBugs(is_release): | 87 def FindBugs(options): |
85 buildbot_report.PrintNamedStep('findbugs') | 88 buildbot_report.PrintNamedStep('findbugs') |
86 build_type = [] | 89 build_type = [] |
87 if is_release: | 90 if options.target == 'Release': |
88 build_type = ['--release-build'] | 91 build_type = ['--release-build'] |
89 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type) | 92 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type) |
90 RunCmd([SrcPath( | 93 RunCmd([SrcPath( |
91 'tools', 'android', 'findbugs_plugin', 'test', | 94 'tools', 'android', 'findbugs_plugin', 'test', |
92 'run_findbugs_plugin_tests.py')] + build_type) | 95 'run_findbugs_plugin_tests.py')] + build_type) |
93 | 96 |
94 | 97 |
95 def BisectPerfRegression(): | 98 def BisectPerfRegression(_): |
96 buildbot_report.PrintNamedStep('Bisect Perf Regression') | 99 buildbot_report.PrintNamedStep('Bisect Perf Regression') |
97 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'), | 100 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'), |
98 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)]) | 101 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)]) |
99 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'), | 102 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'), |
100 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir), | 103 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir), |
101 '-p', bb_utils.GOMA_DIR]) | 104 '-p', bb_utils.GOMA_DIR]) |
102 | 105 |
103 | 106 |
| 107 def GetHostSteps(): |
| 108 return [ |
| 109 ('compile', Compile), |
| 110 ('extract_build', ExtractBuild), |
| 111 ('check_webview_licenses', CheckWebViewLicenses), |
| 112 ('bisect_perf_regression', BisectPerfRegression), |
| 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-targets', 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 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
125 if options.host_tests: | |
126 host_tests = options.host_tests.split(',') | |
127 unknown_tests = set(host_tests) - VALID_HOST_TESTS | |
128 if unknown_tests: | |
129 return sys.exit('Unknown host tests %s' % list(unknown_tests)) | |
130 | 131 |
131 build_type = options.factory_properties.get('target', 'Debug') | 132 bb_utils.RunSteps(GetHostSteps(), options) |
132 | |
133 if options.bisect_perf_regression: | |
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 | 133 |
149 | 134 |
150 if __name__ == '__main__': | 135 if __name__ == '__main__': |
151 sys.exit(main(sys.argv)) | 136 sys.exit(main(sys.argv)) |
OLD | NEW |