hold on
This commit is contained in:
@@ -24,7 +24,7 @@ CFLAGS := -std=c++20 -O2 \
|
||||
-Wunused -Woverloaded-virtual -Wconversion \
|
||||
-Wsign-conversion -Wnull-dereference -Wdouble-promotion \
|
||||
-Wformat=2 -Wimplicit-fallthrough -Wsuggest-override \
|
||||
-Wextra-semi -Wduplicated-cond -Wduplicated-branches \
|
||||
-Wduplicated-cond -Wduplicated-branches \
|
||||
-Wlogical-op -Wuseless-cast -Wno-unused-parameter
|
||||
LFLAGS := -std=c++20 -static-libstdc++ -static-libgcc \
|
||||
-Wl,--fatal-warnings -Wl,--warn-common
|
||||
|
||||
+76
-4
@@ -1,8 +1,80 @@
|
||||
#include "kmake.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <desktoplib/terminal/Terminal.hpp>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
int main() {
|
||||
std::cout << "hello" << std::endl;
|
||||
return 0;
|
||||
namespace kmake {
|
||||
|
||||
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;
|
||||
}
|
||||
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
@@ -1,15 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <ckitty/memory/primitives.hpp>
|
||||
|
||||
#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>
|
||||
#include <mutex>
|
||||
|
||||
namespace kmake {
|
||||
|
||||
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,6 +2,8 @@
|
||||
|
||||
#include <kmake/kmake.hpp>
|
||||
|
||||
#include <kmake/project/Project.hpp>
|
||||
|
||||
namespace kmake {
|
||||
|
||||
class Distro {
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace kmake {
|
||||
}
|
||||
|
||||
string val;
|
||||
child >> val;
|
||||
child.load(val);
|
||||
|
||||
if (val.empty()) {
|
||||
log.push_back("[WARN] Empty string element ignored at '" + item_path + "'");
|
||||
@@ -91,7 +91,7 @@ namespace kmake {
|
||||
}
|
||||
|
||||
string v;
|
||||
child >> v;
|
||||
child.load(v);
|
||||
|
||||
if (v.empty()) {
|
||||
log.push_back("[WARN] Value for key '" + key_path + "' is empty.");
|
||||
@@ -150,7 +150,7 @@ namespace kmake {
|
||||
|
||||
// Parse 'name'
|
||||
if (root.has_child("name") && root["name"].has_val()) {
|
||||
root["name"] >> name;
|
||||
root["name"].load(name);
|
||||
} else {
|
||||
logs.push_back("[WARN] Key 'name' is missing or empty.");
|
||||
}
|
||||
@@ -158,7 +158,7 @@ namespace kmake {
|
||||
// Parse combined 'author' and 'authors'
|
||||
if (root.has_child("author") && root["author"].has_val()) {
|
||||
string single_author;
|
||||
root["author"] >> single_author;
|
||||
root["author"].load(single_author);
|
||||
authors.push_back(single_author);
|
||||
}
|
||||
if (root.has_child("authors")) {
|
||||
@@ -173,7 +173,7 @@ namespace kmake {
|
||||
// Parse 'verbosity'
|
||||
if (root.has_child("verbosity") && root["verbosity"].has_val()) {
|
||||
string v_str;
|
||||
root["verbosity"] >> v_str;
|
||||
root["verbosity"].load(v_str);
|
||||
v_str = strings::to_lower(v_str);
|
||||
if (v_str == "debug") {
|
||||
verbosity = Verbosity::DEBUG;
|
||||
@@ -196,7 +196,7 @@ namespace kmake {
|
||||
if (b_node.has_child("src")) {
|
||||
ryml::ConstNodeRef src_node = b_node["src"];
|
||||
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")) {
|
||||
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")) {
|
||||
ryml::ConstNodeRef out_node = b_node["out"];
|
||||
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()) {
|
||||
out_node["target"] >> build.out.target;
|
||||
out_node["target"].load(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;
|
||||
bin_node["path"].load(build.bin.path);
|
||||
}
|
||||
if (bin_node.has_child("target") && bin_node["target"].has_val()) {
|
||||
string target;
|
||||
bin_node["target"] >> target;
|
||||
bin_node["target"].load(target);
|
||||
build.bin.targets.push_back(target);
|
||||
}
|
||||
if (bin_node.has_child("targets")) {
|
||||
@@ -231,21 +231,21 @@ namespace kmake {
|
||||
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;
|
||||
deps_node["path"].load(build.deps.path);
|
||||
}
|
||||
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()) {
|
||||
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()) {
|
||||
deps_node["style"] >> build.deps.style;
|
||||
deps_node["style"].load(build.deps.style);
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
// good!
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ namespace kmake {
|
||||
|
||||
class Distro;
|
||||
|
||||
enum class Verbosity : int {
|
||||
DEBUG = 3, HIGH = 2, NORMAL = 1, LOW = 0
|
||||
};
|
||||
|
||||
class Project {
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user