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

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: PRESUBMIT-related touchups 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
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 os.environ['PYTHONIOENCODING'] = 'UTF-8' 202 os.environ['PYTHONIOENCODING'] = 'UTF-8'
198 203
199 return True 204 return True
200 205
201 206
202 def main(argv): 207 def main(argv):
203 opts, _ = get_args(argv) 208 opts, _ = get_args(argv)
204 properties = get_recipe_properties( 209 properties = get_recipe_properties(
205 opts.factory_properties, opts.build_properties, 210 opts.factory_properties, opts.build_properties,
206 opts.master_overrides_slave) 211 opts.master_overrides_slave)
207 stream = annotator.StructuredAnnotationStream() 212
208 ret = recipe_main.run_steps(properties, stream, 213 # Find out of the recipe we intend to run is in build_internal's recipes. If
209 universe=recipe_universe.get_universe()) 214 # so, use recipes.py from there, otherwise use the one from build.
210 return ret.status_code 215 recipe_file = properties['recipe'].replace('/', os.path.sep) + '.py'
216 if os.path.exists(os.path.join(BUILD_LIMITED_ROOT, 'recipes', recipe_file)):
217 recipe_runner = os.path.join(BUILD_LIMITED_ROOT, 'recipes.py')
218 else:
219 recipe_runner = os.path.join(SCRIPT_PATH, 'recipes.py')
220
221 os.execvp(sys.executable,
222 [ sys.executable, '-u', recipe_runner,
223 'run', properties['recipe'],
224 '--properties=%s' % json.dumps(properties) ])
211 225
212 226
213 def shell_main(argv): 227 def shell_main(argv):
214 if update_scripts(): 228 if update_scripts():
215 return subprocess.call([sys.executable] + argv) 229 return subprocess.call([sys.executable] + argv)
216 else: 230 else:
217 return main(argv) 231 return main(argv)
218 232
233
219 if __name__ == '__main__': 234 if __name__ == '__main__':
220 sys.exit(shell_main(sys.argv)) 235 sys.exit(shell_main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698