Skip to content

Commit

Permalink
allow inherit_defer for native, nativesdk and cross
Browse files Browse the repository at this point in the history
Closes #572

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed May 16, 2024
1 parent aa408e0 commit 69596c1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions oelint_adv/rule_base/rule_vars_inherit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
7 changes: 6 additions & 1 deletion oelint_adv/rule_base/rule_vars_inherit_devtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand All @@ -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
18 changes: 18 additions & 0 deletions tests/test_class_oelint_var_inherit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
'''
Expand Down
21 changes: 21 additions & 0 deletions tests/test_class_oelint_var_inherit_devtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 69596c1

Please sign in to comment.