From 3dba31a7929ebc64b1f341ee4de0d8548487b8af Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 28 Jan 2024 12:42:26 +0100 Subject: [PATCH 1/2] Fixed handling of absolute paths in glob patterns --- src/config/config.cc | 10 ++++++---- tests/t00025/.clang-uml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/config/config.cc b/src/config/config.cc index 012ebfcc..c0de719a 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -253,12 +253,14 @@ std::vector diagram::get_translation_units() const LOG_DBG("Looking for translation units in {}", root_directory().string()); for (const auto &g : glob()) { - std::string glob_path = - fmt::format("{}/{}", root_directory().string(), g.c_str()); + std::filesystem::path absolute_glob_path{g}; - LOG_DBG("Searching glob path {}", glob_path); + if (!absolute_glob_path.is_absolute()) + absolute_glob_path = root_directory() / absolute_glob_path; - auto matches = glob::glob(glob_path, true, false); + LOG_DBG("Searching glob path {}", absolute_glob_path.string()); + + auto matches = glob::glob(absolute_glob_path, true, false); for (const auto &match : matches) { const auto path = diff --git a/tests/t00025/.clang-uml b/tests/t00025/.clang-uml index 5dced1b2..ef03f511 100644 --- a/tests/t00025/.clang-uml +++ b/tests/t00025/.clang-uml @@ -2,7 +2,7 @@ diagrams: t00025_class: type: class glob: - - /t00025.cc + - t00025.cc using_namespace: clanguml::t00025 include: namespaces: From 7d28be525f4cac6ea80005cebbb71349eba3dc6e Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sun, 28 Jan 2024 15:55:59 +0100 Subject: [PATCH 2/2] Fixed glob absolute paths handling on Windows --- build.ps1 | 2 +- packaging/make_installer.ps1 | 2 +- src/config/config.cc | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index e13a4212..4ae6b2ef 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,4 @@ -param ($Prefix="C:\clang-uml", $BuildType="Release") +param ($Prefix="C:\clang-uml-llvm17", $BuildType="Release") cmake -S . -B $BuildType -DCMAKE_PREFIX_PATH="$Prefix" -DENABLE_CXX_MODULES_TEST_CASES=OFF -Thost=x64 cmake --build $BuildType --config $BuildType diff --git a/packaging/make_installer.ps1 b/packaging/make_installer.ps1 index 2ceb97a0..6e364cfe 100644 --- a/packaging/make_installer.ps1 +++ b/packaging/make_installer.ps1 @@ -1,6 +1,6 @@ # This script assumes that all clang-uml dependencies are instaled in C:\clang-uml -param ($Prefix="C:\clang-uml", $BuildType="Release") +param ($Prefix="C:\clang-uml-llvm17", $BuildType="Release") mkdir _BUILD diff --git a/src/config/config.cc b/src/config/config.cc index c0de719a..9a4f7bb5 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -255,12 +255,16 @@ std::vector diagram::get_translation_units() const for (const auto &g : glob()) { std::filesystem::path absolute_glob_path{g}; +#ifdef _MSC_VER + if (!absolute_glob_path.has_root_name()) +#else if (!absolute_glob_path.is_absolute()) +#endif absolute_glob_path = root_directory() / absolute_glob_path; LOG_DBG("Searching glob path {}", absolute_glob_path.string()); - auto matches = glob::glob(absolute_glob_path, true, false); + auto matches = glob::glob(absolute_glob_path.string(), true, false); for (const auto &match : matches) { const auto path =