Source code location discovery

Doug Binks edited this page Oct 19, 2013 · 4 revisions

The RuntimeObjectSystem automatically searches for source files, attempting to discover them using:

  1. The original location of the source.
  2. A previously discovered source directory.
  3. A directory which shares a common root with the executable.
  4. 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.