Skip to content

Commit a857fa0

Browse files
authored
Add set of ignored output files (#641)
1 parent 1bb0580 commit a857fa0

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

server/src/Paths.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ namespace Paths {
5151
return m.first == base.end();
5252
}
5353

54-
bool skipFile(const fs::path &file) {
55-
return file.string().substr(file.string().size() - 4) == ".f.o";
56-
}
57-
5854
fs::path longestCommonPrefixPath(const fs::path &a, const fs::path &b) {
5955
if (a == b) {
6056
return a;

server/src/Paths.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ namespace Paths {
102102

103103
bool isSubPathOf(const fs::path &base, const fs::path &sub);
104104

105-
bool skipFile(const fs::path &file);
106-
107105
fs::path longestCommonPrefixPath(const fs::path &a, const fs::path &b);
108106

109107
static inline fs::path replaceExtension(const fs::path &path, const std::string &newExt) {

server/src/building/BuildDatabase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class BuildDatabase {
240240
const utbot::ProjectContext projectContext;
241241
CollectionUtils::MapFileTo<std::vector<std::shared_ptr<ObjectFileInfo>>> sourceFileInfos;
242242
CollectionUtils::MapFileTo<std::shared_ptr<ObjectFileInfo>> objectFileInfos;
243+
CollectionUtils::FileSet ignoredOutput;
243244
CollectionUtils::MapFileTo<std::shared_ptr<TargetInfo>> targetInfos;
244245
CollectionUtils::MapFileTo<std::vector<fs::path>> objectFileTargets;
245246

server/src/building/ProjectBuildDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ProjectBuildDatabase : public BuildDatabase {
1919
ProjectBuildDatabase(fs::path buildCommandsJsonPath, fs::path serverBuildDir,
2020
utbot::ProjectContext projectContext);
2121

22-
ProjectBuildDatabase(utbot::ProjectContext projectContext);
22+
explicit ProjectBuildDatabase(utbot::ProjectContext projectContext);
2323
};
2424

2525

server/src/building/ProjectBuildDatabse.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson
6969
fs::path jsonFile = compileCommand.at("file").get<std::string>();
7070
fs::path sourceFile = Paths::getCCJsonFileFullPath(jsonFile, directory);
7171

72-
if (!Paths::isSourceFile(sourceFile)){
73-
continue;
74-
}
75-
7672
std::vector<std::string> jsonArguments;
7773
if (compileCommand.contains("command")) {
7874
std::string command = compileCommand.at("command");
@@ -87,6 +83,13 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson
8783
objectInfo->command = utbot::CompileCommand(jsonArguments, directory, sourceFile);
8884
objectInfo->command.removeWerror();
8985
fs::path outputFile = objectInfo->getOutputFile();
86+
87+
if (!Paths::isSourceFile(sourceFile)) {
88+
LOG_S(INFO) << "Skip non C/C++ file: \"" << sourceFile << "\"";
89+
ignoredOutput.insert(outputFile);
90+
continue;
91+
}
92+
9093
fs::path kleeFilePathTemplate = Paths::createNewDirForFile(sourceFile, projectContext.projectPath,
9194
Paths::getUTBotFiles(projectContext));
9295
fs::path kleeFile = Paths::addSuffix(kleeFilePathTemplate, "_klee");
@@ -171,7 +174,7 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) {
171174
for (nlohmann::json const &jsonFile: linkCommand.at("files")) {
172175
auto filename = jsonFile.get<std::string>();
173176
fs::path currentFile = Paths::getCCJsonFileFullPath(filename, command.getDirectory());
174-
if (Paths::skipFile(currentFile)){
177+
if (ignoredOutput.count(currentFile)) {
175178
continue;
176179
}
177180
targetInfo->addFile(currentFile);
@@ -180,8 +183,8 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) {
180183
!CollectionUtils::containsKey(objectFileInfos,
181184
relative(currentFile, directory))) {
182185
throw CompilationDatabaseException(
183-
"compile_commands.json doesn't contain a command for object file " +
184-
currentFile.string());
186+
"compile_commands.json doesn't contain a command for object file " +
187+
currentFile.string());
185188
}
186189
if (CollectionUtils::containsKey(objectFileInfos, currentFile)) {
187190
objectFileInfos[currentFile]->linkUnit = output;

0 commit comments

Comments
 (0)