From 5f8f8af25fc7f2d0f542ff23faeb25872d61149f Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Thu, 12 Feb 2015 21:56:19 +0200 Subject: [PATCH] Implicitly redirect cmdhelp includes to corresponding JSON files This should help with the superfluous building due to cmdhelp. --- buildaux/mkdeps.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/buildaux/mkdeps.cpp b/buildaux/mkdeps.cpp index f69cd561..cbb106be 100644 --- a/buildaux/mkdeps.cpp +++ b/buildaux/mkdeps.cpp @@ -9,9 +9,27 @@ namespace boost_fs = boost::filesystem; -std::string search_include(const std::list& searchpath, const std::string& filename, +bool is_cmdhelp_file(const std::string& filename) +{ + std::string _filename = filename; + return (_filename.length() > 8 && _filename.substr(0, 8) == "cmdhelp/"); +} + +std::string search_include(const std::list& searchpath, const std::string& _filename, const std::string& ref_by) { + std::string filename = _filename; + //Hack: process cmdhelp includes internally as the date were for the JSON include. + if(is_cmdhelp_file(filename)) { + if(filename != "cmdhelp/inverselist.hpp") { + filename = "../src/" + filename; + //Replace the extension with .json. + size_t split = filename.find_last_of("./\\"); + if(split < filename.length() && filename[split] == '.') { + filename = filename.substr(0, split) + ".json"; + } + } + } size_t p = ref_by.find_last_of("/"); if(p < ref_by.length()) { std::string i = ref_by;