MCPcopy Create free account
hub / github.com/KDAB/codebrowser / main

Function main

generator/main.cpp:307–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307int main(int argc, const char **argv) {
308 std::string ErrorMessage;
309 std::unique_ptr<clang::tooling::CompilationDatabase> Compilations(
310 clang::tooling::FixedCompilationDatabase::loadFromCommandLine(argc, argv
311#if CLANG_VERSION_MAJOR >= 5
312 , ErrorMessage
313#endif
314 ));
315 if (!ErrorMessage.empty()) {
316 std::cerr << ErrorMessage << std::endl;
317 ErrorMessage = {};
318 }
319
320 llvm::cl::ParseCommandLineOptions(argc, argv);
321
322 ProjectManager projectManager(OutputPath, DataPath);
323 for(std::string &s : ProjectPaths) {
324 auto colonPos = s.find(':');
325 if (colonPos >= s.size()) {
326 std::cerr << "fail to parse project option : " << s << std::endl;
327 continue;
328 }
329 auto secondColonPos = s.find(':', colonPos+1);
330 ProjectInfo info { s.substr(0, colonPos), s.substr(colonPos+1, secondColonPos - colonPos -1),
331 secondColonPos < s.size() ? s.substr(secondColonPos + 1) : std::string() };
332 projectManager.addProject(std::move(info));
333 }
334 for(std::string &s : ExternalProjectPaths) {
335 auto colonPos = s.find(':');
336 if (colonPos >= s.size()) {
337 std::cerr << "fail to parse project option : " << s << std::endl;
338 continue;
339 }
340 auto secondColonPos = s.find(':', colonPos+1);
341 if (secondColonPos >= s.size()) {
342 std::cerr << "fail to parse project option : " << s << std::endl;
343 continue;
344 }
345 ProjectInfo info { s.substr(0, colonPos), s.substr(colonPos+1, secondColonPos - colonPos -1),
346 ProjectInfo::External };
347 info.external_root_url = s.substr(secondColonPos + 1);
348 projectManager.addProject(std::move(info));
349 }
350 BrowserAction::projectManager = &projectManager;
351
352
353 if (!Compilations && llvm::sys::fs::exists(BuildPath)) {
354 if (llvm::sys::fs::is_directory(BuildPath)) {
355 Compilations = std::unique_ptr<clang::tooling::CompilationDatabase>(
356 clang::tooling::CompilationDatabase::loadFromDirectory(BuildPath, ErrorMessage));
357 } else {
358 Compilations = std::unique_ptr<clang::tooling::CompilationDatabase>(
359 clang::tooling::JSONCompilationDatabase::loadFromFile(BuildPath, ErrorMessage
360#if CLANG_VERSION_MAJOR >= 4
361 , clang::tooling::JSONCommandLineSyntax::AutoDetect
362#endif
363 ));
364 }

Callers

nothing calls this directly

Calls 8

canonicalizeFunction · 0.85
proceedCommandFunction · 0.85
projectForFileMethod · 0.80
openMethod · 0.80
sizeMethod · 0.45
addProjectMethod · 0.45
shouldProcessMethod · 0.45
generateMethod · 0.45

Tested by

no test coverage detected