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.
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'])
19 DIR_BUILD_ROOT
= os
.path
.dirname(constants
.DIR_SOURCE_ROOT
)
21 # Short hand for RunCmd which is used extensively in this file.
22 RunCmd
= bb_utils
.RunCmd
26 return os
.path
.join(constants
.DIR_SOURCE_ROOT
, *path
)
29 def CheckWebViewLicenses(_
):
30 bb_annotations
.PrintNamedStep('check_licenses')
31 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'],
35 def RunHooks(build_type
):
36 RunCmd([SrcPath('build', 'landmines.py')])
37 build_path
= SrcPath('out', build_type
)
38 landmine_path
= os
.path
.join(build_path
, '.landmines_triggered')
39 clobber_env
= os
.environ
.get('BUILDBOT_CLOBBER')
40 if clobber_env
or os
.path
.isfile(landmine_path
):
41 bb_annotations
.PrintNamedStep('Clobber')
43 print 'Clobbering due to triggered landmines:'
44 with
open(landmine_path
) as f
:
46 RunCmd(['rm', '-rf', build_path
])
48 bb_annotations
.PrintNamedStep('runhooks')
49 RunCmd(['gclient', 'runhooks'], halt_on_failure
=True)
53 RunHooks(options
.target
)
54 cmd
= [os
.path
.join(SLAVE_SCRIPTS_DIR
, 'compile.py'),
57 '--target=%s' % options
.target
,
58 '--goma-dir=%s' % bb_utils
.GOMA_DIR
]
59 bb_annotations
.PrintNamedStep('compile')
60 if options
.build_targets
:
61 build_targets
= options
.build_targets
.split(',')
62 cmd
+= ['--build-args', ' '.join(build_targets
)]
63 RunCmd(cmd
, halt_on_failure
=True, cwd
=DIR_BUILD_ROOT
)
66 def ZipBuild(options
):
67 bb_annotations
.PrintNamedStep('zip_build')
69 os
.path
.join(SLAVE_SCRIPTS_DIR
, 'zip_build.py'),
70 '--src-dir', constants
.DIR_SOURCE_ROOT
,
71 '--exclude-files', 'lib.target,gen,android_webview,jingle_unittests']
72 + bb_utils
.EncodeProperties(options
), cwd
=DIR_BUILD_ROOT
)
75 def ExtractBuild(options
):
76 bb_annotations
.PrintNamedStep('extract_build')
77 RunCmd([os
.path
.join(SLAVE_SCRIPTS_DIR
, 'extract_build.py')]
78 + bb_utils
.EncodeProperties(options
), cwd
=DIR_BUILD_ROOT
)
81 def BisectPerfRegression(options
):
84 args
= ['--extra_src', options
.extra_src
]
85 RunCmd([SrcPath('tools', 'prepare-bisect-perf-regression.py'),
86 '-w', os
.path
.join(constants
.DIR_SOURCE_ROOT
, os
.pardir
)])
87 RunCmd([SrcPath('tools', 'run-bisect-perf-regression.py'),
88 '-w', os
.path
.join(constants
.DIR_SOURCE_ROOT
, os
.pardir
)] + args
)
91 def GetHostStepCmds():
94 ('extract_build', ExtractBuild
),
95 ('check_webview_licenses', CheckWebViewLicenses
),
96 ('bisect_perf_regression', BisectPerfRegression
),
97 ('zip_build', ZipBuild
)
101 def GetHostStepsOptParser():
102 parser
= bb_utils
.GetParser()
103 parser
.add_option('--steps', help='Comma separated list of host tests.')
104 parser
.add_option('--build-targets', default
='',
105 help='Comma separated list of build targets.')
106 parser
.add_option('--experimental', action
='store_true',
107 help='Indicate whether to compile experimental targets.')
108 parser
.add_option('--extra_src', default
='',
109 help='Path to extra source file. If this is supplied, '
110 'bisect script will use it to override default behavior.')
116 parser
= GetHostStepsOptParser()
117 options
, args
= parser
.parse_args(argv
[1:])
119 return sys
.exit('Unused args %s' % args
)
121 setattr(options
, 'target', options
.factory_properties
.get('target', 'Debug'))
122 setattr(options
, 'extra_src',
123 options
.factory_properties
.get('extra_src', ''))
126 bb_utils
.RunSteps(options
.steps
.split(','), GetHostStepCmds(), options
)
129 if __name__
== '__main__':
130 sys
.exit(main(sys
.argv
))