This commit is contained in:
2026-09-07 21:00:27 -06:00
parent 4366c5b028
commit 3331ca2cec
6 changed files with 122 additions and 32 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ CFLAGS := -std=c++20 -O2 \
-Wunused -Woverloaded-virtual -Wconversion \ -Wunused -Woverloaded-virtual -Wconversion \
-Wsign-conversion -Wnull-dereference -Wdouble-promotion \ -Wsign-conversion -Wnull-dereference -Wdouble-promotion \
-Wformat=2 -Wimplicit-fallthrough -Wsuggest-override \ -Wformat=2 -Wimplicit-fallthrough -Wsuggest-override \
-Wextra-semi -Wduplicated-cond -Wduplicated-branches \ -Wduplicated-cond -Wduplicated-branches \
-Wlogical-op -Wuseless-cast -Wno-unused-parameter -Wlogical-op -Wuseless-cast -Wno-unused-parameter
LFLAGS := -std=c++20 -static-libstdc++ -static-libgcc \ LFLAGS := -std=c++20 -static-libstdc++ -static-libgcc \
-Wl,--fatal-warnings -Wl,--warn-common -Wl,--fatal-warnings -Wl,--warn-common
+75 -3
View File
@@ -1,8 +1,80 @@
#include "kmake.hpp" #include "kmake.hpp"
#include <iostream> #include <desktoplib/terminal/Terminal.hpp>
#include <cstdlib>
#include <sstream>
int main() { namespace kmake {
std::cout << "hello" << std::endl;
using namespace ckitty::terminal;
Terminal kmake_terminal;
Verbosity kmake_verbosity = Verbosity::NORMAL;
std::mutex kmake_mutex;
void log(const string& msg, Verbosity level) {
if (static_cast<int>(kmake_verbosity) < static_cast<int>(level)) return;
std::lock_guard<std::mutex> lock(kmake_mutex);
kmake_terminal << msg << style::RESET << '\n';
}
void parseArgs(int argc, char* argv[]) {
for (int i = 1; i < argc; ++i) {
string arg = argv[i];
if (arg == "-version" || arg == "--version") {
args.show_version = true;
} else if (arg == "-list" || arg == "--list") {
args.list_distros = true;
} else if (arg == "-descr" || arg == "--descr") {
args.show_description = true;
} else if (arg == "-verbosity" || arg == "--verbosity") {
if (i + 1 >= argc) {
log("Missing value for " + arg, Verbosity::LOW);
return;
}
string val = argv[++i];
if (val == "low") args.verbosity = Verbosity::LOW;
else if (val == "normal") args.verbosity = Verbosity::NORMAL;
else if (val == "high") args.verbosity = Verbosity::HIGH;
else if (val == "debug") args.verbosity = Verbosity::DEBUG;
else {
log("Invalid verbosity: " + val, Verbosity::LOW);
return;
}
} else if (arg[0] == '-') {
log("Unknown option: " + arg, Verbosity::LOW);
return;
} else {
args.distros.push_back(arg);
}
}
kmake_verbosity = args.verbosity;
return;
}
int run() {
if (args.show_version) {
log("kmake version 1.0.0", Verbosity::NORMAL);
return 0; return 0;
} }
if (args.distros.size() == 0) {
log("No distros specified", Verbosity::NORMAL);
return 0;
}
return 0;
}
} // namespace kmake
int main(int argc, char* argv[]) {
using namespace kmake;
kmake_terminal = Terminal(); // re-initialize
parseArgs(argc, argv);
return run();
}
+24 -7
View File
@@ -1,15 +1,32 @@
#pragma once #pragma once
#include <ckitty/memory/primitives.hpp> #include <ckitty/memory/primitives.hpp>
#include <mutex>
#include <desktoplib/terminal/Terminal.hpp>
#include <desktoplib/terminal/ui/Box.hpp>
#include <desktoplib/terminal/ui/MenuMap.hpp>
#include <desktoplib/terminal/ui/Content.hpp>
#include <desktoplib/terminal/ui/InnerScroll.hpp>
namespace kmake { namespace kmake {
using namespace ckitty; using namespace ckitty;
} enum class Verbosity : int {
LOW = 0,
NORMAL = 1,
HIGH = 2,
DEBUG = 3
};
struct {
vector<string> distros;
Verbosity verbosity = Verbosity::NORMAL;
bool show_version = false;
bool list_distros = false;
bool show_description = false;
string config_file = "kmake.yml";
} args;
void parseArgs(int argc, char* argv[]);
void log(const string& msg, Verbosity level = Verbosity::NORMAL);
int run();
} // namespace kmake
+2
View File
@@ -2,6 +2,8 @@
#include <kmake/kmake.hpp> #include <kmake/kmake.hpp>
#include <kmake/project/Project.hpp>
namespace kmake { namespace kmake {
class Distro { class Distro {
+18 -15
View File
@@ -53,7 +53,7 @@ namespace kmake {
} }
string val; string val;
child >> val; child.load(val);
if (val.empty()) { if (val.empty()) {
log.push_back("[WARN] Empty string element ignored at '" + item_path + "'"); log.push_back("[WARN] Empty string element ignored at '" + item_path + "'");
@@ -91,7 +91,7 @@ namespace kmake {
} }
string v; string v;
child >> v; child.load(v);
if (v.empty()) { if (v.empty()) {
log.push_back("[WARN] Value for key '" + key_path + "' is empty."); log.push_back("[WARN] Value for key '" + key_path + "' is empty.");
@@ -150,7 +150,7 @@ namespace kmake {
// Parse 'name' // Parse 'name'
if (root.has_child("name") && root["name"].has_val()) { if (root.has_child("name") && root["name"].has_val()) {
root["name"] >> name; root["name"].load(name);
} else { } else {
logs.push_back("[WARN] Key 'name' is missing or empty."); logs.push_back("[WARN] Key 'name' is missing or empty.");
} }
@@ -158,7 +158,7 @@ namespace kmake {
// Parse combined 'author' and 'authors' // Parse combined 'author' and 'authors'
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"].load(single_author);
authors.push_back(single_author); authors.push_back(single_author);
} }
if (root.has_child("authors")) { if (root.has_child("authors")) {
@@ -173,7 +173,7 @@ namespace kmake {
// Parse 'verbosity' // Parse 'verbosity'
if (root.has_child("verbosity") && root["verbosity"].has_val()) { if (root.has_child("verbosity") && root["verbosity"].has_val()) {
string v_str; string v_str;
root["verbosity"] >> v_str; root["verbosity"].load(v_str);
v_str = strings::to_lower(v_str); v_str = strings::to_lower(v_str);
if (v_str == "debug") { if (v_str == "debug") {
verbosity = Verbosity::DEBUG; verbosity = Verbosity::DEBUG;
@@ -196,7 +196,7 @@ namespace kmake {
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()) {
src_node["path"] >> build.src.path; src_node["path"].load(build.src.path);
} }
if (src_node.has_child("targets")) { if (src_node.has_child("targets")) {
parse_string_list(src_node["targets"], build.src.targets, "build.src.targets", logs); parse_string_list(src_node["targets"], build.src.targets, "build.src.targets", logs);
@@ -206,21 +206,21 @@ namespace kmake {
if (b_node.has_child("out")) { if (b_node.has_child("out")) {
ryml::ConstNodeRef out_node = b_node["out"]; ryml::ConstNodeRef out_node = b_node["out"];
if (out_node.has_child("path") && out_node["path"].has_val()) { if (out_node.has_child("path") && out_node["path"].has_val()) {
out_node["path"] >> build.out.path; out_node["path"].load(build.out.path);
} }
if (out_node.has_child("target") && out_node["target"].has_val()) { if (out_node.has_child("target") && out_node["target"].has_val()) {
out_node["target"] >> build.out.target; out_node["target"].load(build.out.target);
} }
} }
if (b_node.has_child("bin")) { if (b_node.has_child("bin")) {
ryml::ConstNodeRef bin_node = b_node["bin"]; ryml::ConstNodeRef bin_node = b_node["bin"];
if (bin_node.has_child("path") && bin_node["path"].has_val()) { if (bin_node.has_child("path") && bin_node["path"].has_val()) {
bin_node["path"] >> build.bin.path; bin_node["path"].load(build.bin.path);
} }
if (bin_node.has_child("target") && bin_node["target"].has_val()) { if (bin_node.has_child("target") && bin_node["target"].has_val()) {
string target; string target;
bin_node["target"] >> target; bin_node["target"].load(target);
build.bin.targets.push_back(target); build.bin.targets.push_back(target);
} }
if (bin_node.has_child("targets")) { if (bin_node.has_child("targets")) {
@@ -231,21 +231,21 @@ namespace kmake {
if (b_node.has_child("deps")) { if (b_node.has_child("deps")) {
ryml::ConstNodeRef deps_node = b_node["deps"]; ryml::ConstNodeRef deps_node = b_node["deps"];
if (deps_node.has_child("path") && deps_node["path"].has_val()) { if (deps_node.has_child("path") && deps_node["path"].has_val()) {
deps_node["path"] >> build.deps.path; deps_node["path"].load(build.deps.path);
} }
if (deps_node.has_child("target") && deps_node["target"].has_val()) { if (deps_node.has_child("target") && deps_node["target"].has_val()) {
deps_node["target"] >> build.deps.target; deps_node["target"].load(build.deps.target);
} }
if (deps_node.has_child("rev_target") && deps_node["rev_target"].has_val()) { if (deps_node.has_child("rev_target") && deps_node["rev_target"].has_val()) {
deps_node["rev_target"] >> build.deps.rev_target; deps_node["rev_target"].load(build.deps.rev_target);
} }
if (deps_node.has_child("style") && deps_node["style"].has_val()) { if (deps_node.has_child("style") && deps_node["style"].has_val()) {
deps_node["style"] >> build.deps.style; deps_node["style"].load(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"].load(build.threads);
} }
} }
@@ -268,6 +268,9 @@ namespace kmake {
logs.push_back("[WARN] Key 'distros' must be a map of distro configs."); logs.push_back("[WARN] Key 'distros' must be a map of distro configs.");
} }
} }
// good!
return true;
} }
} }
-4
View File
@@ -6,10 +6,6 @@ namespace kmake {
class Distro; class Distro;
enum class Verbosity : int {
DEBUG = 3, HIGH = 2, NORMAL = 1, LOW = 0
};
class Project { class Project {
public: public: