0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Functions
main.cc File Reference
#include "cli/cli_handler.h"
#include "common/compilation_database.h"
#include "common/generators/generators.h"
#include "util/query_driver_output_extractor.h"
#include "util/util.h"
#include <cli11/CLI11.hpp>
#include <spdlog/spdlog.h>
#include <cstring>

Go to the source code of this file.

Functions

int main (int argc, const char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Definition at line 44 of file main.cc.

45{
47 auto res = cli.handle_options(argc, argv);
48
49 if (res == cli::cli_flow_t::kExit)
50 return 0;
51
52 if (res == cli::cli_flow_t::kError)
53 return 1;
54
55#if !defined(NDEBUG)
56 // Catch invalid logger message formats, e.g. missing arguments
57 spdlog::set_error_handler([](const std::string & /*msg*/) {
58 assert(0 == 1); // NOLINT
59 });
60#endif
61
62 try {
63 const auto db =
65 cli.config);
66
67 const auto compilation_database_files = db->getAllFiles();
68
69 std::map<std::string /* diagram name */,
70 std::vector<std::string> /* translation units */>
71 translation_units_map;
72
73 // We have to generate the translation units list for each diagram
74 // before scheduling tasks, because std::filesystem::current_path
75 // cannot be trusted with multiple threads
77 cli.diagram_names, cli.config, compilation_database_files,
78 translation_units_map);
79
81 cli.get_runtime_config(), translation_units_map);
82 }
84 LOG_ERROR("Failed to load compilation database from {} due to: {}",
85 cli.config.compilation_database_dir(), e.what());
86 return 1;
87 }
89 LOG_ERROR("Querying provided compiler driver {} did not provide any "
90 "paths, please make sure the path is correct and that your "
91 "compiler is GCC-compatible: {}",
92 cli.config.query_driver(), e.what());
93 return 1;
94 }
95
96 return 0;
97}