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

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

Issue 1347263002: Revert of Cross-repo recipe package system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: 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
22 23
23 SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__)) 24 from recipe_engine import main as recipe_main
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')
30 25
31 @contextlib.contextmanager 26 @contextlib.contextmanager
32 def namedTempFile(): 27 def namedTempFile():
33 fd, name = tempfile.mkstemp() 28 fd, name = tempfile.mkstemp()
34 os.close(fd) # let the exceptions fly 29 os.close(fd) # let the exceptions fly
35 try: 30 try:
36 yield name 31 yield name
37 finally: 32 finally:
38 try: 33 try:
39 os.remove(name) 34 os.remove(name)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 s.step_warnings() 192 s.step_warnings()
198 os.environ['RUN_SLAVE_UPDATED_SCRIPTS'] = '1' 193 os.environ['RUN_SLAVE_UPDATED_SCRIPTS'] = '1'
199 194
200 # After running update scripts, set PYTHONIOENCODING=UTF-8 for the real 195 # After running update scripts, set PYTHONIOENCODING=UTF-8 for the real
201 # annotated_run. 196 # annotated_run.
202 os.environ['PYTHONIOENCODING'] = 'UTF-8' 197 os.environ['PYTHONIOENCODING'] = 'UTF-8'
203 198
204 return True 199 return True
205 200
206 201
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
221 def main(argv): 202 def main(argv):
222 opts, _ = get_args(argv) 203 opts, _ = get_args(argv)
223 properties = get_recipe_properties( 204 properties = get_recipe_properties(
224 opts.factory_properties, opts.build_properties, 205 opts.factory_properties, opts.build_properties,
225 opts.master_overrides_slave) 206 opts.master_overrides_slave)
226 207 stream = annotator.StructuredAnnotationStream()
227 clean_old_recipe_engine() 208 ret = recipe_main.run_steps(properties, stream,
228 209 universe=recipe_universe.get_universe())
229 # Find out if the recipe we intend to run is in build_internal's recipes. If 210 return ret.status_code
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)
247 211
248 212
249 def shell_main(argv): 213 def shell_main(argv):
250 if update_scripts(): 214 if update_scripts():
251 return subprocess.call([sys.executable] + argv) 215 return subprocess.call([sys.executable] + argv)
252 else: 216 else:
253 return main(argv) 217 return main(argv)
254 218
255
256 if __name__ == '__main__': 219 if __name__ == '__main__':
257 sys.exit(shell_main(sys.argv)) 220 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