compiles!
This commit is contained in:
@@ -79,29 +79,9 @@ Custom variables from `vars` and `distros.*.vars` are also available.
|
|||||||
## Building and Testing
|
## Building and Testing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Configure
|
# On Windows, development is done on MSYS2 UCRT64.
|
||||||
cmake -B build -S .
|
# Please use the dedicated script to forward commands there.
|
||||||
|
./msys2.ps1 make
|
||||||
# Build
|
|
||||||
cmake --build build -j4
|
|
||||||
|
|
||||||
# Run
|
|
||||||
./build/kmake [options]
|
|
||||||
|
|
||||||
# Run with specific distro(s)
|
|
||||||
./build/kmake linux-gcc windows-msvc
|
|
||||||
|
|
||||||
# Set verbosity (debug, high, normal, low)
|
|
||||||
./build/kmake -verbosity normal
|
|
||||||
|
|
||||||
# Show version
|
|
||||||
./build/kmake -version
|
|
||||||
|
|
||||||
# List available distros
|
|
||||||
./build/kmake -list
|
|
||||||
|
|
||||||
# Print project description and authors
|
|
||||||
./build/kmake -descr
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Common Tasks
|
## Common Tasks
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ CFLAGS := -std=c++20 -O2 \
|
|||||||
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
|
||||||
LIBDIRS := $(EXT_LIBDIRS)
|
LIBDIRS := $(EXT_LIBDIRS)
|
||||||
LIB := $(EXT_LIB)
|
LIB := -lryml -ldesktoplib $(EXT_LIB)
|
||||||
INC := -I./src/ $(EXT_INC)
|
INC := -I./src/ $(EXT_INC)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# msys2-ucrt.ps1
|
||||||
|
$msysShell = "C:\msys64\msys2_shell.cmd"
|
||||||
|
|
||||||
|
if ($args.Count -gt 0) {
|
||||||
|
# Combine arguments into a single string for bash execution
|
||||||
|
$bashCommand = $args -join ' '
|
||||||
|
& $msysShell -defterm -here -no-start -ucrt64 -c $bashCommand
|
||||||
|
} else {
|
||||||
|
# Open interactive UCRT64 shell
|
||||||
|
& $msysShell -defterm -here -no-start -ucrt64
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace kmake {
|
|||||||
|
|
||||||
// Extracts a string list and logs unexpected nodes/types
|
// Extracts a string list and logs unexpected nodes/types
|
||||||
static void parse_string_list(ryml::ConstNodeRef node, vector<string>& dest, const string& path, vector<string>& log) {
|
static void parse_string_list(ryml::ConstNodeRef node, vector<string>& dest, const string& path, vector<string>& log) {
|
||||||
if (!node.valid()) {
|
if (!node.readable()) {
|
||||||
log.push_back("[WARN] Section missing at path: '" + path + "'");
|
log.push_back("[WARN] Section missing at path: '" + path + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ namespace kmake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string val;
|
string val;
|
||||||
child.load(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 + "'");
|
||||||
@@ -65,7 +65,7 @@ namespace kmake {
|
|||||||
|
|
||||||
// Extracts a key-value string map and logs unexpected entries/types
|
// Extracts a key-value string map and logs unexpected entries/types
|
||||||
static void parse_string_map(ryml::ConstNodeRef node, map<string, string>& dest, const string& path, vector<string>& log) {
|
static void parse_string_map(ryml::ConstNodeRef node, map<string, string>& dest, const string& path, vector<string>& log) {
|
||||||
if (!node.valid()) {
|
if (!node.readable()) {
|
||||||
log.push_back("[WARN] Section missing at path: '" + path + "'");
|
log.push_back("[WARN] Section missing at path: '" + path + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ namespace kmake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string v;
|
string v;
|
||||||
child.load(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.");
|
||||||
@@ -133,7 +133,12 @@ namespace kmake {
|
|||||||
std::streamsize size = file.tellg();
|
std::streamsize size = file.tellg();
|
||||||
file.seekg(0, std::ios::beg);
|
file.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
vector<char> buffer(size);
|
if (size < 0) {
|
||||||
|
logs.push_back("Invalid file size: " + filename);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<char> buffer(static_cast<size_t>(size));
|
||||||
if (!file.read(buffer.data(), size)) {
|
if (!file.read(buffer.data(), size)) {
|
||||||
logs.push_back("Failed to read file content: " + filename);
|
logs.push_back("Failed to read file content: " + filename);
|
||||||
return false;
|
return false;
|
||||||
@@ -145,12 +150,12 @@ namespace kmake {
|
|||||||
|
|
||||||
if (!root.is_map()) {
|
if (!root.is_map()) {
|
||||||
logs.push_back("[ERROR] Root YAML document must be a map.");
|
logs.push_back("[ERROR] Root YAML document must be a map.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse 'name'
|
// Parse 'name'
|
||||||
if (root.has_child("name") && root["name"].has_val()) {
|
if (root.has_child("name") && root["name"].has_val()) {
|
||||||
root["name"].load(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 +163,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"].load(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 +178,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"].load(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 +201,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"].load(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 +211,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"].load(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"].load(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"].load(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"].load(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 +236,23 @@ 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"].load(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"].load(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"].load(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"].load(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"].load(build.threads);
|
string threads_str;
|
||||||
|
b_node["threads"].load(&threads_str);
|
||||||
|
build.threads = std::stoi(threads_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user