Added support for external system headers
This commit is contained in:
@@ -94,6 +94,7 @@ void inheritable_diagram_options::inherit(
|
|||||||
puml.override(parent.puml);
|
puml.override(parent.puml);
|
||||||
generate_method_arguments.override(parent.generate_method_arguments);
|
generate_method_arguments.override(parent.generate_method_arguments);
|
||||||
generate_links.override(parent.generate_links);
|
generate_links.override(parent.generate_links);
|
||||||
|
generate_system_headers.override(parent.generate_system_headers);
|
||||||
git.override(parent.git);
|
git.override(parent.git);
|
||||||
base_directory.override(parent.base_directory);
|
base_directory.override(parent.base_directory);
|
||||||
relative_to.override(parent.relative_to);
|
relative_to.override(parent.relative_to);
|
||||||
@@ -527,6 +528,7 @@ template <> struct convert<include_diagram> {
|
|||||||
|
|
||||||
get_option(node, rhs.layout);
|
get_option(node, rhs.layout);
|
||||||
get_option(node, rhs.relative_to);
|
get_option(node, rhs.relative_to);
|
||||||
|
get_option(node, rhs.generate_system_headers);
|
||||||
|
|
||||||
// Convert the path in relative_to to an absolute path, with respect
|
// Convert the path in relative_to to an absolute path, with respect
|
||||||
// to the directory where the `.clang-uml` configuration file is located
|
// to the directory where the `.clang-uml` configuration file is located
|
||||||
@@ -588,6 +590,7 @@ template <> struct convert<config> {
|
|||||||
get_option(node, rhs.generate_method_arguments);
|
get_option(node, rhs.generate_method_arguments);
|
||||||
get_option(node, rhs.generate_packages);
|
get_option(node, rhs.generate_packages);
|
||||||
get_option(node, rhs.generate_links);
|
get_option(node, rhs.generate_links);
|
||||||
|
get_option(node, rhs.generate_system_headers);
|
||||||
get_option(node, rhs.git);
|
get_option(node, rhs.git);
|
||||||
rhs.base_directory.set(node["__parent_path"].as<std::string>());
|
rhs.base_directory.set(node["__parent_path"].as<std::string>());
|
||||||
get_option(node, rhs.relative_to);
|
get_option(node, rhs.relative_to);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ struct inheritable_diagram_options {
|
|||||||
option<git_config> git{"git"};
|
option<git_config> git{"git"};
|
||||||
option<std::filesystem::path> base_directory{"__parent_path"};
|
option<std::filesystem::path> base_directory{"__parent_path"};
|
||||||
option<std::filesystem::path> relative_to{"relative_to"};
|
option<std::filesystem::path> relative_to{"relative_to"};
|
||||||
|
option<bool> generate_system_headers{"generate_system_headers", false};
|
||||||
|
|
||||||
void inherit(const inheritable_diagram_options &parent);
|
void inherit(const inheritable_diagram_options &parent);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -109,6 +109,20 @@ void translation_unit_visitor::process_include_directive(
|
|||||||
.string());
|
.string());
|
||||||
include_file.set_line(0);
|
include_file.set_line(0);
|
||||||
}
|
}
|
||||||
|
else if (ctx.config().generate_system_headers() &&
|
||||||
|
include_directive.include_kind() == cppast::cpp_include_kind::system) {
|
||||||
|
auto directive_target = include_directive.name();
|
||||||
|
auto f = std::make_unique<source_file>();
|
||||||
|
f->set_name(include_directive.name());
|
||||||
|
f->set_type(source_file_t::kHeader);
|
||||||
|
ctx.diagram().add_element(std::move(f));
|
||||||
|
|
||||||
|
ctx.get_current_file().value().add_relationship(
|
||||||
|
relationship{common::model::relationship_t::kDependency,
|
||||||
|
ctx.diagram().get_element(directive_target).value().alias()});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
LOG_DBG("Skipping include directive to file {}", include_path.string());
|
LOG_DBG("Skipping include directive to file {}", include_path.string());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ diagrams:
|
|||||||
- ../../tests/t40001/**/*.h
|
- ../../tests/t40001/**/*.h
|
||||||
# Render the paths relative to this directory
|
# Render the paths relative to this directory
|
||||||
relative_to: ../../tests/t40001
|
relative_to: ../../tests/t40001
|
||||||
|
# Include also external system headers
|
||||||
|
generate_system_headers: true
|
||||||
include:
|
include:
|
||||||
# Include only headers belonging to these paths
|
# Include only headers belonging to these paths
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#include "lib1/lib1.h"
|
#include "lib1/lib1.h"
|
||||||
|
|
||||||
|
#include <cppast/cpp_preprocessor.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace clanguml::t40001 {
|
namespace clanguml::t40001 {
|
||||||
|
|
||||||
int foo() { return lib1::foo2(); }
|
int foo() { return lib1::foo2(); }
|
||||||
|
|||||||
@@ -40,9 +40,14 @@ TEST_CASE("t40001", "[test-case][package]")
|
|||||||
REQUIRE_THAT(puml, IsFile("t40001.cc"));
|
REQUIRE_THAT(puml, IsFile("t40001.cc"));
|
||||||
REQUIRE_THAT(puml, IsFile("t40001_include1.h"));
|
REQUIRE_THAT(puml, IsFile("t40001_include1.h"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsFile("string"));
|
||||||
|
REQUIRE_THAT(puml, IsFile("cppast/cpp_preprocessor.hpp"));
|
||||||
|
|
||||||
REQUIRE_THAT(puml, IsAssociation(_A("t40001.cc"), _A("t40001_include1.h")));
|
REQUIRE_THAT(puml, IsAssociation(_A("t40001.cc"), _A("t40001_include1.h")));
|
||||||
REQUIRE_THAT(puml, IsAssociation(_A("t40001_include1.h"), _A("lib1.h")));
|
REQUIRE_THAT(puml, IsAssociation(_A("t40001_include1.h"), _A("lib1.h")));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, IsDependency(_A("t40001_include1.h"), _A("string")));
|
||||||
|
|
||||||
save_puml(
|
save_puml(
|
||||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "../../include/lib1/lib1.h"
|
#include "../../include/lib1/lib1.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace clanguml::t40002::lib1 {
|
namespace clanguml::t40002::lib1 {
|
||||||
|
|
||||||
int foo0() { return 0; }
|
int foo0() { return 0; }
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ TEST_CASE("t40002", "[test-case][package]")
|
|||||||
REQUIRE_THAT(puml, IsFile("lib1.cc"));
|
REQUIRE_THAT(puml, IsFile("lib1.cc"));
|
||||||
REQUIRE_THAT(puml, IsFile("lib2.cc"));
|
REQUIRE_THAT(puml, IsFile("lib2.cc"));
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, !IsFile("string"));
|
||||||
|
|
||||||
REQUIRE_THAT(puml, IsAssociation(_A("t40002.cc"), _A("lib1.h")));
|
REQUIRE_THAT(puml, IsAssociation(_A("t40002.cc"), _A("lib1.h")));
|
||||||
REQUIRE_THAT(puml, IsAssociation(_A("lib1.h"), _A("lib2.h")));
|
REQUIRE_THAT(puml, IsAssociation(_A("lib1.h"), _A("lib2.h")));
|
||||||
REQUIRE_THAT(puml, IsAssociation(_A("lib1.cc"), _A("lib1.h")));
|
REQUIRE_THAT(puml, IsAssociation(_A("lib1.cc"), _A("lib1.h")));
|
||||||
|
|||||||
Reference in New Issue
Block a user