more work
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <kmake/project/Distro.hpp>
|
||||
|
||||
namespace kmake {
|
||||
|
||||
class DistroBuilder {
|
||||
public:
|
||||
|
||||
Distro& distro;
|
||||
|
||||
/**
|
||||
* The list of sources to use.
|
||||
*/
|
||||
vector<fs::path> sources;
|
||||
|
||||
/**
|
||||
* A map of the binaries to create, for
|
||||
* each source file.
|
||||
*/
|
||||
map<fs::path, fs::path> binaries;
|
||||
|
||||
/**
|
||||
* A map of the dependencies to create, for
|
||||
* each source file.
|
||||
*/
|
||||
map<fs::path, fs::path> dependencies;
|
||||
|
||||
public:
|
||||
|
||||
DistroBuilder(Distro& d);
|
||||
|
||||
~DistroBuilder();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Obtains all sources that are newer than their
|
||||
* binary counterparts.
|
||||
*/
|
||||
void getSources();
|
||||
|
||||
/**
|
||||
* Obtains a counterpart (of the source file) to another
|
||||
* directory like out, bin or dep. The relative path is
|
||||
* the same from each origin.
|
||||
*/
|
||||
fs::path counterpart(fs::path path, fs::path counter_path);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <desktoplib/terminal/Terminal.hpp>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
namespace kmake {
|
||||
@@ -23,8 +22,6 @@ namespace kmake {
|
||||
}
|
||||
|
||||
void createProject() {
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path cwd = fs::current_path();
|
||||
string parent_dir = cwd.filename().string();
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <ckitty/memory/primitives.hpp>
|
||||
|
||||
#include <mutex>
|
||||
#include <filesystem>
|
||||
|
||||
namespace kmake {
|
||||
|
||||
using namespace ckitty;
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
enum class Verbosity : int {
|
||||
LOW = 0,
|
||||
NORMAL = 1,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <kmake/project/Project.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace kmake {
|
||||
|
||||
class Distro {
|
||||
@@ -11,6 +13,7 @@ namespace kmake {
|
||||
|
||||
Project* project;
|
||||
|
||||
string name;
|
||||
map<string, string> vars;
|
||||
vector<string> start;
|
||||
vector<string> deps;
|
||||
@@ -18,14 +21,39 @@ namespace kmake {
|
||||
vector<string> link;
|
||||
vector<string> end;
|
||||
|
||||
fs::path out, bin, dep;
|
||||
|
||||
public:
|
||||
|
||||
Distro();
|
||||
|
||||
~Distro();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Will create the directories for the distro.
|
||||
* A distro_name/ folder will be added to
|
||||
* Out, Bin and Dep directories.
|
||||
*
|
||||
* After this method, out, bin and dep
|
||||
* variables will be set.
|
||||
*/
|
||||
void ensureDirs();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns a populated vector of strings.
|
||||
*/
|
||||
vector<string> populate(const vector<string>& v);
|
||||
|
||||
/**
|
||||
* This method will populate the placeholders with the distro
|
||||
* variables. Variables not found will not get replaced.
|
||||
*/
|
||||
string populate(const string& str);
|
||||
|
||||
optional<string> getVar(const string& name);
|
||||
|
||||
};
|
||||
|
||||
@@ -101,9 +101,10 @@ namespace kmake {
|
||||
}
|
||||
}
|
||||
|
||||
static Distro parse_distro(Project* p, c4::yml::ConstNodeRef node, const std::string& path, std::vector<std::string>& log) {
|
||||
static Distro parse_distro(Project* p, const std::string& name, c4::yml::ConstNodeRef node, const std::string& path, std::vector<std::string>& log) {
|
||||
Distro d;
|
||||
d.project = p;
|
||||
d.name = name;
|
||||
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);
|
||||
@@ -268,7 +269,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(this, child, "distros." + distro_name, logs);
|
||||
distros[distro_name] = parse_distro(this, distro_name, child, "distros." + distro_name, logs);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user