diff options
Diffstat (limited to 'utils/metadata_generator.cpp')
-rw-r--r-- | utils/metadata_generator.cpp | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/utils/metadata_generator.cpp b/utils/metadata_generator.cpp index 9f5215d..57facb1 100644 --- a/utils/metadata_generator.cpp +++ b/utils/metadata_generator.cpp @@ -22,15 +22,36 @@ /// \brief a simple utility for generating metadata /// #include <iostream> +#include <set> #include <string> #include <vector> +#include <boost/spirit/include/karma.hpp> + #include "libbash.h" -static std::vector<std::string> metadata_names = {"DEPEND", "RDEPEND", "SLOT", "SRC_URI", - "RESTRICT", "HOMEPAGE", "LICENSE", "DESCRIPTION", - "KEYWORDS", "INHERITED", "IUSE", "REQUIRED_USE", - "PDEPEND", "PROVIDE", "EAPI", "PROPERTIES", "DEFINED_PHASES"}; +static const std::vector<std::string> metadata_names = {"DEPEND", "RDEPEND", "SLOT", "SRC_URI", + "RESTRICT", "HOMEPAGE", "LICENSE", "DESCRIPTION", + "KEYWORDS", "INHERITED", "IUSE", "REQUIRED_USE", + "PDEPEND", "PROVIDE", "EAPI", "PROPERTIES"}; + +static const std::unordered_map<std::string, std::string> phases = { + {"pkg_pretend", "ppretend"}, + {"pkg_setup", "setup"}, + {"src_unpack", "unpack"}, + {"src_prepare", "prepare"}, + {"src_configure", "configure"}, + {"src_compile", "compile"}, + {"src_test", "test"}, + {"src_install", "install"}, + {"pkg_preinst", "preinst"}, + {"pkg_postinst", "postinst"}, + {"pkg_prerm", "prerm"}, + {"pkg_postrm", "postrm"}, + {"pkg_config", "config"}, + {"pkg_info", "info"}, + {"pkg_nofetch", "nofetch"} +}; int main(int argc, char** argv) { @@ -41,7 +62,8 @@ int main(int argc, char** argv) } std::unordered_map<std::string, std::vector<std::string>> variables; - libbash::interpret(argv[1], variables); + std::vector<std::string> functions; + libbash::interpret(argv[1], variables, functions); for(auto iter_name = metadata_names.begin(); iter_name != metadata_names.end(); ++iter_name) { @@ -52,5 +74,20 @@ int main(int argc, char** argv) std::cout << std::endl; } + // Print defined phases + std::set<std::string> sorted_phases; + for(auto iter = functions.begin(); iter != functions.end(); ++iter) + { + auto iter_phase = phases.find(*iter); + if(iter_phase != phases.end()) + sorted_phases.insert(iter_phase->second); + } + + using namespace boost::spirit::karma; + std::cout << format(string % ' ', sorted_phases) << std::endl; + + // Print empty lines + std::cout << std::endl << std::endl << std::endl << std::endl << std::endl; + return EXIT_SUCCESS; } |