matusnovak/doxybook2

Can not build on Mac OS 10.11 + Patch

X-Ryl669 opened this issue · 1 comments

I've tried to build Doxybook2 on MacOS El Capitan, and it failed because of missing value() method for std::optional. The explanation is very subtle:
value() can throw an bad_optional_access which is in defined in the dylib starting with MacOS 10.14, it's not available on earlier version.

Please notice that operator * works (it doesn't throw), so I've replaced the former by the latter.

The patch is thus very simple:

diff --git a/src/Doxybook/Renderer.cpp b/src/Doxybook/Renderer.cpp
index 1d16626..c35f8d6 100644
--- a/src/Doxybook/Renderer.cpp
+++ b/src/Doxybook/Renderer.cpp
@@ -70,7 +70,7 @@ static std::string basename(const std::string& path) {

 Doxybook2::Renderer::Renderer(const Config& config, const std::optional<std::string>& templatesPath)
     : config(config), env(std::make_unique<inja::Environment>(
-                          templatesPath.has_value() ? trimPath(templatesPath.value()) + SEPARATOR : "./")) {
+                          templatesPath.has_value() ? trimPath(*templatesPath) + SEPARATOR : "./")) {

     env->add_callback("isEmpty", 1, [](inja::Arguments& args) -> bool {
         const auto arg = args.at(0)->get<std::string>();
@@ -179,7 +179,7 @@ Doxybook2::Renderer::Renderer(const Config& config, const std::optional<std::str
     std::string includePrefix = "";

     if (templatesPath.has_value()) {
-        includePrefix = trimPath(templatesPath.value()) + SEPARATOR;
+        includePrefix = trimPath(*templatesPath) + SEPARATOR;

         directoryIterator(includePrefix, [&](const std::string& file) {
             const auto name = basename(file);

Hi @X-Ryl669

Thanks a lot for the patch. I don't own a Mac so the only way for me to look for these kind of platform-specific errors is through a continuous integration.

I have added your patch to the 1.1.4 release here: releases/tag/v1.1.4