From 2b7ee72e8642e25f1d0ba4bb15a8747ab4f5a02c Mon Sep 17 00:00:00 2001 From: cursey Date: Mon, 10 Jan 2022 23:27:48 -0800 Subject: [PATCH] Separate template parsing and generation * Reuse type for specifying template to use * Add support for template add-function * Add support for template pass-sources-to-add-function --- include/enum_helper.hpp | 7 +- include/project_parser.hpp | 11 +- src/cmake_generator.cpp | 133 +++++++++++++++--- src/project_parser.cpp | 233 ++++++++++++------------------- tests/driver/cmake.toml | 19 +++ tests/driver/cmake/FindWdk.cmake | 179 ++++++++++++++++++++++++ tests/driver/src/DriverEntry.cpp | 5 + tests/templates/cmake.toml | 4 +- 8 files changed, 423 insertions(+), 168 deletions(-) create mode 100644 tests/driver/cmake.toml create mode 100644 tests/driver/cmake/FindWdk.cmake create mode 100644 tests/driver/src/DriverEntry.cpp diff --git a/include/enum_helper.hpp b/include/enum_helper.hpp index 7aafd78..93d88d9 100644 --- a/include/enum_helper.hpp +++ b/include/enum_helper.hpp @@ -4,6 +4,7 @@ #include #include #include +#include // This is the type that will hold all the strings. // Each enumeration type will declare its own specialization. @@ -12,7 +13,7 @@ // be no definition of a generic version). template struct enumStrings { - static char const *data[]; + static std::vector data; }; // This is a utility type. @@ -43,8 +44,8 @@ std::istream &operator>>(std::istream &str, enumRefHolder const &data) { // These two can be made easier to read in C++11 // using std::begin() and std::end() // - static auto begin = std::begin(enumStrings::data); - static auto end = std::end(enumStrings::data); + auto begin = std::begin(enumStrings::data); + auto end = std::end(enumStrings::data); auto find = std::find(begin, end, value); if (find != end) { diff --git a/include/project_parser.hpp b/include/project_parser.hpp index 8c26b50..bd2bafa 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -56,11 +56,14 @@ enum TargetType { target_interface, target_custom, target_object, + target_template, + target_COUNT, }; struct Target { std::string name; TargetType type = {}; + std::string type_string; ConditionVector headers; ConditionVector sources; @@ -100,6 +103,12 @@ struct Target { ConditionVector include_after; }; +struct Template { + Target outline; + std::string add_function; + bool pass_sources_to_add_function = false; +}; + struct Test { std::string name; std::string condition; @@ -160,12 +169,12 @@ struct Project { std::vector packages; Vcpkg vcpkg; std::vector contents; + std::vector