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

Side by Side Diff: recipe_modules/step/api.py

Issue 2933473002: [context] Split "env" values and prefixes. (Closed)
Patch Set: Created 3 years, 6 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
« recipe_modules/context/api.py ('K') | « recipe_modules/python/api.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import contextlib 5 import contextlib
6 import copy 6 import copy
7 7
8 from recipe_engine import recipe_api 8 from recipe_engine import recipe_api
9 9
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 break 180 break
181 181
182 step_count = self._step_names.setdefault(full_name, 1) + 1 182 step_count = self._step_names.setdefault(full_name, 1) + 1
183 self._step_names[full_name] = step_count 183 self._step_names[full_name] = step_count
184 name_suffix = ' (%d)' % step_count 184 name_suffix = ' (%d)' % step_count
185 self._seen_steps.add(full_name) 185 self._seen_steps.add(full_name)
186 186
187 cwd = self.m.context.cwd 187 cwd = self.m.context.cwd
188 if cwd is not None and cwd != self.m.path['start_dir']: 188 if cwd is not None and cwd != self.m.path['start_dir']:
189 kwargs['cwd'] = cwd 189 kwargs['cwd'] = cwd
190 kwargs['env'] = self.m.context.env 190
191 if self._prefix_path: 191 # Assemble the environment.
192 ps = self.m.path.pathsep 192 with self.m.context(env={
193 prefix = ps.join(self._prefix_path) 193 'PATH': self.m.context.Prefix(*self._prefix_path)}):
194 suffix = kwargs['env'].get('PATH', '%(PATH)s') 194 env_values = self.m.context.env
195 kwargs['env']['PATH'] = '%s%s%s' % (prefix, ps, suffix) 195 env = {}
196 for k, path_tuple in self.m.context.env_prefixes.iteritems():
197 path_tuple = tuple(str(v) for v in path_tuple)
198 path_tuple += (env_values.get(k) or '%%(%s)s' % (k,),)
199 env[k] = self.m.path.pathsep.join(path_tuple)
200
201 for k, v in env_values.iteritems():
202 if k in env or v == '':
203 continue # Already processed, or empty.
204 env[k] = v
205
206 kwargs['env'] = env
207
196 kwargs['infra_step'] = self.m.context.infra_step or bool(infra_step) 208 kwargs['infra_step'] = self.m.context.infra_step or bool(infra_step)
197 kwargs['step_nest_level'] = self.m.context.nest_level 209 kwargs['step_nest_level'] = self.m.context.nest_level
198 kwargs['name'] = full_name 210 kwargs['name'] = full_name
199 kwargs['base_name'] = name 211 kwargs['base_name'] = name
200 212
201 schema = self.make_config() 213 schema = self.make_config()
202 schema.set_val(kwargs) 214 schema.set_val(kwargs)
203 return self.run_from_dict(schema.as_jsonish()) 215 return self.run_from_dict(schema.as_jsonish())
204 216
205 # TODO(martiniss) delete, and make generator_script use **kwargs on step() 217 # TODO(martiniss) delete, and make generator_script use **kwargs on step()
206 @recipe_api.composite_step 218 @recipe_api.composite_step
207 def run_from_dict(self, dct): 219 def run_from_dict(self, dct):
208 return self.step_client.run_step(dct) 220 return self.step_client.run_step(dct)
OLDNEW
« recipe_modules/context/api.py ('K') | « recipe_modules/python/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698