Move prefs::kLastPolicyStatisticsUpdate to the policy component.
[chromium-blink-merge.git] / build / android / buildbot / bb_host_steps.py
blobe27ba08bbcc9b4265182acb9721821d66fe7c8c3
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 import os
7 import sys
9 import bb_utils
10 import bb_annotations
12 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
13 from pylib import constants
16 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave')
17 VALID_HOST_TESTS = set(['check_webview_licenses', 'findbugs'])
18 EXPERIMENTAL_TARGETS = ['android_experimental']
20 # Short hand for RunCmd which is used extensively in this file.
21 RunCmd = bb_utils.RunCmd
24 def SrcPath(*path):
25 return os.path.join(constants.DIR_SOURCE_ROOT, *path)
28 def CheckWebViewLicenses(_):
29 bb_annotations.PrintNamedStep('check_licenses')
30 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'],
31 warning_code=1)
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 bb_annotations.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])
47 bb_annotations.PrintNamedStep('runhooks')
48 RunCmd(['gclient', 'runhooks'], halt_on_failure=True)
51 def Compile(options):
52 RunHooks(options.target)
53 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'),
54 '--build-tool=ninja',
55 '--compiler=goma',
56 '--target=%s' % options.target,
57 '--goma-dir=%s' % bb_utils.GOMA_DIR]
58 build_targets = options.build_targets.split(',')
59 bb_annotations.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:
64 bb_annotations.PrintNamedStep('Experimental Compile %s' % compile_target)
65 RunCmd(cmd + ['--build-args=%s' % compile_target], flunk_on_failure=False)
68 def ZipBuild(options):
69 bb_annotations.PrintNamedStep('zip_build')
70 RunCmd([
71 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'),
72 '--src-dir', constants.DIR_SOURCE_ROOT,
73 '--build-dir', SrcPath('out'),
74 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests']
75 + bb_utils.EncodeProperties(options))
78 def ExtractBuild(options):
79 bb_annotations.PrintNamedStep('extract_build')
80 RunCmd(
81 [os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py'),
82 '--build-dir', SrcPath('build'), '--build-output-dir',
83 SrcPath('out')] + bb_utils.EncodeProperties(options),
84 warning_code=1)
87 def FindBugs(options):
88 bb_annotations.PrintNamedStep('findbugs')
89 build_type = []
90 if options.target == 'Release':
91 build_type = ['--release-build']
92 RunCmd([SrcPath('build', 'android', 'findbugs_diff.py')] + build_type)
93 RunCmd([SrcPath(
94 'tools', 'android', 'findbugs_plugin', 'test',
95 'run_findbugs_plugin_tests.py')] + build_type)
98 def BisectPerfRegression(_):
99 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'),
100 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)])
101 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'),
102 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)])
105 def DownloadWebRTCResources(_):
106 bb_annotations.PrintNamedStep('download_resources')
107 RunCmd([SrcPath('third_party', 'webrtc', 'tools', 'update_resources.py'),
108 '-p', '../../../'], halt_on_failure=True)
111 def GetHostStepCmds():
112 return [
113 ('compile', Compile),
114 ('extract_build', ExtractBuild),
115 ('check_webview_licenses', CheckWebViewLicenses),
116 ('bisect_perf_regression', BisectPerfRegression),
117 ('download_webrtc_resources', DownloadWebRTCResources),
118 ('findbugs', FindBugs),
119 ('zip_build', ZipBuild)
123 def GetHostStepsOptParser():
124 parser = bb_utils.GetParser()
125 parser.add_option('--steps', help='Comma separated list of host tests.')
126 parser.add_option('--build-targets', default='All',
127 help='Comma separated list of build targets.')
128 parser.add_option('--experimental', action='store_true',
129 help='Indicate whether to compile experimental targets.')
131 return parser
134 def main(argv):
135 parser = GetHostStepsOptParser()
136 options, args = parser.parse_args(argv[1:])
137 if args:
138 return sys.exit('Unused args %s' % args)
140 setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
142 if options.steps:
143 bb_utils.RunSteps(options.steps.split(','), GetHostStepCmds(), options)
146 if __name__ == '__main__':
147 sys.exit(main(sys.argv))