diff --git a/server/src/Paths.cpp b/server/src/Paths.cpp index 2c6b12b8..d31ce27a 100644 --- a/server/src/Paths.cpp +++ b/server/src/Paths.cpp @@ -51,10 +51,6 @@ namespace Paths { return m.first == base.end(); } - bool skipFile(const fs::path &file) { - return file.string().substr(file.string().size() - 4) == ".f.o"; - } - fs::path longestCommonPrefixPath(const fs::path &a, const fs::path &b) { if (a == b) { return a; diff --git a/server/src/Paths.h b/server/src/Paths.h index 255c55b4..507d8495 100644 --- a/server/src/Paths.h +++ b/server/src/Paths.h @@ -102,8 +102,6 @@ namespace Paths { bool isSubPathOf(const fs::path &base, const fs::path &sub); - bool skipFile(const fs::path &file); - fs::path longestCommonPrefixPath(const fs::path &a, const fs::path &b); static inline fs::path replaceExtension(const fs::path &path, const std::string &newExt) { diff --git a/server/src/building/BuildDatabase.h b/server/src/building/BuildDatabase.h index 49902297..095142f6 100644 --- a/server/src/building/BuildDatabase.h +++ b/server/src/building/BuildDatabase.h @@ -240,6 +240,7 @@ class BuildDatabase { const utbot::ProjectContext projectContext; CollectionUtils::MapFileTo>> sourceFileInfos; CollectionUtils::MapFileTo> objectFileInfos; + CollectionUtils::FileSet ignoredOutput; CollectionUtils::MapFileTo> targetInfos; CollectionUtils::MapFileTo> objectFileTargets; diff --git a/server/src/building/ProjectBuildDatabase.h b/server/src/building/ProjectBuildDatabase.h index ddf8c339..2808a068 100644 --- a/server/src/building/ProjectBuildDatabase.h +++ b/server/src/building/ProjectBuildDatabase.h @@ -19,7 +19,7 @@ class ProjectBuildDatabase : public BuildDatabase { ProjectBuildDatabase(fs::path buildCommandsJsonPath, fs::path serverBuildDir, utbot::ProjectContext projectContext); - ProjectBuildDatabase(utbot::ProjectContext projectContext); + explicit ProjectBuildDatabase(utbot::ProjectContext projectContext); }; diff --git a/server/src/building/ProjectBuildDatabse.cpp b/server/src/building/ProjectBuildDatabse.cpp index 17e7a18b..5c4266c7 100644 --- a/server/src/building/ProjectBuildDatabse.cpp +++ b/server/src/building/ProjectBuildDatabse.cpp @@ -69,10 +69,6 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson fs::path jsonFile = compileCommand.at("file").get(); fs::path sourceFile = Paths::getCCJsonFileFullPath(jsonFile, directory); - if (!Paths::isSourceFile(sourceFile)){ - continue; - } - std::vector jsonArguments; if (compileCommand.contains("command")) { std::string command = compileCommand.at("command"); @@ -87,6 +83,13 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson objectInfo->command = utbot::CompileCommand(jsonArguments, directory, sourceFile); objectInfo->command.removeWerror(); fs::path outputFile = objectInfo->getOutputFile(); + + if (!Paths::isSourceFile(sourceFile)) { + LOG_S(INFO) << "Skip non C/C++ file: \"" << sourceFile << "\""; + ignoredOutput.insert(outputFile); + continue; + } + fs::path kleeFilePathTemplate = Paths::createNewDirForFile(sourceFile, projectContext.projectPath, Paths::getUTBotFiles(projectContext)); fs::path kleeFile = Paths::addSuffix(kleeFilePathTemplate, "_klee"); @@ -171,7 +174,7 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) { for (nlohmann::json const &jsonFile: linkCommand.at("files")) { auto filename = jsonFile.get(); fs::path currentFile = Paths::getCCJsonFileFullPath(filename, command.getDirectory()); - if (Paths::skipFile(currentFile)){ + if (ignoredOutput.count(currentFile)) { continue; } targetInfo->addFile(currentFile); @@ -180,8 +183,8 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) { !CollectionUtils::containsKey(objectFileInfos, relative(currentFile, directory))) { throw CompilationDatabaseException( - "compile_commands.json doesn't contain a command for object file " + - currentFile.string()); + "compile_commands.json doesn't contain a command for object file " + + currentFile.string()); } if (CollectionUtils::containsKey(objectFileInfos, currentFile)) { objectFileInfos[currentFile]->linkUnit = output;