Skip to content

Add set of ignored output files #641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions server/src/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions server/src/Paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions server/src/building/BuildDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class BuildDatabase {
const utbot::ProjectContext projectContext;
CollectionUtils::MapFileTo<std::vector<std::shared_ptr<ObjectFileInfo>>> sourceFileInfos;
CollectionUtils::MapFileTo<std::shared_ptr<ObjectFileInfo>> objectFileInfos;
CollectionUtils::FileSet ignoredOutput;
CollectionUtils::MapFileTo<std::shared_ptr<TargetInfo>> targetInfos;
CollectionUtils::MapFileTo<std::vector<fs::path>> objectFileTargets;

Expand Down
2 changes: 1 addition & 1 deletion server/src/building/ProjectBuildDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};


Expand Down
17 changes: 10 additions & 7 deletions server/src/building/ProjectBuildDatabse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson
fs::path jsonFile = compileCommand.at("file").get<std::string>();
fs::path sourceFile = Paths::getCCJsonFileFullPath(jsonFile, directory);

if (!Paths::isSourceFile(sourceFile)){
continue;
}

std::vector<std::string> jsonArguments;
if (compileCommand.contains("command")) {
std::string command = compileCommand.at("command");
Expand All @@ -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");
Expand Down Expand Up @@ -171,7 +174,7 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) {
for (nlohmann::json const &jsonFile: linkCommand.at("files")) {
auto filename = jsonFile.get<std::string>();
fs::path currentFile = Paths::getCCJsonFileFullPath(filename, command.getDirectory());
if (Paths::skipFile(currentFile)){
if (ignoredOutput.count(currentFile)) {
continue;
}
targetInfo->addFile(currentFile);
Expand All @@ -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;
Expand Down