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.
13 sys
.path
.append(os
.path
.join(os
.path
.dirname(__file__
), '..'))
14 from pylib
import constants
17 SLAVE_SCRIPTS_DIR
= os
.path
.join(bb_utils
.BB_BUILD_DIR
, 'scripts', 'slave')
18 VALID_HOST_TESTS
= set(['check_webview_licenses'])
20 DIR_BUILD_ROOT
= os
.path
.dirname(constants
.DIR_SOURCE_ROOT
)
22 # Short hand for RunCmd which is used extensively in this file.
23 RunCmd
= bb_utils
.RunCmd
27 return os
.path
.join(constants
.DIR_SOURCE_ROOT
, *path
)
30 def CheckWebViewLicenses(_
):
31 bb_annotations
.PrintNamedStep('check_licenses')
32 RunCmd([SrcPath('android_webview', 'tools', 'webview_licenses.py'), 'scan'],
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')
44 print 'Clobbering due to triggered landmines:'
45 with
open(landmine_path
) as f
:
47 RunCmd(['rm', '-rf', build_path
])
49 bb_annotations
.PrintNamedStep('runhooks')
50 RunCmd(['gclient', 'runhooks'], halt_on_failure
=True)
54 RunHooks(options
.target
)
55 cmd
= [os
.path
.join(SLAVE_SCRIPTS_DIR
, 'compile.py'),
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
)
67 def ZipBuild(options
):
68 bb_annotations
.PrintNamedStep('zip_build')
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
)
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
)
82 def BisectPerfRegression(options
):
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
)] +
94 def GetHostStepCmds():
97 ('extract_build', ExtractBuild
),
98 ('check_webview_licenses', CheckWebViewLicenses
),
99 ('bisect_perf_regression', BisectPerfRegression
),
100 ('zip_build', ZipBuild
)
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.')
119 parser
= GetHostStepsOptParser()
120 options
, args
= parser
.parse_args(argv
[1:])
122 return sys
.exit('Unused args %s' % args
)
124 setattr(options
, 'target', options
.factory_properties
.get('target', 'Debug'))
125 setattr(options
, 'extra_src',
126 options
.factory_properties
.get('extra_src', ''))
129 bb_utils
.RunSteps(options
.steps
.split(','), GetHostStepCmds(), options
)
132 if __name__
== '__main__':
133 sys
.exit(main(sys
.argv
))