Skip to content

CConditionalScanner does not detect included header from a command line macro #4193

Closed

Description

@mwichmann

This issue is generated as a result of investigating using the CConditionalScanner to detect dependencies when the #include uses a macro, after a Discord discussion here: https://discord.com/channels/571796279483564041/571796280146133047/998690474216927345. This base problem has actually been recorded in several past issues, including #344 #2601 #3038.

The investigation shows that if the macro is defined in the source file, like this:

#define HEADER "foo.h"
#include HEADER

then CConditionalScanner indeed produces the dependency, but if it is defined as a compiler command-line option, it is not.

env = Environment(CPPDEFINES=['HEADER=\\"foo.h\\"'])

Attaching a diff to the unit test file for the C scanner, which demonstrates this behavior (unfortunately had to make into a file type github would accept)

CTests-diff.zip

Activity

  1. ivankravets commented on Jul 25, 2022

    @ivankravets
    Contributor

    Hi @mwichmann, do you use the latest development version? It should be fixed by d9192db

  2. mwichmann commented on Jul 25, 2022

    @mwichmann
    CollaboratorAuthor

    Doesn't seem to be... which doesn't mean my test isn't faulty. I still get:

    AssertionError: False is not true : expect ['f9.h'] != scanned []
    
  3. mwichmann commented on Mar 21, 2023

    @mwichmann
    CollaboratorAuthor

    I think this may have been fixed by #4263 - not an issue with the conditional scanner, but with the way processDefines emitted a single string-valued macro. I'll need to swing by and check in more detail, but we may be able to close this.

  4. mwichmann commented on Mar 21, 2023

    @mwichmann
    CollaboratorAuthor

    Okay, reran the test case attached here, it still fails, but can be made to pass by:

    -        env = DummyEnvironment(CPPDEFINES=['HEADER=\\"f9.h\\"'])
    +        env = DummyEnvironment(CPPDEFINES=[('HEADER', '\\"f9.h\\"')])

    So there may still be a CPPDEFINES hole here.

  5. mwichmann commented on Mar 21, 2023

    @mwichmann
    CollaboratorAuthor

    The hole is in SCons/Scanner/C/dictifyCPPDEFINES() - it does its own processing of defines, not using the processDefines routine the rest of SCons uses, and did not deal with "NAME=VALUE" strings, either as a solo value, or as a member of a sequence. (note this problem is not related to the large CPPDEFINES refactor, it was always possible to assign a single string or a string-in-a-list to CPPDEFINES, only after type conversion is triggered might you not have those anymore). I have a patch and some additional tests.

  6. added a commit that references this issue on Mar 21, 2023
    fd166f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions