OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 import json | |
7 import optparse | |
8 import os | |
9 import sys | |
10 | |
11 from bb_utils import ConvertJson | |
12 from bb_utils import OptParserError | |
13 from bb_utils import RunCmd | |
14 | |
15 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | |
16 from pylib import buildbot_report | |
17 from pylib import constants | |
18 | |
19 | |
20 SLAVE_SCRIPTS_DIR = os.path.join(constants.BB_BUILD_DIR, 'scripts', 'slave') | |
21 COMPILE_SCRIPT = os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py') | |
22 ZIP_BUILD_SCRIPT = os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py') | |
23 WEBVIEW_LICENSES_SCRIPT = 'android_webview/tools/webview_licenses.py' | |
24 FINDBUGS_DIFF_SCRIPT = 'build/android/findbugs_diff.py' | |
25 FINDBUGS_PLUGIN_TESTS_SCRIPT = ( | |
26 'tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py') | |
27 | |
28 VALID_HOST_STEPS = set(['check_webview_licenses', | |
29 'compile', | |
30 'compile_experimental', | |
31 'findbugs', | |
32 'zip_build']) | |
33 | |
34 BUILD_DIR = 'out' | |
35 BUILD_TOOL = 'ninja' | |
36 COMPILER = 'goma' | |
Isaac (away)
2013/05/29 20:28:07
remove variables on lines 21-26, 34-36 and add the
Siva Chandra
2013/06/04 00:34:03
Done.
| |
37 EXCLUDE_FILES = 'lib.target,gen,android_webview,jingle_unittests' | |
38 EXPERIMENTAL_TARGETS = ['android_experimental'] | |
39 | |
40 | |
41 def CheckWebViewLicensesStep(): | |
42 buildbot_report.PrintNamedStep('Check licenses for WebView') | |
43 def RetcodeCallback(code): | |
44 if code == 1: | |
45 buildbot_report.PrintWarning() | |
46 if code > 1: | |
47 buildbot_report.PrintError() | |
48 RunCmd([WEBVIEW_LICENSES_SCRIPT, 'scan'], retcode_callback=RetcodeCallback) | |
49 | |
50 | |
51 def CompileStep(target, args, experimental=False): | |
52 opts = ['--build-tool=%s' % BUILD_TOOL, | |
53 '--compiler=%s' % COMPILER, | |
54 '--target=%s' % target, | |
55 '--goma-dir=%s' % constants.GOMA_DIR,] | |
56 if experimental: | |
57 for compile_target in args: | |
58 buildbot_report.PrintNamedStep('Exerimental Compile %s' % compile_target) | |
59 RunCmd([COMPILE_SCRIPT] + opts + ['--build-args=%s' % compile_target], | |
60 flunk_on_failure=False) | |
61 else: | |
62 buildbot_report.PrintNamedStep('compile') | |
63 RunCmd([COMPILE_SCRIPT] + opts + ['--build-args=%s' % ' '.join(args)]) | |
64 | |
65 | |
66 def ZipBuildStep(factory_properties, build_properties): | |
67 buildbot_report.PrintNamedStep('Zip build') | |
68 args = ['--src-dir', constants.CHROME_DIR, | |
69 '--build-dir', BUILD_DIR, | |
70 '--exclude-files', EXCLUDE_FILES, | |
71 '--factory-properties', factory_properties, | |
72 '--build-properties', build_properties] | |
73 RunCmd([ZIP_BUILD_SCRIPT] + args) | |
74 | |
75 | |
76 def FindBugsStep(target): | |
77 buildbot_report.PrintNamedStep('findbugs') | |
78 if target == 'Release': | |
79 target = '--release-build' | |
80 RunCmd([FINDBUGS_DIFF_SCRIPT, target]) | |
81 RunCmd([FINDBUGS_PLUGIN_TESTS_SCRIPT, target]) | |
82 | |
83 | |
84 def main(argv): | |
85 buildbot_report.PrintNamedStep('Host Steps') | |
86 parser = optparse.OptionParser() | |
87 parser.add_option('--steps', default='compile,zip_build', | |
88 help='Comma separated list of host steps.') | |
89 parser.add_option('--build-args', default='All', | |
90 help='Comma separated list of build targets.') | |
91 parser.add_option('--factory-properties', action='callback', | |
92 callback=ConvertJson, type='string', default={}, | |
93 help='factory properties in JSON format.') | |
94 parser.add_option('--build-properties', action='callback', | |
95 callback=ConvertJson, type='string', default={}, | |
96 help='build properties in JSON format.') | |
97 | |
98 options, args = parser.parse_args(argv[1:]) | |
99 if args: | |
100 return OptParserError(parser, 'Unused args %s' % args) | |
101 | |
102 steps = options.steps.split(',') | |
103 unknown_steps = set(steps) - VALID_HOST_STEPS | |
104 if unknown_steps: | |
105 return OptParserError(parser, 'Unknown steps %s' % list(unknown_steps)) | |
106 | |
107 target = options.factory_properties.get('target', 'Debug') | |
108 for step in steps: | |
109 if step == 'check_webview_licenses': | |
Isaac (away)
2013/05/29 20:28:07
can we make check_webview_licenses and findbugs a
Siva Chandra
2013/06/04 00:34:03
Done.
| |
110 CheckWebViewLicensesStep() | |
111 if step == 'compile': | |
Isaac (away)
2013/05/29 20:28:07
don't we always want to compile?
Siva Chandra
2013/06/04 00:34:03
Done. Compile comes from a boolean option now.
| |
112 CompileStep(target, options.build_args.split(',')) | |
113 if step == 'compile_experimental': | |
Isaac (away)
2013/05/29 20:28:07
add option --experimental instead of separate step
Siva Chandra
2013/06/04 00:34:03
Done.
| |
114 CompileStep(target, EXPERIMENTAL_TARGETS, True) | |
115 if step == 'findbugs': | |
116 FindBugsStep(target) | |
117 if step == 'zip_build': | |
Isaac (away)
2013/05/29 20:28:07
add '--zip-build' option
Siva Chandra
2013/06/04 00:34:03
Done.
| |
118 ZipBuildStep(json.dumps(options.factory_properties), | |
119 json.dumps(options.build_properties)) | |
120 | |
121 | |
122 if __name__ == '__main__': | |
123 sys.exit(main(sys.argv)) | |
OLD | NEW |