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

Unified Diff: recipe_engine/recipe_api.py

Issue 2933473002: [context] Split "env" values and prefixes. (Closed)
Patch Set: comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_engine/step_runner.py » ('j') | recipe_engine/step_runner.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/recipe_api.py
diff --git a/recipe_engine/recipe_api.py b/recipe_engine/recipe_api.py
index f9eba82c3cae9ddcf639a5200c563cc550fb15e9..e9af1682cd08291b327711877765b9c9cd811210 100644
--- a/recipe_engine/recipe_api.py
+++ b/recipe_engine/recipe_api.py
@@ -9,6 +9,7 @@ import contextlib
import copy
import json
import keyword
+import os
import re
import types
@@ -173,9 +174,9 @@ class StepClient(object):
class StepConfig(collections.namedtuple('_StepConfig', (
- 'name', 'base_name', 'cmd', 'cwd', 'env', 'allow_subannotations',
- 'trigger_specs', 'timeout', 'infra_step', 'stdout', 'stderr', 'stdin',
- 'ok_ret', 'step_test_data', 'nest_level'))):
+ 'name', 'base_name', 'cmd', 'cwd', 'env', 'env_prefixes', 'pathsep',
+ 'allow_subannotations', 'trigger_specs', 'timeout', 'infra_step',
+ 'stdout', 'stderr', 'stdin', 'ok_ret', 'step_test_data', 'nest_level'))):
"""
StepConfig is the representation of a raw step as the recipe_engine sees it.
@@ -192,6 +193,8 @@ class StepClient(object):
cmd: command to run. Acceptable types: str, Path, Placeholder, or None.
cwd (str or None): absolute path to working directory for the command
env (dict): overrides for environment variables, described above.
+ env_prefixes (dict): environment prefix variables, described above.
+ pathsep (str): system path enviornment variable separator.
allow_subannotations (bool): if True, lets the step emit its own
annotations. NOTE: Enabling this can cause some buggy behavior. Please
strongly consider using step_result.presentation instead. If you have
@@ -223,6 +226,20 @@ class StepClient(object):
"delete_this": None,
"static_value": "something",
}
+
+ The optional "env_prefixes" parameter contains values that, if specified,
+ will transform an environment variable into a "pathsep"-delimited sequence
+ of items:
+ - If an environment variable is also specified for this key, it will be
+ appended as the last element: <prefix0>:...:<prefixN>:ENV
+ - If no enviornment variable is specified, the current environment's value
+ will be appended, unless it's empty: <prefix0>:...:<prefixN>[:ENV]?
+ - If an enviornment variable with a value of None (delete) is specified,
+ nothing will be appeneded: <prefix0>:...:<prefixN>
+
+ There is currently no way to remove prefix paths; once they're there,
+ they're there for good. If you think you need to remove paths from the
+ prefix lists, please talk to infra-dev@chromium.org.
"""
_RENDER_WHITELIST=frozenset((
@@ -233,6 +250,7 @@ class StepClient(object):
'base_name',
'nest_level',
'ok_ret',
+ 'pathsep',
'step_test_data',
))
@@ -245,6 +263,10 @@ class StepClient(object):
cmd=[(x if isinstance(x, Placeholder) else str(x))
for x in (sc.cmd or ())],
cwd=(str(sc.cwd) if sc.cwd else (None)),
+ env=sc.env or {},
+ env_prefixes={k: tuple(str(x) for x in v)
+ for k, v in (sc.env_prefixes or {}).iteritems()},
+ pathsep=sc.pathsep or os.pathsep,
base_name=sc.base_name or sc.name,
allow_subannotations=bool(sc.allow_subannotations),
trigger_specs=sc.trigger_specs or (),
@@ -255,6 +277,7 @@ class StepClient(object):
def render_to_dict(self):
sc = self._replace(
+ env_prefixes={k: list(v) for k, v in self.env_prefixes.iteritems()},
trigger_specs=[trig._render_to_dict()
for trig in (self.trigger_specs or ())],
)
« no previous file with comments | « no previous file | recipe_engine/step_runner.py » ('j') | recipe_engine/step_runner.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698