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

Side by Side Diff: scripts/slave/annotated_run.py

Issue 1241323004: Cross-repo recipe package system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Roll to latest recipes-py Created 5 years, 3 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 | « infra/config/recipes.cfg ('k') | scripts/slave/bot_update.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 (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 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 contextlib 6 import contextlib
7 import json 7 import json
8 import optparse 8 import optparse
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 import tempfile 12 import tempfile
13 13
14 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname( 14 BUILD_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
15 os.path.abspath(__file__)))) 15 os.path.abspath(__file__))))
16 sys.path.append(os.path.join(BUILD_ROOT, 'scripts')) 16 sys.path.append(os.path.join(BUILD_ROOT, 'scripts'))
17 sys.path.append(os.path.join(BUILD_ROOT, 'third_party')) 17 sys.path.append(os.path.join(BUILD_ROOT, 'third_party'))
18 18
19 from common import annotator 19 from common import annotator
20 from common import chromium_utils 20 from common import chromium_utils
21 from common import master_cfg_utils 21 from common import master_cfg_utils
22 from slave import recipe_universe
23 22
24 from recipe_engine import main as recipe_main 23 SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
24 BUILD_LIMITED_ROOT = os.path.join(
25 os.path.dirname(BUILD_ROOT), 'build_internal', 'scripts', 'slave')
26
27 PACKAGE_CFG = os.path.join(
28 os.path.dirname(os.path.dirname(SCRIPT_PATH)),
29 'infra', 'config', 'recipes.cfg')
25 30
26 @contextlib.contextmanager 31 @contextlib.contextmanager
27 def namedTempFile(): 32 def namedTempFile():
28 fd, name = tempfile.mkstemp() 33 fd, name = tempfile.mkstemp()
29 os.close(fd) # let the exceptions fly 34 os.close(fd) # let the exceptions fly
30 try: 35 try:
31 yield name 36 yield name
32 finally: 37 finally:
33 try: 38 try:
34 os.remove(name) 39 os.remove(name)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 s.step_warnings() 197 s.step_warnings()
193 os.environ['RUN_SLAVE_UPDATED_SCRIPTS'] = '1' 198 os.environ['RUN_SLAVE_UPDATED_SCRIPTS'] = '1'
194 199
195 # After running update scripts, set PYTHONIOENCODING=UTF-8 for the real 200 # After running update scripts, set PYTHONIOENCODING=UTF-8 for the real
196 # annotated_run. 201 # annotated_run.
197 os.environ['PYTHONIOENCODING'] = 'UTF-8' 202 os.environ['PYTHONIOENCODING'] = 'UTF-8'
198 203
199 return True 204 return True
200 205
201 206
207 def clean_old_recipe_engine():
208 """Clean stale pycs from the old location of recipe_engine.
209
210 This function should only be needed for a little while after the recipe
211 packages rollout (2015-09-16).
212 """
213 for (dirpath, _, filenames) in os.walk(
214 os.path.join(BUILD_ROOT, 'third_party', 'recipe_engine')):
215 for filename in filenames:
216 if filename.endswith('.pyc'):
217 path = os.path.join(dirpath, filename)
218 os.remove(path)
219
220
202 def main(argv): 221 def main(argv):
203 opts, _ = get_args(argv) 222 opts, _ = get_args(argv)
204 properties = get_recipe_properties( 223 properties = get_recipe_properties(
205 opts.factory_properties, opts.build_properties, 224 opts.factory_properties, opts.build_properties,
206 opts.master_overrides_slave) 225 opts.master_overrides_slave)
207 stream = annotator.StructuredAnnotationStream() 226
208 ret = recipe_main.run_steps(properties, stream, 227 clean_old_recipe_engine()
209 universe=recipe_universe.get_universe()) 228
210 return ret.status_code 229 # Find out if the recipe we intend to run is in build_internal's recipes. If
230 # so, use recipes.py from there, otherwise use the one from build.
231 recipe_file = properties['recipe'].replace('/', os.path.sep) + '.py'
232 if os.path.exists(os.path.join(BUILD_LIMITED_ROOT, 'recipes', recipe_file)):
233 recipe_runner = os.path.join(BUILD_LIMITED_ROOT, 'recipes.py')
234 else:
235 recipe_runner = os.path.join(SCRIPT_PATH, 'recipes.py')
236
237 with namedTempFile() as props_file:
238 with open(props_file, 'w') as fh:
239 fh.write(json.dumps(properties))
240 cmd = [
241 sys.executable, '-u', recipe_runner,
242 'run',
243 '--workdir=%s' % os.getcwd(),
244 '--properties-file=%s' % props_file,
245 properties['recipe'] ]
246 return subprocess.call(cmd)
211 247
212 248
213 def shell_main(argv): 249 def shell_main(argv):
214 if update_scripts(): 250 if update_scripts():
215 return subprocess.call([sys.executable] + argv) 251 return subprocess.call([sys.executable] + argv)
216 else: 252 else:
217 return main(argv) 253 return main(argv)
218 254
255
219 if __name__ == '__main__': 256 if __name__ == '__main__':
220 sys.exit(shell_main(sys.argv)) 257 sys.exit(shell_main(sys.argv))
OLDNEW
« no previous file with comments | « infra/config/recipes.cfg ('k') | scripts/slave/bot_update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698