Initial MSVC build working
This commit is contained in:
@@ -32,8 +32,6 @@ public:
|
||||
clanguml::common::id_t id() const noexcept { return id_; }
|
||||
void set_id(clanguml::common::id_t id) { id_ = id; }
|
||||
|
||||
void set_id(id_t id);
|
||||
|
||||
void is_virtual(bool is_virtual);
|
||||
bool is_virtual() const;
|
||||
|
||||
|
||||
@@ -763,6 +763,7 @@ void translation_unit_visitor::process_class_children(
|
||||
|
||||
// Static fields have to be processed by iterating over variable
|
||||
// declarations
|
||||
#ifndef _MSC_VER
|
||||
for (const auto *decl : cls->decls()) {
|
||||
if (decl->getKind() == clang::Decl::Var) {
|
||||
const clang::VarDecl *variable_declaration{
|
||||
@@ -788,7 +789,7 @@ void translation_unit_visitor::process_class_children(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if (cls->isCompleteDefinition())
|
||||
for (const auto *friend_declaration : cls->friends()) {
|
||||
if (friend_declaration != nullptr)
|
||||
@@ -1429,7 +1430,7 @@ std::unique_ptr<class_> translation_unit_visitor::
|
||||
template_instantiation.set_name(template_decl->getNameAsString());
|
||||
template_instantiation.set_namespace(ns);
|
||||
template_instantiation.set_id(template_decl->getID() +
|
||||
static_cast<id_t>(
|
||||
static_cast<common::id_t>(
|
||||
std::hash<std::string>{}(full_template_specialization_name) >> 4U));
|
||||
|
||||
build_template_instantiation_process_template_arguments(parent,
|
||||
|
||||
@@ -191,14 +191,17 @@ inja::json generator<C, D>::element_context(const E &e) const
|
||||
if (!e.file().empty()) {
|
||||
std::filesystem::path file{e.file()};
|
||||
std::string relative_path = file.string();
|
||||
|
||||
#if _MSC_VER
|
||||
if (file.is_absolute() && ctx.contains("git"))
|
||||
#else
|
||||
if (file.is_absolute() && ctx.template contains("git"))
|
||||
#endif
|
||||
relative_path =
|
||||
std::filesystem::relative(file, ctx["git"]["toplevel"]);
|
||||
std::filesystem::relative(file, ctx["git"]["toplevel"]).string();
|
||||
|
||||
ctx["element"]["source"]["path"] = relative_path;
|
||||
ctx["element"]["source"]["full_path"] = file.string();
|
||||
ctx["element"]["source"]["name"] = file.filename();
|
||||
ctx["element"]["source"]["name"] = file.filename().string();
|
||||
ctx["element"]["source"]["line"] = e.line();
|
||||
}
|
||||
|
||||
|
||||
@@ -184,12 +184,12 @@ tvl::value_t namespace_filter::match(
|
||||
auto namespace_starts_with_element_qualified_name =
|
||||
nsit.starts_with(e.get_namespace());
|
||||
|
||||
auto result = element_full_name_starts_with_namespace |
|
||||
auto result = element_full_name_starts_with_namespace ||
|
||||
element_full_name_equals_pattern;
|
||||
|
||||
if (is_inclusive)
|
||||
result =
|
||||
result | namespace_starts_with_element_qualified_name;
|
||||
result || namespace_starts_with_element_qualified_name;
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
explicit source_file(const std::filesystem::path &p)
|
||||
{
|
||||
set_path({p.parent_path().string()});
|
||||
set_name(p.filename());
|
||||
set_name(p.filename().string());
|
||||
is_absolute_ = p.is_absolute();
|
||||
set_id(common::to_id(p));
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ protected:
|
||||
private:
|
||||
clang::SourceManager &source_manager_;
|
||||
|
||||
const clanguml::config::diagram &config_;
|
||||
[[maybe_unused]] const clanguml::config::diagram &config_;
|
||||
|
||||
std::unique_ptr<comment::comment_visitor> comment_visitor_;
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ decorator_toks decorator::tokenize(const std::string &label, std::string_view c)
|
||||
decorator_toks res;
|
||||
res.label = label;
|
||||
size_t pos{};
|
||||
const auto *it = c.begin();
|
||||
auto it = c.begin();
|
||||
std::advance(it, label.size());
|
||||
|
||||
if (*it == ':') {
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
void finalize() { }
|
||||
|
||||
private:
|
||||
clang::SourceManager &source_manager_;
|
||||
[[maybe_unused]] clang::SourceManager &source_manager_;
|
||||
|
||||
// Reference to the output diagram model
|
||||
clanguml::include_diagram::model::diagram &diagram_;
|
||||
|
||||
@@ -551,7 +551,7 @@ int add_config_diagram(clanguml::common::model::diagram_t type,
|
||||
return 1;
|
||||
}
|
||||
|
||||
YAML::Node doc = YAML::LoadFile(config_file);
|
||||
YAML::Node doc = YAML::LoadFile(config_file.string());
|
||||
|
||||
for (YAML::const_iterator it = doc["diagrams"].begin();
|
||||
it != doc["diagrams"].end(); ++it) {
|
||||
|
||||
@@ -220,6 +220,7 @@ void translation_unit_visitor::process_class_children(
|
||||
|
||||
// Static fields have to be processed by iterating over variable
|
||||
// declarations
|
||||
#ifndef _MSC_VER
|
||||
for (const auto *decl : cls.decls()) {
|
||||
if (decl->getKind() == clang::Decl::Var) {
|
||||
const clang::VarDecl *variable_declaration{
|
||||
@@ -230,6 +231,7 @@ void translation_unit_visitor::process_class_children(
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cls.isCompleteDefinition())
|
||||
for (const auto *friend_declaration : cls.friends()) {
|
||||
|
||||
@@ -49,12 +49,16 @@ void setup_logging(int verbose)
|
||||
std::string get_process_output(const std::string &command)
|
||||
{
|
||||
constexpr size_t kBufferSize{1024};
|
||||
|
||||
std::array<char, kBufferSize> buffer{};
|
||||
std::string result;
|
||||
|
||||
#if defined(__linux) || defined(__unix)
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(
|
||||
popen(command.c_str(), "r"), pclose);
|
||||
|
||||
#elif defined(WINDOWS) || defined(_WIN32) || defined(WIN32)
|
||||
std::unique_ptr<FILE, decltype(&_pclose)> pipe(
|
||||
_popen(command.c_str(), "r"), _pclose);
|
||||
#endif
|
||||
if (!pipe) {
|
||||
throw std::runtime_error("popen() failed!");
|
||||
}
|
||||
@@ -68,12 +72,25 @@ std::string get_process_output(const std::string &command)
|
||||
|
||||
std::string get_env(const std::string &name)
|
||||
{
|
||||
#if defined(__linux) || defined(__unix)
|
||||
const char *value = std::getenv(name.c_str()); // NOLINT
|
||||
|
||||
if (value == nullptr)
|
||||
return {};
|
||||
|
||||
return std::string{value};
|
||||
#elif defined(WINDOWS) || defined(_WIN32) || defined(WIN32)
|
||||
static constexpr auto kMaxEnvLength = 2096U;
|
||||
static char value[kMaxEnvLength];
|
||||
const DWORD ret =
|
||||
GetEnvironmentVariableA(name.c_str(), value, kMaxEnvLength);
|
||||
if (ret == 0 || ret > kMaxEnvLength)
|
||||
return {};
|
||||
else
|
||||
return value;
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is_git_repository()
|
||||
@@ -83,13 +100,9 @@ bool is_git_repository()
|
||||
if (!env.empty())
|
||||
return true;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
return false;
|
||||
#else
|
||||
return contains(
|
||||
trim(get_process_output("git rev-parse --git-dir 2> /dev/null")),
|
||||
trim(get_process_output("git rev-parse --git-dir")),
|
||||
".git");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string get_git_branch()
|
||||
|
||||
Reference in New Issue
Block a user