[yocto] [[AUH] 08/17] recipe/base.py: Add support for get recipe inherits.
Paul Eggleton
paul.eggleton at linux.intel.com
Thu Nov 26 12:25:30 PST 2015
On Wednesday 25 November 2015 18:00:37 Aníbal Limón wrote:
> Recipe inherits are needed to detect what recipes support
> certain feature.
>
> For example: For detect ptest enable recipes and then do
> ptest runtime test after succesful upgrade.
>
> Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
> ---
> modules/recipe/base.py | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/modules/recipe/base.py b/modules/recipe/base.py
> index 5c70c61..dabad2f 100644
> --- a/modules/recipe/base.py
> +++ b/modules/recipe/base.py
> @@ -57,6 +57,16 @@ def modify_recipe_files(func):
> os.rename(full_path_f + ".tmp", full_path_f)
> return modify
>
> +def read_recipe_files(func):
> + def read(env, recipe_dir):
> + for f in os.listdir(recipe_dir):
> + full_path_f = os.path.join(recipe_dir, f)
> + if is_recipe_or_include_file(env, full_path_f, f):
> + with open(full_path_f) as recipe:
> + for line in recipe:
> + func(line)
> + return read
> +
> class Recipe(object):
> def __init__(self, env, new_ver, interactive, workdir, recipe_dir,
> bitbake, git): self.env = env
> @@ -85,8 +95,23 @@ class Recipe(object):
> self.commit_msg = self.env['PN'] + ": upgrade to " + self.new_ver +
> "\n\n" self.rm_patches_msg = "\n\nRemoved the following patch(es):\n"
>
> + self._inherits = None
> +
> super(Recipe, self).__init__()
>
> + def get_inherits(self):
> + @read_recipe_files
> + def _get_inherits(line):
> + m = re.search("^inherit (.*)$", line)
> + if m:
> + tmp = m.group(1).split()
> + self._inherits.extend(tmp)
> +
> + if not self._inherits:
> + self._inherits = []
> + _get_inherits(self.env, self.recipe_dir)
> +
> + return self._inherits
>
> def update_env(self, env):
> self.env = env
I'm not sure I like this - you're not parsing the recipe so you'll miss things
such as inc files inheriting the recipe. Would it be possible to parse the
recipe properly instead e.g. with tinfoil?
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
More information about the yocto
mailing list