diff --git a/src/cli/cli_handler.cc b/src/cli/cli_handler.cc index bebb0759..b3d1daac 100644 --- a/src/cli/cli_handler.cc +++ b/src/cli/cli_handler.cc @@ -305,8 +305,10 @@ cli_flow_t cli_handler::handle_post_config_options() cli_flow_t cli_handler::print_version() { - ostr_ << "clang-uml " << clanguml::version::CLANG_UML_VERSION << '\n'; - ostr_ << "Copyright (C) 2021-2023 Bartek Kryza " << '\n'; + ostr_ << "clang-uml " << clanguml::version::CLANG_UML_VERSION << std::endl; + ostr_ << "Copyright (C) 2021-2023 Bartek Kryza " + << std::endl; + ostr_ << util::get_os_name() << std::endl; ostr_ << "Built against LLVM/Clang libraries version: " << LLVM_VERSION_STRING << std::endl; ostr_ << "Using LLVM/Clang libraries version: " diff --git a/src/main.cc b/src/main.cc index c96a9867..45b9cf21 100644 --- a/src/main.cc +++ b/src/main.cc @@ -61,7 +61,7 @@ int main(int argc, const char *argv[]) try { const auto db = - clanguml::common::compilation_database::auto_detect_from_directory( + common::compilation_database::auto_detect_from_directory( cli.config); const auto compilation_database_files = db->getAllFiles(); @@ -73,20 +73,20 @@ int main(int argc, const char *argv[]) // We have to generate the translation units list for each diagram // before scheduling tasks, because std::filesystem::current_path // cannot be trusted with multiple threads - clanguml::common::generators::find_translation_units_for_diagrams( + common::generators::find_translation_units_for_diagrams( cli.diagram_names, cli.config, compilation_database_files, translation_units_map); - clanguml::common::generators::generate_diagrams(cli.diagram_names, - cli.config, cli.effective_output_directory, db, cli.verbose, - cli.thread_count, cli.generators, translation_units_map); + common::generators::generate_diagrams(cli.diagram_names, cli.config, + cli.effective_output_directory, db, cli.verbose, cli.thread_count, + cli.generators, translation_units_map); } - catch (clanguml::common::compilation_database_error &e) { + catch (common::compilation_database_error &e) { LOG_ERROR("Failed to load compilation database from {} due to: {}", cli.config.compilation_database_dir(), e.what()); return 1; } - catch (clanguml::util::query_driver_no_paths &e) { + catch (util::query_driver_no_paths &e) { LOG_ERROR("Quering provided compiler driver {} did not provide any " "paths, please make sure the path is correct and that your " "compiler is GCC-compatible: {}", diff --git a/src/util/util.cc b/src/util/util.cc index f307e6c3..24ce86d7 100644 --- a/src/util/util.cc +++ b/src/util/util.cc @@ -20,6 +20,9 @@ #include #include +#if __has_include() +#include +#endif namespace clanguml::util { @@ -124,6 +127,29 @@ std::string get_git_toplevel_dir() return trim(get_process_output("git rev-parse --show-toplevel")); } +std::string get_os_name() +{ +#ifdef _WIN32 + return "Windows, 32-bit"; +#elif _WIN64 + return "Windows, 64-bit"; +#elif __has_include() + utsname utsn; + uname(&utsn); + return fmt::format("{} {} {}", utsn.sysname, utsn.machine, utsn.release); +#elif __linux__ + return "Linux"; +#elif __APPLE__ || __MACH__ + return "macOS"; +#elif __FreeBSD__ + return "FreeBSD"; +#elif __unix__ || __unix + return "Unix"; +#else + return "Unknown"; +#endif +} + std::string ltrim(const std::string &s) { const size_t start = s.find_first_not_of(WHITESPACE); diff --git a/src/util/util.h b/src/util/util.h index eeafe95d..d35eaa07 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -76,6 +76,8 @@ std::string get_git_commit(); std::string get_git_toplevel_dir(); +std::string get_os_name(); + /** * @brief Split a string using delimiter *