diff --git a/src/kmake/build/Executor.hpp b/src/kmake/build/Executor.hpp new file mode 100644 index 0000000..1d62ce5 --- /dev/null +++ b/src/kmake/build/Executor.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include + +namespace kmake { + + /** + * The executor is a class that runs a list of commands in order. + * A single thread will take care of this command list. + */ + class Executor { + private: + + vector commands; + + public: + + Executor(); + + ~Executor(); + + public: + + void run(); + + void next(); + + bool isDone(); + + }; + +} \ No newline at end of file diff --git a/src/kmake/project/Distro.hpp b/src/kmake/project/Distro.hpp index 8ec3564..ecb1418 100644 --- a/src/kmake/project/Distro.hpp +++ b/src/kmake/project/Distro.hpp @@ -7,6 +7,8 @@ namespace kmake { class Distro { public: + Project* project; + map vars; vector start; vector deps; @@ -22,7 +24,7 @@ namespace kmake { public: - + optional getVar(const string& name); }; diff --git a/src/kmake/project/Project.cpp b/src/kmake/project/Project.cpp index a29fa7b..0b14ffe 100644 --- a/src/kmake/project/Project.cpp +++ b/src/kmake/project/Project.cpp @@ -101,8 +101,9 @@ namespace kmake { } } - static Distro parse_distro(c4::yml::ConstNodeRef node, const std::string& path, std::vector& log) { + static Distro parse_distro(Project* p, c4::yml::ConstNodeRef node, const std::string& path, std::vector& log) { Distro d; + d.project = p; if (node.has_child("vars")) parse_string_map(node["vars"], d.vars, path + ".vars", log); if (node.has_child("start")) parse_string_list(node["start"], d.start, path + ".start", log); if (node.has_child("deps")) parse_string_list(node["deps"], d.deps, path + ".deps", log); @@ -158,9 +159,7 @@ namespace kmake { if (root.has_child("author") && root["author"].has_val()) { string single_author; root["author"] >> single_author; - if (!single_author.empty()) { - authors.push_back(single_author); - } + authors.push_back(single_author); } if (root.has_child("authors")) { parse_string_list(root["authors"], authors, "authors", logs); @@ -193,6 +192,7 @@ namespace kmake { // Parse 'build' if (root.has_child("build")) { ryml::ConstNodeRef b_node = root["build"]; + if (b_node.has_child("src")) { ryml::ConstNodeRef src_node = b_node["src"]; if (src_node.has_child("path") && src_node["path"].has_val()) { @@ -203,6 +203,47 @@ namespace kmake { } } + if (b_node.has_child("out")) { + ryml::ConstNodeRef out_node = b_node["out"]; + if (out_node.has_child("path") && out_node["path"].has_val()) { + out_node["path"] >> build.out.path; + } + if (out_node.has_child("target") && out_node["target"].has_val()) { + out_node["target"] >> build.out.target; + } + } + + if (b_node.has_child("bin")) { + ryml::ConstNodeRef bin_node = b_node["bin"]; + if (bin_node.has_child("path") && bin_node["path"].has_val()) { + bin_node["path"] >> build.bin.path; + } + if (bin_node.has_child("target") && bin_node["target"].has_val()) { + string target; + bin_node["target"] >> target; + build.bin.targets.push_back(target); + } + if (bin_node.has_child("targets")) { + parse_string_list(bin_node["targets"], build.bin.targets, "build.bin.targets", logs); + } + } + + if (b_node.has_child("deps")) { + ryml::ConstNodeRef deps_node = b_node["deps"]; + if (deps_node.has_child("path") && deps_node["path"].has_val()) { + deps_node["path"] >> build.deps.path; + } + if (deps_node.has_child("target") && deps_node["target"].has_val()) { + deps_node["target"] >> build.deps.target; + } + if (deps_node.has_child("rev_target") && deps_node["rev_target"].has_val()) { + deps_node["rev_target"] >> build.deps.rev_target; + } + if (deps_node.has_child("style") && deps_node["style"].has_val()) { + deps_node["style"] >> build.deps.style; + } + } + if (b_node.has_child("threads") && b_node["threads"].has_val()) { b_node["threads"] >> build.threads; } @@ -220,7 +261,7 @@ namespace kmake { for (ryml::ConstNodeRef child : d_node.children()) { if (child.has_key()) { string distro_name = to_string(child.key()); - distros[distro_name] = parse_distro(child, "distros." + distro_name, logs); + distros[distro_name] = parse_distro(this, child, "distros." + distro_name, logs); } } } else { diff --git a/src/kmake/project/Project.hpp b/src/kmake/project/Project.hpp index ae994ca..bc39438 100644 --- a/src/kmake/project/Project.hpp +++ b/src/kmake/project/Project.hpp @@ -19,11 +19,31 @@ namespace kmake { Verbosity verbosity; struct { + struct { string path; vector targets; } src; + + struct { + string path; + string target; + } out; + + struct { + string path; + vector targets; + } bin; + + struct { + string path; + string target; + string rev_target; + string style; + } deps; + int threads; + } build; map vars; @@ -39,6 +59,12 @@ namespace kmake { bool load(const string& filename); + bool hasDistro(const string& name); + + Distro& getDistro(const string& name); + + optional getVar(const string& name); + }; }