moosetechnology / Famix-Cpp

Famix metamodel for C/C++
MIT License
1 stars 2 forks source link

create included file based on root and not includer #19

Closed nkinesis closed 12 months ago

nkinesis commented 1 year ago

Issue Let's suppose I have an XML file like this:

`

` Result: all files are created correctly in the model, according to the file/folder hierarchy. However, there might be a case where a file is only mentioned in the XML as include, and not as file. For example: ` ` In this case, LibraryInfo.cpp will be created under the correct folder hierarchy (./foo/bar), but LibraryInfo.h and Precompiled.h will be created under a duplicated and therefore incorrect folder hierarchy: ./foo/bar/foo/bar/LibraryInfo.h. Why does it happen? This happens because the importer was written assuming that all include paths are relative to the files which are including them. This is not always true for the game engines I'm analysing, and for this reason, I resolve all include paths to absolute paths before running the importer. **Solution** Given that all my paths are absolute, there is no reason to deal with them as relative in any methods in the FamixCPreprocVisitor. Therefore, I changed the methods to work both with absolute and relative paths. In my game engine parser, all absolute paths are identified by a trailing dot. If the path starts with a dot, the importer will then consider it to be absolute. Otherwise, the importer will consider it to be relative.