Skip to content

Commit

Permalink
input: add substituteMetaEnv policy
Browse files Browse the repository at this point in the history
Since 227e0a6 substiution is applied to metaEnv variables. For older
recipes this might fail if the string can't be substituted.
  • Loading branch information
rhubert committed Oct 24, 2024
1 parent 30ae46e commit ad183aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 13 additions & 0 deletions doc/manual/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ New behavior
The ``fileMode`` attribute is default initialized to ``0600``. All files
will get the same mode, regardless of the URL schema.

substituteMetaEnv
~~~~~~~~~~~~~~~~~

Introduced in: 0.25

Apply string substitution on metaEnvironment.

Old behavior
No substitution.

New behavior
Apply substitution.

.. _policies-obsolete:

Obsolete policies
Expand Down
13 changes: 11 additions & 2 deletions pym/bob/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2510,8 +2510,11 @@ def prepare(self, inputEnv, sandboxEnabled, inputStates, inputSandbox=None,
for key, value in i.items() })

# meta variables override existing variables
metaEnv = { key : env.substitute(value, "metaEnvironment::"+key)
for key, value in self.__metaEnv.items() }
if self.__recipeSet.getPolicy('substituteMetaEnv'):
metaEnv = { key : env.substitute(value, "metaEnvironment::"+key)
for key, value in self.__metaEnv.items() }
else:
metaEnv = self.__metaEnv
env.update(metaEnv)

# set fixed built-in variables
Expand Down Expand Up @@ -2999,6 +3002,7 @@ class RecipeSet:
schema.Optional('gitCommitOnBranch') : bool,
schema.Optional('fixImportScmVariant') : bool,
schema.Optional('defaultFileMode') : bool,
schema.Optional('substituteMetaEnv') : bool,
},
error="Invalid policy specified! Are you using an appropriate version of Bob?"
),
Expand Down Expand Up @@ -3043,6 +3047,11 @@ class RecipeSet:
InfoOnce("defaultFileMode policy not set. File mode of URL SCMs not set for locally copied files.",
help="See http://bob-build-tool.readthedocs.io/en/latest/manual/policies.html#defaultfilemode for more information.")
),
"substituteMetaEnv": (
"0.25rc1",
InfoOnce("substituteMetaEnv is not set. MetaEnv will not be substituted.",
help="See http://bob-build-tool.readthedocs.io/en/latest/manual/policies.html#substituteMetaEnv for more information.")
)
}

_ignoreCmdConfig = False
Expand Down

0 comments on commit ad183aa

Please sign in to comment.