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 os | |
8 import sys | |
9 | |
10 import bb_utils | |
11 | |
12 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | |
13 from pylib import buildbot_report | |
14 from pylib import constants | |
15 | |
16 | |
17 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') | |
18 VALID_HOST_TESTS = set(['check_webview_licenses', 'findbugs']) | |
19 EXPERIMENTAL_TARGETS = ['android_experimental'] | |
20 | |
21 # Short hand for RunCmd which is used extensively in this file. | |
22 RunCmd = bb_utils.RunCmd | |
23 | |
24 | |
25 def SrcPath(*path): | |
26 return os.path.join(constants.CHROME_DIR, *path) | |
27 | |
28 | |
29 def CheckWebViewLicenses(): | |
30 buildbot_report.PrintNamedStep('Check licenses for WebView') | |
31 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'], | |
32 warning_code=1) | |
33 | |
34 | |
35 def RunHooks(): | |
36 buildbot_report.PrintNamedStep('runhooks') | |
37 RunCmd(['gclient', 'runhooks'], halt_on_failure=True) | |
38 | |
39 | |
40 def Compile(target, args, experimental=False): | |
41 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'), | |
42 '--build-tool=ninja', | |
43 '--compiler=goma', | |
44 '--target=%s' % target, | |
45 '--goma-dir=%s' % os.path.join(bb_utils.BB_BUILD_DIR, 'goma')] | |
46 if experimental: | |
47 for compile_target in args: | |
48 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target) | |
49 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False) | |
50 else: | |
51 buildbot_report.PrintNamedStep('compile') | |
52 RunCmd(cmd + ['--build-args=%s' % ' '.join(args)], halt_on_failure=True) | |
53 | |
54 | |
55 def ZipBuild(factory_properties, build_properties): | |
56 buildbot_report.PrintNamedStep('Zip build') | |
57 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'), | |
58 '--src-dir', constants.CHROME_DIR, | |
59 '--build-dir', SrcPath('out'), | |
60 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests', | |
61 '--factory-properties', json.dumps(factory_properties), | |
62 '--build-properties', json.dumps(build_properties)]) | |
63 | |
64 | |
65 def ExtractBuild(factory_properties, build_properties): | |
66 buildbot_report.PrintNamedStep('Download and extract build') | |
67 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'), | |
68 '--build-dir', SrcPath('build'), | |
69 '--build-output-dir', SrcPath('out'), | |
70 '--factory-properties', json.dumps(factory_properties), | |
71 '--build-properties', json.dumps(build_properties)], | |
72 warning_code=1) | |
73 | |
74 | |
75 def FindBugs(target): | |
Isaac (away)
2013/06/06 23:32:02
We should avoid passing around a string here. Con
Siva Chandra
2013/06/07 01:42:08
Done.
| |
76 buildbot_report.PrintNamedStep('findbugs') | |
77 if target == 'Release': | |
78 target = '--release-build' | |
79 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py'), target]) | |
Isaac (away)
2013/06/06 23:32:02
we should not pass target arg if build type is deb
Siva Chandra
2013/06/07 01:42:08
Done.
| |
80 RunCmd([SrcPath('tools', 'android', 'findbugs_plugin', 'test', | |
81 'run_findbugs_plugin_tests.py'), | |
Isaac (away)
2013/06/06 23:32:02
nit linebreak
Siva Chandra
2013/06/07 01:42:08
The line is now different. Where do you suggested
Isaac (away)
2013/06/07 02:59:11
looks fine now. The comment was me thinking targe
| |
82 target]) | |
83 | |
84 | |
85 def UpdateClang(): | |
86 RunCmd([SrcPath('tools', 'clang', 'scripts', 'update.sh')]) | |
87 | |
88 | |
89 def main(argv): | |
90 parser = bb_utils.GetParser() | |
91 parser.add_option('--host-tests', help='Comma separated list of host tests.') | |
92 parser.add_option('--build-args', default='All', | |
Isaac (away)
2013/06/06 23:32:02
Is this option being used right now? If not, we s
Siva Chandra
2013/06/07 01:42:08
We will require it downstream.
Isaac (away)
2013/06/07 02:59:11
OK.
| |
93 help='Comma separated list of build targets.') | |
94 parser.add_option('--compile', action='store_true', | |
95 help='Indicate whether a compile step should be run.') | |
96 parser.add_option('--experimental', action='store_true', | |
97 help='Indicate whether to compile experimental targets.') | |
98 parser.add_option('--zipbuild', action='store_true', | |
Isaac (away)
2013/06/06 23:32:02
--zip-build
Siva Chandra
2013/06/07 01:42:08
Done.
| |
99 help='Indicate whether the build should be zipped.') | |
100 parser.add_option('--extract-build', action='store_true', | |
101 help='Indicate whether a build should be downloaded.') | |
102 parser.add_option('--asan-tests-setup', action='store_true', | |
Isaac (away)
2013/06/06 23:32:02
--update-clang
Siva Chandra
2013/06/07 01:42:08
Done.
| |
103 help='Download or build the ASan runtime library.') | |
104 | |
105 options, args = parser.parse_args(argv[1:]) | |
106 if args: | |
107 return sys.exit('Unused args %s' % args) | |
108 | |
109 host_tests = [] | |
110 if options.host_tests: | |
111 host_tests = options.host_tests.split(',') | |
112 unknown_tests = set(host_tests) - VALID_HOST_TESTS | |
113 if unknown_tests: | |
114 return sys.exit('Unknown host tests %s' % list(unknown_tests)) | |
115 | |
116 target = options.factory_properties.get('target', 'Debug') | |
Isaac (away)
2013/06/06 23:32:02
could you rename this per commend above? Perhaps
Siva Chandra
2013/06/07 01:42:08
Done.
| |
117 | |
118 if options.compile: | |
119 if 'check_webview_licenses' in host_tests: | |
120 CheckWebViewLicenses() | |
121 RunHooks() | |
122 Compile(target, options.build_args.split(',')) | |
123 if options.experimental: | |
124 Compile(target, EXPERIMENTAL_TARGETS, True) | |
125 if 'findbugs' in host_tests: | |
126 FindBugs(target) | |
127 if options.zipbuild: | |
128 ZipBuild(options.factory_properties, options.build_properties) | |
129 if options.asan_tests_setup: | |
130 UpdateClang() | |
131 if options.extract_build: | |
132 ExtractBuild(options.factory_properties, options.build_properties) | |
133 | |
134 | |
135 if __name__ == '__main__': | |
136 sys.exit(main(sys.argv)) | |
OLD | NEW |