summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-02-06 18:02:10 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-02-07 00:39:13 +0000
commitfd4d6ca859ce71fb0f3d95004da3278d0b120dd1 (patch)
tree4522e2f9f6320ee6e8f5b9d25aac7b6f9ec33e23
parentunique_ptr over ScopeExit (diff)
downloadicespider-fd4d6ca859ce71fb0f3d95004da3278d0b120dd1.tar.bz2
icespider-fd4d6ca859ce71fb0f3d95004da3278d0b120dd1.tar.xz
icespider-fd4d6ca859ce71fb0f3d95004da3278d0b120dd1.zip
Fix IWYU on generated code
-rw-r--r--icespider/compile/routeCompiler.cpp46
1 files changed, 37 insertions, 9 deletions
diff --git a/icespider/compile/routeCompiler.cpp b/icespider/compile/routeCompiler.cpp
index 3a25d6e..e2ac9fa 100644
--- a/icespider/compile/routeCompiler.cpp
+++ b/icespider/compile/routeCompiler.cpp
@@ -14,6 +14,7 @@
#include <filesystem>
#include <fprintbf.h>
#include <http.h>
+#include <initializer_list>
#include <list>
#include <memory>
#include <pathparts.h>
@@ -200,9 +201,9 @@ namespace IceSpider {
throw std::runtime_error("Failed to open output files");
}
AdHoc::ScopeExit outClose(nullptr, nullptr, [&output, &outputh]() {
- std::filesystem::remove(output);
- std::filesystem::remove(outputh);
- });
+ std::filesystem::remove(output);
+ std::filesystem::remove(outputh);
+ });
processConfiguration(out.get(), outh.get(), output.stem().string(), configuration, units);
}
@@ -309,28 +310,55 @@ namespace IceSpider {
fputs("// This source files was generated by IceSpider.\n", output);
fprintbf(output, "// Configuration name: %s\n\n", c->name);
+ fputs("#pragma once\n", outputh);
fputs("// This source files was generated by IceSpider.\n", outputh);
fprintbf(outputh, "// Configuration name: %s\n\n", c->name);
fputs("// Configuration headers.\n", output);
fprintbf(output, "#include \"%s.h\"\n", name);
- fputs("// Standard headers.\n", outputh);
- fputs("#include <irouteHandler.h>\n", outputh);
- fputs("#include <core.h>\n", outputh);
- fputs("#include <slicer/serializer.h>\n", outputh);
-
+ fputs("\n// Interface headers.\n", output);
fputs("\n// Interface headers.\n", outputh);
for (const auto & s : c->slices) {
std::filesystem::path slicePath(s);
slicePath.replace_extension(".h");
+ fprintbf(output, "#include <%s>\n", slicePath.string());
fprintbf(outputh, "#include <%s>\n", slicePath.string());
}
+ fputs("\n// Standard headers.\n", outputh);
+ fputs("namespace IceSpider {\n", outputh);
+ fputs("\tclass Core; // IWYU pragma: keep\n", outputh);
+ fputs("\tclass IHttpRequest; // IWYU pragma: keep\n", outputh);
+ fputs("}\n", outputh);
+
+ fputs("// Standard headers.\n", output);
+ for (const auto header : {
+ "core.h",
+ "irouteHandler.h",
+ "Ice/Config.h",
+ "Ice/Exception.h",
+ "Ice/Proxy.h",
+ "boost/lexical_cast.hpp",
+ "future",
+ "ios",
+ "memory",
+ "string",
+ "string_view",
+ "factory.h",
+ "http.h",
+ "ihttpRequest.h",
+ "util.h",
+ }) {
+ fprintbf(output, "#include <%s>\n", header);
+ }
+
if (!c->headers.empty()) {
+ fputs("\n// Extra headers.\n", output);
fputs("\n// Extra headers.\n", outputh);
for (const auto & h : c->headers) {
- fprintbf(outputh, "#include <%s>\n", h);
+ fprintbf(output, "#include <%s> // IWYU pragma: keep\n", h);
+ fprintbf(outputh, "#include <%s> // IWYU pragma: keep\n", h);
}
}