On 6/9/20 4:34 PM, Martin Jansa wrote:
Seeing how many cases like this exist(ed), this look very useful, but it would be even better if we can catch the opposite case when e.g. REQUIRED_DISTRO_FEATURES are set in recipe, but doesn't do anything because of missing features_check inherit.


Yes, that would be a good test for insane.

But I understand that such check might be more controversial as it would need to be checked globally (outside this bbclass), maybe something in insane.bbclass catching both cases as QA issue?

I didn't want to add this check to insane since I like that you only pay for the check if you actually use the class.

Not sure if that is worth pushing for, but I think I recall someone saying that a large part of the parsing time is spent running the anonyous python(?).

Jacob


On Tue, Jun 9, 2020 at 4:11 PM Jacob Kroon <jacob.kr...@gmail.com <mailto:jacob.kr...@gmail.com>> wrote:

    Signed-off-by: Jacob Kroon <jacob.kr...@gmail.com
    <mailto:jacob.kr...@gmail.com>>
    ---
      meta/classes/features_check.bbclass | 20 ++++++++++++++++++++
      1 file changed, 20 insertions(+)

    diff --git a/meta/classes/features_check.bbclass
    b/meta/classes/features_check.bbclass
    index 4ba827d4ab..31ce600374 100644
    --- a/meta/classes/features_check.bbclass
    +++ b/meta/classes/features_check.bbclass
    @@ -12,11 +12,25 @@
      # Copyright 2019 (C) Texas Instruments Inc.
      # Copyright 2013 (C) O.S. Systems Software LTDA.

    +FEATURES_CHECK_INCLUDE_STACK := "${BBINCLUDESTACK}"
    +
      python () {
          if d.getVar('PARSE_ALL_RECIPES', False):
              return

    +    unused = True
    +
          for kind in ['DISTRO', 'MACHINE', 'COMBINED']:
    +        if d.getVar('ANY_OF_' + kind + '_FEATURES') is None and \
    +           d.overridedata.get('ANY_OF_' + kind + '_FEATURES') is
    None and \
    +           d.getVar('REQUIRED_' + kind + '_FEATURES') is None and \
    +           d.overridedata.get('REQUIRED_' + kind + '_FEATURES') is
    None and \
    +           d.getVar('CONFLICT_' + kind + '_FEATURES') is None and \
    +           d.overridedata.get('CONFLICT_' + kind + '_FEATURES') is
    None:
    +            continue
    +
    +        unused = False
    +
              # Assume at least one var is set.
              features = set((d.getVar(kind + '_FEATURES') or '').split())

    @@ -39,4 +53,10 @@ python () {
                  if conflicts:
                      raise bb.parse.SkipRecipe("conflicting %s
    feature%s '%s' (in %s_FEATURES)"
                          % (kind.lower(), 's' if len(conflicts) > 1
    else '', ' '.join(conflicts), kind))
    +
    +    # Only warn if inherited directly in a .bb-file; if the class
    is inherited
    +    # via an .inc/.bbclass it could be a false positive
    +    inherited_from_bb =
    d.getVar('FEATURES_CHECK_INCLUDE_STACK').split()[-1].endswith('.bb')
    +    if unused and inherited_from_bb:
    +        bb.warn("Recipe inherits features_check but doesn't use it")
      }
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#139374): 
https://lists.openembedded.org/g/openembedded-core/message/139374
Mute This Topic: https://lists.openembedded.org/mt/74774873/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to