more advances

This commit is contained in:
2026-09-05 12:08:12 -06:00
parent baf19016ff
commit 3dc6aff75c
4 changed files with 107 additions and 6 deletions
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <kmake/kmake.hpp>
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<string> commands;
public:
Executor();
~Executor();
public:
void run();
void next();
bool isDone();
};
}
+3 -1
View File
@@ -7,6 +7,8 @@ namespace kmake {
class Distro { class Distro {
public: public:
Project* project;
map<string, string> vars; map<string, string> vars;
vector<string> start; vector<string> start;
vector<string> deps; vector<string> deps;
@@ -22,7 +24,7 @@ namespace kmake {
public: public:
optional<string> getVar(const string& name);
}; };
+45 -4
View File
@@ -101,8 +101,9 @@ namespace kmake {
} }
} }
static Distro parse_distro(c4::yml::ConstNodeRef node, const std::string& path, std::vector<std::string>& log) { static Distro parse_distro(Project* p, c4::yml::ConstNodeRef node, const std::string& path, std::vector<std::string>& log) {
Distro d; Distro d;
d.project = p;
if (node.has_child("vars")) parse_string_map(node["vars"], d.vars, path + ".vars", log); 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("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); if (node.has_child("deps")) parse_string_list(node["deps"], d.deps, path + ".deps", log);
@@ -158,10 +159,8 @@ namespace kmake {
if (root.has_child("author") && root["author"].has_val()) { if (root.has_child("author") && root["author"].has_val()) {
string single_author; string single_author;
root["author"] >> 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")) { if (root.has_child("authors")) {
parse_string_list(root["authors"], authors, "authors", logs); parse_string_list(root["authors"], authors, "authors", logs);
} }
@@ -193,6 +192,7 @@ namespace kmake {
// Parse 'build' // Parse 'build'
if (root.has_child("build")) { if (root.has_child("build")) {
ryml::ConstNodeRef b_node = root["build"]; ryml::ConstNodeRef b_node = root["build"];
if (b_node.has_child("src")) { if (b_node.has_child("src")) {
ryml::ConstNodeRef src_node = b_node["src"]; ryml::ConstNodeRef src_node = b_node["src"];
if (src_node.has_child("path") && src_node["path"].has_val()) { 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()) { if (b_node.has_child("threads") && b_node["threads"].has_val()) {
b_node["threads"] >> build.threads; b_node["threads"] >> build.threads;
} }
@@ -220,7 +261,7 @@ namespace kmake {
for (ryml::ConstNodeRef child : d_node.children()) { for (ryml::ConstNodeRef child : d_node.children()) {
if (child.has_key()) { if (child.has_key()) {
string distro_name = to_string(child.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 { } else {
+26
View File
@@ -19,11 +19,31 @@ namespace kmake {
Verbosity verbosity; Verbosity verbosity;
struct { struct {
struct { struct {
string path; string path;
vector<string> targets; vector<string> targets;
} src; } src;
struct {
string path;
string target;
} out;
struct {
string path;
vector<string> targets;
} bin;
struct {
string path;
string target;
string rev_target;
string style;
} deps;
int threads; int threads;
} build; } build;
map<string, string> vars; map<string, string> vars;
@@ -39,6 +59,12 @@ namespace kmake {
bool load(const string& filename); bool load(const string& filename);
bool hasDistro(const string& name);
Distro& getDistro(const string& name);
optional<string> getVar(const string& name);
}; };
} }