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

Side by Side Diff: scripts/slave/recipe_modules/goma/example.py

Issue 2480193002: Stop to use contextmanager for goma.build_with_goma (Closed)
Patch Set: use env_update Created 4 years, 1 month 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
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import re 5 import re
6 6
7 DEPS = [ 7 DEPS = [
8 'goma', 8 'goma',
9 'recipe_engine/platform', 9 'recipe_engine/platform',
10 'recipe_engine/properties', 10 'recipe_engine/properties',
11 'recipe_engine/step', 11 'recipe_engine/step',
12 ] 12 ]
13 13
14 def RunSteps(api): 14 def RunSteps(api):
15 api.goma.ensure_goma() 15 api.goma.ensure_goma()
16 api.step('gn', ['gn', 'gen', 'out/Release', 16 api.step('gn', ['gn', 'gen', 'out/Release',
17 '--args=use_goma=true goma_dir=%s' % api.goma.goma_dir]) 17 '--args=use_goma=true goma_dir=%s' % api.goma.goma_dir])
18 18
19 command = list(api.properties.get('build_command')) 19 command = list(api.properties.get('build_command'))
20 env = {} 20 env = {}
21 allow_build_without_goma = api.properties.get( 21 allow_build_without_goma = api.properties.get(
22 'allow_build_without_goma', False) 22 'allow_build_without_goma', False)
23 23
24 with api.goma.build_with_goma( 24 with api.goma.build_with_goma(
25 ninja_log_outdir=api.properties.get('ninja_log_outdir'), 25 ninja_log_outdir=api.properties.get('ninja_log_outdir'),
26 ninja_log_compiler=api.properties.get('ninja_log_compiler'), 26 ninja_log_compiler=api.properties.get('ninja_log_compiler'),
27 ninja_log_command=command, 27 ninja_log_command=command,
28 allow_build_without_goma=allow_build_without_goma, 28 allow_build_without_goma=allow_build_without_goma,
29 env=env): 29 env=env) as (env_update, ninja_command):
30 if 'GOMA_DISABLED' in env: 30 env.update(env_update)
31 api.goma.remove_j_flag(command) 31 # build something using goma.
32 api.step('ninja', command, env=env) 32 api.step('echo goma jobs',
33 else: 33 ['echo', str(api.goma.recommended_goma_jobs)])
34 # build something using goma. 34 api.step('echo goma jobs second',
35 api.step('echo goma jobs', 35 ['echo', str(api.goma.recommended_goma_jobs)])
36 ['echo', str(api.goma.recommended_goma_jobs)]) 36 api.step('ninja', ninja_command, env=env)
37 api.step('echo goma jobs second',
38 ['echo', str(api.goma.recommended_goma_jobs)])
39 api.step('ninja', command, env=env)
40 37
41 def GenTests(api): 38 def GenTests(api):
42 for platform in ('linux', 'win', 'mac'): 39 for platform in ('linux', 'win', 'mac'):
43 properties = { 40 properties = {
44 'buildername': 'test_builder', 41 'buildername': 'test_builder',
45 'mastername': 'test_master', 42 'mastername': 'test_master',
46 'slavename': 'test_slave', 43 'slavename': 'test_slave',
47 'clobber': '1', 44 'clobber': '1',
48 'build_command': ['ninja', '-C', 'out/Release', '-j', '500'], 45 'build_command': ['ninja', '-C', 'out/Release', '-j', '500'],
49 'ninja_log_outdir': 'out/Release', 46 'ninja_log_outdir': 'out/Release',
50 'ninja_log_compiler': 'goma', 47 'ninja_log_compiler': 'goma',
51 'build_data_dir': 'build_data_dir', 48 'build_data_dir': 'build_data_dir',
52 } 49 }
53 50
54 yield (api.test(platform) + api.platform.name(platform) + 51 yield (api.test(platform) + api.platform.name(platform) +
55 api.properties.generic(**properties)) 52 api.properties.generic(**properties))
56 53
57 yield (api.test('%s_goma_disabled' % platform) + 54 yield (api.test('%s_goma_disabled' % platform) +
58 api.step_data('preprocess_for_goma.start_goma', retcode=1) + 55 api.step_data('preprocess_for_goma.start_goma', retcode=1) +
59 api.platform.name(platform) + 56 api.platform.name(platform) +
60 api.properties(allow_build_without_goma=True) + 57 api.properties(allow_build_without_goma=True) +
61 api.properties.generic(**properties)) 58 api.properties.generic(**properties))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698