From 69596c16fceb9ed3317ad32220677c6a407a8dc5 Mon Sep 17 00:00:00 2001 From: Konrad Weihmann Date: Wed, 15 May 2024 18:15:39 +0200 Subject: [PATCH] allow inherit_defer for native, nativesdk and cross Closes #572 Signed-off-by: Konrad Weihmann --- oelint_adv/rule_base/rule_vars_inherit.py | 2 ++ .../rule_base/rule_vars_inherit_devtool.py | 7 ++++++- tests/test_class_oelint_var_inherit.py | 18 ++++++++++++++++ .../test_class_oelint_var_inherit_devtool.py | 21 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/oelint_adv/rule_base/rule_vars_inherit.py b/oelint_adv/rule_base/rule_vars_inherit.py index d692266d..b586b9c2 100644 --- a/oelint_adv/rule_base/rule_vars_inherit.py +++ b/oelint_adv/rule_base/rule_vars_inherit.py @@ -19,6 +19,8 @@ def check(self, _file: str, stash: Stash) -> List[Tuple[str, int, str]]: items: List[Inherit] = stash.GetItemsFor(filename=_file, classifier=Inherit.CLASSIFIER) for i in items: if '${' not in i.RealRaw and i.Statement == 'inherit_defer': + if any(x in i.get_items() for x in ['native', 'nativesdk', 'cross']): + continue res += self.finding(i.Origin, i.InFileLine, 'inherit_defer should only be used if there is a variable involved', appendix='inherit') diff --git a/oelint_adv/rule_base/rule_vars_inherit_devtool.py b/oelint_adv/rule_base/rule_vars_inherit_devtool.py index ea6d8141..66495cb1 100644 --- a/oelint_adv/rule_base/rule_vars_inherit_devtool.py +++ b/oelint_adv/rule_base/rule_vars_inherit_devtool.py @@ -11,7 +11,7 @@ def __init__(self) -> None: super().__init__(id='oelint.var.inheritdevtool', severity='warning', message='It is better to use inherit_defer for {statement}, to enable proper devtool integration', - appendix=['native', 'nativesdk'], + appendix=['native', 'nativesdk', 'cross'], valid_from_release='scarthgap') def check(self, _file: str, stash: Stash) -> List[Tuple[str, int, str]]: @@ -28,4 +28,9 @@ def check(self, _file: str, stash: Stash) -> List[Tuple[str, int, str]]: override_msg=self.Msg.format(statement='nativesdk'), appendix='nativesdk', ) + if 'cross' in i.get_items() and i.Statement != 'inherit_defer': + res += self.finding(i.Origin, i.InFileLine, + override_msg=self.Msg.format(statement='cross'), + appendix='cross', + ) return res diff --git a/tests/test_class_oelint_var_inherit.py b/tests/test_class_oelint_var_inherit.py index ba55a495..52a5872a 100644 --- a/tests/test_class_oelint_var_inherit.py +++ b/tests/test_class_oelint_var_inherit.py @@ -68,6 +68,24 @@ def test_good_inherit(self, input_, id_, occurrence): inherit_defer ${A} ''', }, + { + 'oelint_adv_test.bb': + ''' + inherit_defer native + ''', + }, + { + 'oelint_adv_test.bb': + ''' + inherit_defer nativesdk + ''', + }, + { + 'oelint_adv_test.bb': + ''' + inherit_defer cross + ''', + }, { 'oelint_adv_test.bb': ''' diff --git a/tests/test_class_oelint_var_inherit_devtool.py b/tests/test_class_oelint_var_inherit_devtool.py index 91b1a024..4b0fdb22 100644 --- a/tests/test_class_oelint_var_inherit_devtool.py +++ b/tests/test_class_oelint_var_inherit_devtool.py @@ -84,3 +84,24 @@ def test_good_inherit_native(self, input_, id_, occurrence): ) def test_good_inherit_nativesdk(self, input_, id_, occurrence): self.check_for_id(self._create_args(input_, ['--release=scarthgap']), id_, occurrence) + + @pytest.mark.parametrize('id_', ['oelint.var.inheritdevtool.cross']) + @pytest.mark.parametrize('occurrence', [0]) + @pytest.mark.parametrize('input_', + [ + { + 'oelint_adv_test.bb': + ''' + inherit_defer cross + ''', + }, + { + 'oelint_adv_test.bb': + ''' + inherit_defer ${@oe.utils.ifelse(1 == 1, 'cross', C} + ''', + }, + ], + ) + def test_good_inherit_cross(self, input_, id_, occurrence): + self.check_for_id(self._create_args(input_, ['--release=scarthgap']), id_, occurrence)