Fixed building and tests on macos

This commit is contained in:
Bartek Kryza
2022-08-30 21:23:56 +02:00
parent f1c0361c46
commit 0cef28ac02
7 changed files with 29 additions and 6 deletions

View File

@@ -66,8 +66,6 @@ apt install ccache cmake libyaml-cpp-dev clang-12 libclang-12-dev libclang-cpp12
# macos
brew install ccache cmake llvm yaml-cpp
```
> Please note that on macos this tool is not fully functional, i.e. several test cases fail. The build instructions are
> provided for development purposes only.
Then proceed with building the sources:
@@ -79,12 +77,17 @@ make release
release/clang-uml --help
# To build using a specific installed version of LLVM use:
LLVM_VERSION=13 make release
LLVM_VERSION=14 make release
# Optionally
make install
# or
export PATH=$PATH:$PWD/release
# On macos, it is necessary to build clang-uml using the same llvm against which it is linked, e.g.
export CC=/usr/local/opt/llvm/bin/clang
export CCX=/usr/local/opt/llvm/bin/clang++
LLVM_VERSION=14 make release
```
## Usage

View File

@@ -133,6 +133,9 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
if (enm->getNameAsString().empty())
return true;
if (!diagram().should_include(enm->getQualifiedNameAsString()))
return true;
LOG_DBG("= Visiting enum declaration {} at {}",
enm->getQualifiedNameAsString(),
enm->getLocation().printToString(source_manager_));
@@ -304,6 +307,9 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
if (source_manager_.isInSystemHeader(cls->getSourceRange().getBegin()))
return true;
if (!diagram().should_include(cls->getQualifiedNameAsString()))
return true;
LOG_DBG("= Visiting class declaration {} at {}",
cls->getQualifiedNameAsString(),
cls->getLocation().printToString(source_manager_));

View File

@@ -154,6 +154,12 @@ void class_diagram::initialize_template_aliases()
if (!template_aliases().count("std::basic_string<char>")) {
template_aliases().insert({"std::basic_string<char>", "std::string"});
}
if (!template_aliases().count("std::basic_string<char,std::char_traits<"
"char>,std::allocator<char>>")) {
template_aliases().insert({"std::basic_string<char,std::char_traits<"
"char>,std::allocator<char>>",
"std::string"});
}
if (!template_aliases().count("std::basic_string<wchar_t>")) {
template_aliases().insert(
{"std::basic_string<wchar_t>", "std::wstring"});

View File

@@ -7,6 +7,10 @@ set(CMAKE_CXX_STANDARD 17)
set(TEST_DISABLE_WARNINGS "-Wno-unused-parameter -Wno-unused-private-field -Wno-unused-variable -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCLANG_CXXFLAGS} ${TEST_DISABLE_WARNINGS}")
if(APPLE)
# Without this, clang-uml test cases fail with error saying that clang cannot find stdarg.h
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${LLVM_LIBRARY_DIR}/clang/${LLVM_PACKAGE_VERSION}/include")
endif(APPLE)
file(GLOB_RECURSE TEST_CASE_SOURCES t*/*.cc)
file(GLOB_RECURSE TEST_CASE_CONFIGS t*/.clang-uml)

View File

@@ -17,3 +17,6 @@ diagrams:
- clanguml::t00039::ns3::F<T>
relationships:
- inheritance
exclude:
namespaces:
- std

View File

@@ -17,3 +17,5 @@ diagrams:
exclude:
specializations:
- clanguml::t00042::C<T>
namespaces:
- std

View File

@@ -48,7 +48,6 @@ TEST_CASE("t00048", "[test-case][class]")
REQUIRE_THAT(puml, IsBaseClass(_A("Base"), _A("A")));
REQUIRE_THAT(puml, IsBaseClass(_A("Base"), _A("B")));
save_puml(
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
}