OLD | NEW |
(Empty) | |
| 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. |
| 5 |
| 6 import os |
| 7 import json |
| 8 import sys |
| 9 |
| 10 import bb_utils |
| 11 import bb_annotations |
| 12 |
| 13 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 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']) |
| 19 |
| 20 DIR_BUILD_ROOT = os.path.dirname(constants.DIR_SOURCE_ROOT) |
| 21 |
| 22 # Short hand for RunCmd which is used extensively in this file. |
| 23 RunCmd = bb_utils.RunCmd |
| 24 |
| 25 |
| 26 def SrcPath(*path): |
| 27 return os.path.join(constants.DIR_SOURCE_ROOT, *path) |
| 28 |
| 29 |
| 30 def CheckWebViewLicenses(_): |
| 31 bb_annotations.PrintNamedStep('check_licenses') |
| 32 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'], |
| 33 warning_code=1) |
| 34 |
| 35 |
| 36 def RunHooks(build_type): |
| 37 RunCmd([SrcPath('build', 'landmines.py')]) |
| 38 build_path = SrcPath('out', build_type) |
| 39 landmine_path = os.path.join(build_path, '.landmines_triggered') |
| 40 clobber_env = os.environ.get('BUILDBOT_CLOBBER') |
| 41 if clobber_env or os.path.isfile(landmine_path): |
| 42 bb_annotations.PrintNamedStep('Clobber') |
| 43 if not clobber_env: |
| 44 print 'Clobbering due to triggered landmines:' |
| 45 with open(landmine_path) as f: |
| 46 print f.read() |
| 47 RunCmd(['rm', '-rf', build_path]) |
| 48 |
| 49 bb_annotations.PrintNamedStep('runhooks') |
| 50 RunCmd(['gclient', 'runhooks'], halt_on_failure=True) |
| 51 |
| 52 |
| 53 def Compile(options): |
| 54 RunHooks(options.target) |
| 55 cmd = [os.path.join(SLAVE_SCRIPTS_DIR, 'compile.py'), |
| 56 '--build-tool=ninja', |
| 57 '--compiler=goma', |
| 58 '--target=%s' % options.target, |
| 59 '--goma-dir=%s' % bb_utils.GOMA_DIR] |
| 60 bb_annotations.PrintNamedStep('compile') |
| 61 if options.build_targets: |
| 62 build_targets = options.build_targets.split(',') |
| 63 cmd += ['--build-args', ' '.join(build_targets)] |
| 64 RunCmd(cmd, halt_on_failure=True, cwd=DIR_BUILD_ROOT) |
| 65 |
| 66 |
| 67 def ZipBuild(options): |
| 68 bb_annotations.PrintNamedStep('zip_build') |
| 69 RunCmd([ |
| 70 os.path.join(SLAVE_SCRIPTS_DIR, 'zip_build.py'), |
| 71 '--src-dir', constants.DIR_SOURCE_ROOT, |
| 72 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests'] |
| 73 + bb_utils.EncodeProperties(options), cwd=DIR_BUILD_ROOT) |
| 74 |
| 75 |
| 76 def ExtractBuild(options): |
| 77 bb_annotations.PrintNamedStep('extract_build') |
| 78 RunCmd([os.path.join(SLAVE_SCRIPTS_DIR, 'extract_build.py')] |
| 79 + bb_utils.EncodeProperties(options), cwd=DIR_BUILD_ROOT) |
| 80 |
| 81 |
| 82 def BisectPerfRegression(options): |
| 83 args = [] |
| 84 if options.extra_src: |
| 85 args = ['--extra_src', options.extra_src] |
| 86 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'), |
| 87 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir)]) |
| 88 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'), |
| 89 '-w', os.path.join(constants.DIR_SOURCE_ROOT, os.pardir), |
| 90 '--build-properties=%s' % json.dumps(options.build_properties)] + |
| 91 args) |
| 92 |
| 93 |
| 94 def GetHostStepCmds(): |
| 95 return [ |
| 96 ('compile', Compile), |
| 97 ('extract_build', ExtractBuild), |
| 98 ('check_webview_licenses', CheckWebViewLicenses), |
| 99 ('bisect_perf_regression', BisectPerfRegression), |
| 100 ('zip_build', ZipBuild) |
| 101 ] |
| 102 |
| 103 |
| 104 def GetHostStepsOptParser(): |
| 105 parser = bb_utils.GetParser() |
| 106 parser.add_option('--steps', help='Comma separated list of host tests.') |
| 107 parser.add_option('--build-targets', default='', |
| 108 help='Comma separated list of build targets.') |
| 109 parser.add_option('--experimental', action='store_true', |
| 110 help='Indicate whether to compile experimental targets.') |
| 111 parser.add_option('--extra_src', default='', |
| 112 help='Path to extra source file. If this is supplied, ' |
| 113 'bisect script will use it to override default behavior.') |
| 114 |
| 115 return parser |
| 116 |
| 117 |
| 118 def main(argv): |
| 119 parser = GetHostStepsOptParser() |
| 120 options, args = parser.parse_args(argv[1:]) |
| 121 if args: |
| 122 return sys.exit('Unused args %s' % args) |
| 123 |
| 124 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
| 125 setattr(options, 'extra_src', |
| 126 options.factory_properties.get('extra_src', '')) |
| 127 |
| 128 if options.steps: |
| 129 bb_utils.RunSteps(options.steps.split(','), GetHostStepCmds(), options) |
| 130 |
| 131 |
| 132 if __name__ == '__main__': |
| 133 sys.exit(main(sys.argv)) |
OLD | NEW |