From 6669794434cb9f472aafce126162b9b81389df5f Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 3 May 2024 12:24:13 +0200 Subject: Rename to ymake --- ymake.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 ymake.cpp (limited to 'ymake.cpp') diff --git a/ymake.cpp b/ymake.cpp new file mode 100644 index 0000000..93a813e --- /dev/null +++ b/ymake.cpp @@ -0,0 +1,83 @@ +#include "ymake.h" + +#include "builder.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +namespace fs = std::filesystem; +namespace bp = boost::process; +namespace pt = boost::property_tree; +using namespace std::string_literals; + +namespace { + const fs::path YMakefile{"YMakefile"}; + + void usage() + { + std::cout << "Usage: ymake " << std::endl; + } + +} + +int ymake(int argc, char* argv[]) +{ + try { + pt::ptree ptree; + pt::read_xml(YMakefile, ptree, pt::xml_parser::no_comments | pt::xml_parser::trim_whitespace); + + std::string action{"default"}; + + if (argc == 1) { // default action + } else if (argc == 2) { + action = argv[1]; + } else { + std::cerr << "Invalid arguments." << std::endl; + usage; + exit(1); + } + + Builder builder(ptree); + if (action == "default"s || action == "build") { // build + builder.build(); + } else if (action == "clean") { + builder.clean(); + } else if (action == "install") { + throw std::runtime_error("unimplemented"); + } else if (action == "rebuild") { + throw std::runtime_error("unimplemented"); + } else if (action == "run") { + throw std::runtime_error("unimplemented"); + } else { + std::cerr << "Invalid action: " << action << std::endl; + usage; + exit(1); + } + + } catch (const std::exception& ex) { + std::cerr << "ymake: " << ex.what() << std::endl; + return 1; + } + + return 0; +} + -- cgit v1.2.3