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 <desktoplib/terminal/Terminal.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <filesystem>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
namespace kmake {
|
namespace kmake {
|
||||||
@@ -23,8 +22,6 @@ namespace kmake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void createProject() {
|
void createProject() {
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
fs::path cwd = fs::current_path();
|
fs::path cwd = fs::current_path();
|
||||||
string parent_dir = cwd.filename().string();
|
string parent_dir = cwd.filename().string();
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ckitty/memory/primitives.hpp>
|
#include <ckitty/memory/primitives.hpp>
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace kmake {
|
namespace kmake {
|
||||||
|
|
||||||
using namespace ckitty;
|
using namespace ckitty;
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
enum class Verbosity : int {
|
enum class Verbosity : int {
|
||||||
LOW = 0,
|
LOW = 0,
|
||||||
NORMAL = 1,
|
NORMAL = 1,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <kmake/project/Project.hpp>
|
#include <kmake/project/Project.hpp>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace kmake {
|
namespace kmake {
|
||||||
|
|
||||||
class Distro {
|
class Distro {
|
||||||
@@ -11,6 +13,7 @@ namespace kmake {
|
|||||||
|
|
||||||
Project* project;
|
Project* project;
|
||||||
|
|
||||||
|
string name;
|
||||||
map<string, string> vars;
|
map<string, string> vars;
|
||||||
vector<string> start;
|
vector<string> start;
|
||||||
vector<string> deps;
|
vector<string> deps;
|
||||||
@@ -18,6 +21,8 @@ namespace kmake {
|
|||||||
vector<string> link;
|
vector<string> link;
|
||||||
vector<string> end;
|
vector<string> end;
|
||||||
|
|
||||||
|
fs::path out, bin, dep;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Distro();
|
Distro();
|
||||||
@@ -26,6 +31,29 @@ namespace kmake {
|
|||||||
|
|
||||||
public:
|
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);
|
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;
|
Distro d;
|
||||||
d.project = p;
|
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("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);
|
||||||
@@ -268,7 +269,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(this, child, "distros." + distro_name, logs);
|
distros[distro_name] = parse_distro(this, distro_name, child, "distros." + distro_name, logs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user