diff options
author | yenatch <yenatch@gmail.com> | 2017-07-22 18:49:38 -0400 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2017-07-22 18:49:38 -0400 |
commit | 0faa6c9c93804c4ce0e6fc8e5a6d5cfbc85f01da (patch) | |
tree | 7e42c1ad480d5d0c49e8fd45f2f8766bb0280922 /tools/scaninc/scaninc.cpp | |
parent | 5e80a12ec9fcf2201c070712d8e2dcefe2a0e364 (diff) |
scaninc: read c includes
Now editing .h files triggers a rebuild.
Also allow .h and .inc files to be passed as a main argument.
src/ and include/ are temporarily hardcoded.
Diffstat (limited to 'tools/scaninc/scaninc.cpp')
-rw-r--r-- | tools/scaninc/scaninc.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp index b6f7ba767..10cb06eee 100644 --- a/tools/scaninc/scaninc.cpp +++ b/tools/scaninc/scaninc.cpp @@ -55,16 +55,45 @@ int main(int argc, char **argv) std::string extension = initialPath.substr(pos + 1); - if (extension == "c") + std::string srcDir("src/"); + std::string includeDir("include/"); + + if (extension == "c" || extension == "h") { - CFile file(initialPath); + filesToProcess.push(initialPath); + + while (!filesToProcess.empty()) + { + CFile file(filesToProcess.top()); + filesToProcess.pop(); - file.FindIncbins(); - dependencies = file.GetIncbins(); + file.FindIncbins(); + for (auto incbin : file.GetIncbins()) + { + dependencies.insert(incbin); + } + for (auto include : file.GetIncludes()) + { + std::string path(srcDir + include); + if (!CanOpenFile(path)) + { + path = includeDir + include; + } + + if (CanOpenFile(path)) + { + bool inserted = dependencies.insert(path).second; + if (inserted) + { + filesToProcess.push(path); + } + } + } + } } - else if (extension == "s") + else if (extension == "s" || extension == "inc") { - filesToProcess.push(std::string(argv[1])); + filesToProcess.push(initialPath); while (!filesToProcess.empty()) { |