Skip to content

Commit

Permalink
input: add substituteMetaEnvFail 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. Add a policy
to make the new bob useable on old recipes as well.
  • Loading branch information
rhubert committed Oct 24, 2024
1 parent cdcf25d commit 1d2b032
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions doc/manual/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ New behavior
The ``fileMode`` attribute is default initialized to ``0600``. All files
will get the same mode, regardless of the URL schema.

substituteMetaEnvFail
~~~~~~~~~~~~~~~~~~~~~

Introduced in: 0.25

Starting with Bob 0.25, string substitution is applied on metaEnvironment. This
policy controls the behavior if the substitution fails.

Old behavior
Try to apply substitution. If it fails issue a warning and return the
original string.

New behavior
Apply substitution and raise a parse error on failures.

.. _policies-obsolete:

Obsolete policies
Expand Down
9 changes: 8 additions & 1 deletion pym/bob/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,8 @@ 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)
metaEnv = { key : env.substitute(value, "metaEnvironment::"+key,
fail=self.__recipeSet.getPolicy('substituteMetaEnvFail'))
for key, value in self.__metaEnv.items() }
env.update(metaEnv)

Expand Down Expand Up @@ -2999,6 +3000,7 @@ class RecipeSet:
schema.Optional('gitCommitOnBranch') : bool,
schema.Optional('fixImportScmVariant') : bool,
schema.Optional('defaultFileMode') : bool,
schema.Optional('substituteMetaEnvFail') : bool,
},
error="Invalid policy specified! Are you using an appropriate version of Bob?"
),
Expand Down Expand Up @@ -3043,6 +3045,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.")
),
"substituteMetaEnvFail": (
"0.25rc1",
InfoOnce("substituteMetaEnvFail is not set. MetaEnv will not be substituted if substitution failes.",
help="See http://bob-build-tool.readthedocs.io/en/latest/manual/policies.html#substituteMetaEnvFail for more information.")
)
}

_ignoreCmdConfig = False
Expand Down

0 comments on commit 1d2b032

Please sign in to comment.