@@ -31,7 +31,8 @@ static std::string tryConvertOptionToPath(const std::string &possibleFilePath, c
31
31
32
32
ProjectBuildDatabase::ProjectBuildDatabase (fs::path _buildCommandsJsonPath,
33
33
fs::path _serverBuildDir,
34
- utbot::ProjectContext _projectContext) :
34
+ utbot::ProjectContext _projectContext,
35
+ bool skipObjectWithoutSource) :
35
36
BuildDatabase(_serverBuildDir,
36
37
_buildCommandsJsonPath,
37
38
fs::canonical (_buildCommandsJsonPath / " link_commands.json" ),
@@ -47,7 +48,7 @@ ProjectBuildDatabase::ProjectBuildDatabase(fs::path _buildCommandsJsonPath,
47
48
auto linkCommandsJson = JsonUtils::getJsonFromFile (linkCommandsJsonPath);
48
49
auto compileCommandsJson = JsonUtils::getJsonFromFile (compileCommandsJsonPath);
49
50
initObjects (compileCommandsJson);
50
- initInfo (linkCommandsJson);
51
+ initInfo (linkCommandsJson, skipObjectWithoutSource );
51
52
filterInstalledFiles ();
52
53
addLocalSharedLibraries ();
53
54
fillTargetInfoParents ();
@@ -58,9 +59,10 @@ ProjectBuildDatabase::ProjectBuildDatabase(fs::path _buildCommandsJsonPath,
58
59
}
59
60
}
60
61
61
- ProjectBuildDatabase::ProjectBuildDatabase (utbot::ProjectContext projectContext) : ProjectBuildDatabase(
62
+ ProjectBuildDatabase::ProjectBuildDatabase (utbot::ProjectContext projectContext, bool skipObjectWithoutSource)
63
+ : ProjectBuildDatabase(
62
64
CompilationUtils::substituteRemotePathToCompileCommandsJsonPath (projectContext),
63
- Paths::getUTBotBuildDir(projectContext), std::move(projectContext)) {
65
+ Paths::getUTBotBuildDir(projectContext), std::move(projectContext), skipObjectWithoutSource ) {
64
66
}
65
67
66
68
@@ -154,7 +156,7 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson
154
156
}
155
157
}
156
158
157
- void ProjectBuildDatabase::initInfo (const nlohmann::json &linkCommandsJson) {
159
+ void ProjectBuildDatabase::initInfo (const nlohmann::json &linkCommandsJson, bool skipObjectWithoutSource ) {
158
160
for (nlohmann::json const &linkCommand: linkCommandsJson) {
159
161
fs::path directory = linkCommand.at (" directory" ).get <std::string>();
160
162
std::vector<std::string> jsonArguments;
@@ -189,14 +191,17 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) {
189
191
if (ignoredOutput.count (currentFile)) {
190
192
continue ;
191
193
}
192
- targetInfo->addFile (currentFile);
193
194
if (Paths::isObjectFile (currentFile)) {
194
195
if (!CollectionUtils::containsKey (objectFileInfos, currentFile) &&
195
196
!CollectionUtils::containsKey (objectFileInfos,
196
197
relative (currentFile, directory))) {
197
198
std::string message =
198
199
" compile_commands.json doesn't contain a command for object file " +
199
200
currentFile.string ();
201
+ if (skipObjectWithoutSource) {
202
+ LOG_S (WARNING) << message;
203
+ continue ;
204
+ }
200
205
LOG_S (ERROR) << message;
201
206
throw CompilationDatabaseException (message);
202
207
}
@@ -207,6 +212,7 @@ void ProjectBuildDatabase::initInfo(const nlohmann::json &linkCommandsJson) {
207
212
objectFileInfos[relative (currentFile, directory)]->linkUnit = output;
208
213
}
209
214
}
215
+ targetInfo->addFile (currentFile);
210
216
}
211
217
targetInfo->commands .emplace_back (command);
212
218
}
0 commit comments