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

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

Issue 16688002: Port remaining android buildbot code into python (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/buildbot/bb_run_bot.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 #!/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 json
7 import os 6 import os
8 import sys 7 import sys
9 8
10 import bb_utils 9 import bb_utils
11 10
12 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 11 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
13 from pylib import buildbot_report 12 from pylib import buildbot_report
14 from pylib import constants 13 from pylib import constants
15 14
16 15
17 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')
18 VALID_HOST_TESTS = set(['check_webview_licenses', 'findbugs']) 17 VALID_HOST_TESTS = set(['check_webview_licenses', 'findbugs'])
19 EXPERIMENTAL_TARGETS = ['android_experimental'] 18 EXPERIMENTAL_TARGETS = ['android_experimental']
20 19
21 # Short hand for RunCmd which is used extensively in this file. 20 # Short hand for RunCmd which is used extensively in this file.
22 RunCmd = bb_utils.RunCmd 21 RunCmd = bb_utils.RunCmd
23 22
24 23
25 def SrcPath(*path): 24 def SrcPath(*path):
26 return os.path.join(constants.DIR_SOURCE_ROOT, *path) 25 return os.path.join(constants.DIR_SOURCE_ROOT, *path)
27 26
28 27
29 def CheckWebViewLicenses(): 28 def CheckWebViewLicenses():
30 buildbot_report.PrintNamedStep('Check licenses for WebView') 29 buildbot_report.PrintNamedStep('check_licenses')
31 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'], 30 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'],
32 warning_code=1) 31 warning_code=1)
33 32
34 33
35 def RunHooks(): 34 def RunHooks(build_type):
35 RunCmd([SrcPath('build', 'landmines.py')])
36 build_path = SrcPath('out', build_type)
37 landmine_path = os.path.join(build_path, '.landmines_triggered')
38 clobber_env = os.environ.get('BUILDBOT_CLOBBER')
39 if clobber_env or os.path.isfile(landmine_path):
40 buildbot_report.PrintNamedStep('Clobber')
41 if not clobber_env:
42 print 'Clobbering due to triggered landmines:'
43 with open(landmine_path) as f:
44 print f.read()
45 RunCmd(['rm', '-rf', build_path])
46
36 buildbot_report.PrintNamedStep('runhooks') 47 buildbot_report.PrintNamedStep('runhooks')
37 RunCmd(['gclient', 'runhooks'], halt_on_failure=True) 48 RunCmd(['gclient', 'runhooks'], halt_on_failure=True)
38 49
39 50
40 def Compile(build_type, args, experimental=False): 51 def Compile(build_type, args, experimental=False):
41 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'), 52 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'),
42 '--build-tool=ninja', 53 '--build-tool=ninja',
43 '--compiler=goma', 54 '--compiler=goma',
44 '--target=%s' % build_type, 55 '--target=%s' % build_type,
45 '--goma-dir=%s' % os.path.join(bb_utils.BB_BUILD_DIR, 'goma')] 56 '--goma-dir=%s' % bb_utils.GOMA_DIR]
46 if experimental: 57 if experimental:
47 for compile_target in args: 58 for compile_target in args:
48 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target) 59 buildbot_report.PrintNamedStep('Experimental Compile %s' % compile_target)
49 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False) 60 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False)
50 else: 61 else:
51 buildbot_report.PrintNamedStep('compile') 62 buildbot_report.PrintNamedStep('compile')
52 RunCmd(cmd + ['--build-args=%s' % ' '.join(args)], halt_on_failure=True) 63 RunCmd(cmd + ['--build-args=%s' % ' '.join(args)], halt_on_failure=True)
53 64
54 65
55 def ZipBuild(factory_properties, build_properties): 66 def ZipBuild(properties):
56 buildbot_report.PrintNamedStep('Zip build') 67 buildbot_report.PrintNamedStep('zip_build')
57 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'), 68 RunCmd([
58 '--src-dir', constants.DIR_SOURCE_ROOT, 69 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'),
59 '--build-dir', SrcPath('out'), 70 '--src-dir', constants.DIR_SOURCE_ROOT,
60 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests', 71 '--build-dir', SrcPath('out'),
61 '--factory-properties', json.dumps(factory_properties), 72 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests']
62 '--build-properties', json.dumps(build_properties)]) 73 + properties)
63 74
64 75
65 def ExtractBuild(factory_properties, build_properties): 76 def ExtractBuild(properties):
66 buildbot_report.PrintNamedStep('Download and extract build') 77 buildbot_report.PrintNamedStep('extract_build')
67 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'), 78 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'),
68 '--build-dir', SrcPath('build'), 79 '--build-dir', SrcPath('build'),
69 '--build-output-dir', SrcPath('out'), 80 '--build-output-dir', SrcPath('out')] + properties,
70 '--factory-properties', json.dumps(factory_properties),
71 '--build-properties', json.dumps(build_properties)],
72 warning_code=1) 81 warning_code=1)
73 82
74 83
75 def FindBugs(is_release): 84 def FindBugs(is_release):
76 buildbot_report.PrintNamedStep('findbugs') 85 buildbot_report.PrintNamedStep('findbugs')
77 build_type = [] 86 build_type = []
78 if is_release: 87 if is_release:
79 build_type = ['--release-build'] 88 build_type = ['--release-build']
80 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type) 89 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type)
81 RunCmd([SrcPath( 90 RunCmd([SrcPath(
82 'tools', 'android', 'findbugs_plugin', 'test', 91 'tools', 'android', 'findbugs_plugin', 'test',
83 'run_findbugs_plugin_tests.py')] + build_type) 92 'run_findbugs_plugin_tests.py')] + build_type)
84 93
85 94
86 def UpdateClang():
87 RunCmd([SrcPath('tools', 'clang', 'scripts', 'update.sh')])
88
89
90 def main(argv): 95 def main(argv):
91 parser = bb_utils.GetParser() 96 parser = bb_utils.GetParser()
92 parser.add_option('--host-tests', help='Comma separated list of host tests.') 97 parser.add_option('--host-tests', help='Comma separated list of host tests.')
93 parser.add_option('--build-args', default='All', 98 parser.add_option('--build-args', default='All',
94 help='Comma separated list of build targets.') 99 help='Comma separated list of build targets.')
95 parser.add_option('--compile', action='store_true', 100 parser.add_option('--compile', action='store_true',
96 help='Indicate whether a compile step should be run.') 101 help='Indicate whether a compile step should be run.')
97 parser.add_option('--experimental', action='store_true', 102 parser.add_option('--experimental', action='store_true',
98 help='Indicate whether to compile experimental targets.') 103 help='Indicate whether to compile experimental targets.')
99 parser.add_option('--zip-build', action='store_true', 104 parser.add_option('--zip-build', action='store_true',
100 help='Indicate whether the build should be zipped.') 105 help='Indicate whether the build should be zipped.')
101 parser.add_option('--extract-build', action='store_true', 106 parser.add_option('--extract-build', action='store_true',
102 help='Indicate whether a build should be downloaded.') 107 help='Indicate whether a build should be downloaded.')
103 parser.add_option('--update-clang', action='store_true',
104 help='Download or build the ASan runtime library.')
105 108
106 options, args = parser.parse_args(argv[1:]) 109 options, args = parser.parse_args(argv[1:])
107 if args: 110 if args:
108 return sys.exit('Unused args %s' % args) 111 return sys.exit('Unused args %s' % args)
109 112
110 host_tests = [] 113 host_tests = []
111 if options.host_tests: 114 if options.host_tests:
112 host_tests = options.host_tests.split(',') 115 host_tests = options.host_tests.split(',')
113 unknown_tests = set(host_tests) - VALID_HOST_TESTS 116 unknown_tests = set(host_tests) - VALID_HOST_TESTS
114 if unknown_tests: 117 if unknown_tests:
115 return sys.exit('Unknown host tests %s' % list(unknown_tests)) 118 return sys.exit('Unknown host tests %s' % list(unknown_tests))
116 119
117 build_type = options.factory_properties.get('target', 'Debug') 120 build_type = options.factory_properties.get('target', 'Debug')
118 121
119 if options.compile: 122 if options.compile:
120 if 'check_webview_licenses' in host_tests: 123 if 'check_webview_licenses' in host_tests:
121 CheckWebViewLicenses() 124 CheckWebViewLicenses()
122 RunHooks() 125 RunHooks(build_type)
123 Compile(build_type, options.build_args.split(',')) 126 Compile(build_type, options.build_args.split(','))
124 if options.experimental: 127 if options.experimental:
125 Compile(build_type, EXPERIMENTAL_TARGETS, True) 128 Compile(build_type, EXPERIMENTAL_TARGETS, True)
126 if 'findbugs' in host_tests: 129 if 'findbugs' in host_tests:
127 FindBugs(build_type == 'Release') 130 FindBugs(build_type == 'Release')
128 if options.zip_build: 131 if options.zip_build:
129 ZipBuild(options.factory_properties, options.build_properties) 132 ZipBuild(bb_utils.EncodeProperties(options))
130 if options.update_clang:
131 UpdateClang()
132 if options.extract_build: 133 if options.extract_build:
133 ExtractBuild(options.factory_properties, options.build_properties) 134 ExtractBuild(bb_utils.EncodeProperties(options))
134 135
135 136
136 if __name__ == '__main__': 137 if __name__ == '__main__':
137 sys.exit(main(sys.argv)) 138 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_device_steps.py ('k') | build/android/buildbot/bb_run_bot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698