Compare commits

...

5 Commits

Author SHA1 Message Date
Bartek Kryza
4da14a32d7 Fix manual parsing of Windows source location paths (#217) 2023-12-14 19:43:37 +01:00
Bartek Kryza
7be848b8a1 Merge pull request #219 from bkryza/fix-progress-indicators-msvc
Fixed progress indicator characters on Windows (#218)
2023-12-12 14:31:20 +01:00
Bartek Kryza
66534af3fc Fixed progress indicator characters on Windows (#218) 2023-12-12 12:03:11 +01:00
Bartek Kryza
8ae47dd766 Fixed linking with LLVM17 on MSVC 2023-12-11 20:35:35 +01:00
Bartek Kryza
079758e154 Merge pull request #216 from bkryza/v0.4.2
V0.4.2
2023-12-11 14:07:50 +01:00
7 changed files with 81 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
compilation_database_dir: debug
output_directory: docs/diagrams
comment_parser: clang
add_compile_flags:
- -Wno-deprecated-declarations
remove_compile_flags:
- -Wno-class-memaccess
- -Wno-dangling-reference

View File

@@ -75,6 +75,9 @@ else(LINK_LLVM_SHARED)
LLVMWindowsDriver
LLVMWindowsManifest)
endif()
if(${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL "17.0")
list(APPEND LIBTOOLING_LIBS clangASTMatchers)
endif()
endif(MSVC)
endif(LINK_LLVM_SHARED)

View File

@@ -30,7 +30,9 @@ target_compile_options(clang-umllib PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>)
target_compile_definitions(clang-umllib PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
-DLLVM_FORCE_USE_OLD_TOOLCHAIN>)
-DLLVM_FORCE_USE_OLD_TOOLCHAIN
-DTERMCOLOR_USE_WINDOWS_API=1
-DTERMCOLOR_TARGET_WINDOWS=1>)
#
# Define the target executable clang-uml

View File

@@ -836,12 +836,23 @@ bool parse_source_location(const std::string &location_str, std::string &file,
if (tokens.size() < 3)
return false;
if (tokens.size() == 4) {
// Handle Windows paths
decltype(tokens) tmp_tokens{};
tmp_tokens.emplace_back(
fmt::format("{}:{}", tokens.at(0), tokens.at(1)));
tmp_tokens.emplace_back(tokens.at(2));
tmp_tokens.emplace_back(tokens.at(3));
tokens = std::move(tmp_tokens);
}
file = tokens.at(0);
try {
line = std::stoi(tokens.at(1));
}
catch (std::invalid_argument &e) {
line = 0;
return false;
}
try {

View File

@@ -39,7 +39,11 @@ void progress_indicator::add_progress_bar(
indicators::option::BarWidth{kBarWidth},
indicators::option::ForegroundColor{color},
indicators::option::ShowElapsedTime{true},
#if _MSC_VER
indicators::option::Fill{"="}, indicators::option::Lead{">"},
#else
indicators::option::Fill{""}, indicators::option::Lead{""},
#endif
indicators::option::Remainder{"-"},
indicators::option::PrefixText{
fmt::format("{:<25}", util::abbreviate(name, kPrefixTextWidth))},
@@ -104,8 +108,12 @@ void progress_indicator::complete(const std::string &name)
bar.set_progress(kCompleteProgressPercent);
bar.set_option(indicators::option::PostfixText{
fmt::format("{}/{} ", p.progress, p.max)});
#if _MSC_VER
const auto postfix_text = fmt::format("{}/{} OK", p.progress, p.max);
#else
const auto postfix_text = fmt::format("{}/{} ✔", p.progress, p.max);
#endif
bar.set_option(indicators::option::PostfixText{postfix_text});
bar.set_option(
indicators::option::ForegroundColor{indicators::Color::green});
bar.mark_as_completed();
@@ -118,9 +126,13 @@ void progress_indicator::fail(const std::string &name)
auto &bar = progress_bars_[p.index];
progress_bars_mutex_.unlock();
#if _MSC_VER
const auto postfix_text = fmt::format("{}/{} FAILED", p.progress, p.max);
#else
const auto postfix_text = fmt::format("{}/{} ✗", p.progress, p.max);
#endif
bar.set_option(indicators::option::ForegroundColor{indicators::Color::red});
bar.set_option(indicators::option::PostfixText{
fmt::format("{}/{} ✗", p.progress, p.max)});
bar.set_option(indicators::option::PostfixText{postfix_text});
bar.mark_as_completed();
}

View File

@@ -141,7 +141,7 @@ void translation_unit_visitor::set_source_location(
file_path = fs::absolute(file_path);
}
file_path = fs::canonical(file_path);
file_path = fs::weakly_canonical(file_path);
file = file_path.string();

View File

@@ -430,3 +430,47 @@ TEST_CASE("Test is_relative_to", "[unit-test]")
CHECK(is_relative_to(child, base1));
CHECK_FALSE(is_relative_to(child, base2));
}
TEST_CASE("Test parse_source_location", "[unit-test]")
{
using namespace clanguml::common;
const std::string int_template_str{"ns1::ns2::class1<int>"};
std::string file;
unsigned line{};
unsigned column{};
bool result = false;
result = parse_source_location("/a/b/c/d/test.cpp:123", file, line, column);
CHECK_FALSE(result);
result = false, file = "", line = 0, column = 0;
result =
parse_source_location("/a/b/c/d/test.cpp:123:456", file, line, column);
CHECK(result);
CHECK(file == "/a/b/c/d/test.cpp");
CHECK(line == 123);
CHECK(column == 456);
result = false, file = "", line = 0, column = 0;
result = parse_source_location(
"E:\\test\\src\\main.cpp:123", file, line, column);
CHECK_FALSE(result);
result = false, file = "", line = 0, column = 0;
result = parse_source_location(
"E:\\test\\src\\main.cpp:123:456", file, line, column);
CHECK(result);
CHECK(file == "E:\\test\\src\\main.cpp");
CHECK(line == 123);
CHECK(column == 456);
result = false, file = "", line = 0, column = 0;
}