Added support for external system headers

This commit is contained in:
Bartek Kryza
2022-04-25 00:18:13 +02:00
parent 6e78e87bb0
commit bd0bb4455f
8 changed files with 33 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ void inheritable_diagram_options::inherit(
puml.override(parent.puml);
generate_method_arguments.override(parent.generate_method_arguments);
generate_links.override(parent.generate_links);
generate_system_headers.override(parent.generate_system_headers);
git.override(parent.git);
base_directory.override(parent.base_directory);
relative_to.override(parent.relative_to);
@@ -527,6 +528,7 @@ template <> struct convert<include_diagram> {
get_option(node, rhs.layout);
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
// 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_packages);
get_option(node, rhs.generate_links);
get_option(node, rhs.generate_system_headers);
get_option(node, rhs.git);
rhs.base_directory.set(node["__parent_path"].as<std::string>());
get_option(node, rhs.relative_to);

View File

@@ -112,6 +112,7 @@ struct inheritable_diagram_options {
option<git_config> git{"git"};
option<std::filesystem::path> base_directory{"__parent_path"};
option<std::filesystem::path> relative_to{"relative_to"};
option<bool> generate_system_headers{"generate_system_headers", false};
void inherit(const inheritable_diagram_options &parent);
};

View File

@@ -109,6 +109,20 @@ void translation_unit_visitor::process_include_directive(
.string());
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 {
LOG_DBG("Skipping include directive to file {}", include_path.string());
}