Source code location discovery
The RuntimeObjectSystem automatically searches for source files, attempting to discover them using:
- The original location of the source.
- A previously discovered source directory.
- A directory which shares a common root with the executable.
- A directory which shares a common root with a user provided directory through the AddPathToSourceSearch function.
A common root is a directory where part of the original source path matches the path from the common root. So if there is a common root /projectfiles/myproject/ and the original source file is /aproject/source/source.cpp then the following matches could be found if they existed:
- /aproject/source/source.cpp
- /projectfiles/myproject/aproject/source/source.cpp
- /projectfiles/myproject/source/source.cpp
- /projectfiles/myproject/source.cpp
- /projectfiles/aproject/source/source.cpp
- /projectfiles/source/source.cpp
- /projectfiles/source.cpp
- /source/source.cpp
- /source.cpp
Developers can use the RuntimeObjectSystem::FindFiles function to locate files. A common pattern is to use FindFiles( FILE ) to locate the current source file, and then use this to construct a path relative to the source file.
_RuntimeObjectSystem::AddIncludeDir and _RuntimeObjectSystem::AddLibraryDir do not search for the paths provided, so these should be located prior to adding them. See the SimpleTest demo for example code.
A good practice is to provide developers a means to configure their source paths using AddPathToSourceSearch, either through configuration files or a dialogue box for example.