Menu

Platform path not detected when importing project from sub folder

Julien
2021-03-04
2021-03-06
  • Julien

    Julien - 2021-03-04

    Hi,

    Assuming following project structure

    - MyProject
           - Cppcheck
                  - Project.cppcheck
                  - platform.xml
           - src
                  - main.c
    

    When calling cppcheck from command line : cppcheck --project=Cppcheck/Project.cppcheck directly from MyProject/ path, with a custom platform.xml on Cppcheck/ project directory the platform file is not found.

    cppcheck: error: unrecognized platform: "platform.xml".

    Looking at the code :
    else if (!mSettings->loadPlatformFile(argv[0], platform)) {
    argv[0] is the path from where we are calling cppcheck MyProject/ but that would be better to check in the path where the project file Project.cppcheck is located as everything should be relative to this file location Cppcheck/

    https://github.com/danmar/cppcheck/blob/141d2ac215c25dd60ca8230eca053756da832279/cli/cmdlineparser.cpp#L627

     
  • Daniel Marjamäki

    Thanks! I will investigate this. Well replacing argv[0] is not a good idea neither we want to be able to load platform files in the binary path.

     
  • Daniel Marjamäki

    I believe I have fixed this let us know if you will continue to see problems.

     
  • Julien

    Julien - 2021-03-06

    Thank you very much this was a fast fix !

    I will give it a try soon and keep yoy updated.
    Just one thing I seen 2x the same line here :

    filenames.push_back(Path::getPathFromFilename(Path::fromNativeSeparators(exename))
    

    Does the second one should not have + ".xml" ?

     
  • Julien

    Julien - 2021-03-06

    Thanks, it works perfectly!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.