File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 33
44#include < memory>
55#include < unordered_map>
6+ #include < vector>
67
78#include < boost/program_options.hpp>
8-
99#include < odb/database.hxx>
1010
1111namespace po = boost::program_options;
@@ -43,6 +43,7 @@ struct ParserContext
4343 std::string& compassRoot;
4444 po::variables_map& options;
4545 std::unordered_map<std::string, IncrementalStatus> fileStatus;
46+ std::vector<std::string> moduleDirectories;
4647};
4748
4849} // parser
Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ po::options_description commandLineArguments()
8585 " further actions modifying the state of the database." )
8686 (" incremental-threshold" , po::value<int >()->default_value (10 ),
8787 " This is a threshold percentage. If the total ratio of changed files "
88- " is greater than this value, full parse is forced instead of incremental parsing." );
88+ " is greater than this value, full parse is forced instead of incremental parsing." )
89+ (" modules,m" , po::value<std::string>(),
90+ " For metrics calculations, you can specify the project's (sub)module structure."
91+ " Provide the path of a text file for this setting."
92+ " The file should contain directory paths, each on a separate line, which will be considered modules." );
8993
9094 return desc;
9195}
Original file line number Diff line number Diff line change 1+ #include < boost/filesystem/exception.hpp>
12#include < fstream>
23
34#include < boost/filesystem.hpp>
1213#include < parser/sourcemanager.h>
1314
1415namespace po = boost::program_options;
16+ namespace fs = boost::filesystem;
1517
1618namespace cc
1719{
@@ -76,6 +78,31 @@ ParserContext::ParserContext(
7678
7779 // TODO: detect ADDED files
7880 });
81+
82+ // Fill moduleDirectories vector
83+ if (options.count (" modules" )) {
84+ const std::string& modulesFilePath = options[" modules" ].as <std::string>();
85+
86+ std::ifstream fileStream (modulesFilePath);
87+
88+ if (!fileStream.good ()) {
89+ LOG (error) << " Failed to open modules file: " << modulesFilePath;
90+ return ;
91+ }
92+
93+ LOG (info) << " Processing modules file: " << modulesFilePath;
94+
95+ std::string line;
96+ while (std::getline (fileStream, line)) {
97+ try {
98+ const fs::path p = fs::canonical (line);
99+ moduleDirectories.push_back (p.string ());
100+ } catch (fs::filesystem_error& err) {
101+ LOG (error) << " Failed to process path from modules file: " << line;
102+ LOG (error) << err.what ();
103+ }
104+ }
105+ }
79106}
80107}
81108}
You can’t perform that action at this time.
0 commit comments