From 3528fd003f41531915b3b424a221ae6c3c26fb52 Mon Sep 17 00:00:00 2001 From: Kittycannon Date: Mon, 7 Sep 2026 21:15:36 -0600 Subject: [PATCH] compiles! --- AGENTS.md | 26 +++----------------- makefile | 16 ++++++------- msys2.ps1 | 11 +++++++++ src/kmake/project/Project.cpp | 45 ++++++++++++++++++++--------------- 4 files changed, 48 insertions(+), 50 deletions(-) create mode 100644 msys2.ps1 diff --git a/AGENTS.md b/AGENTS.md index 5207126..e75adbf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -79,29 +79,9 @@ Custom variables from `vars` and `distros.*.vars` are also available. ## Building and Testing ```bash -# Configure -cmake -B build -S . - -# 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 +# On Windows, development is done on MSYS2 UCRT64. +# Please use the dedicated script to forward commands there. +./msys2.ps1 make ``` ## Common Tasks diff --git a/makefile b/makefile index 2815159..767852c 100644 --- a/makefile +++ b/makefile @@ -19,17 +19,17 @@ OBJEXT := o #Flags, Libraries and Includes ROOT := ./ CFLAGS := -std=c++20 -O2 \ - -Wall -Werror -Wextra \ - -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align \ - -Wunused -Woverloaded-virtual -Wconversion \ - -Wsign-conversion -Wnull-dereference -Wdouble-promotion \ - -Wformat=2 -Wimplicit-fallthrough -Wsuggest-override \ - -Wduplicated-cond -Wduplicated-branches \ - -Wlogical-op -Wuseless-cast -Wno-unused-parameter + -Wall -Werror -Wextra \ + -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align \ + -Wunused -Woverloaded-virtual -Wconversion \ + -Wsign-conversion -Wnull-dereference -Wdouble-promotion \ + -Wformat=2 -Wimplicit-fallthrough -Wsuggest-override \ + -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 LIBDIRS := $(EXT_LIBDIRS) -LIB := $(EXT_LIB) +LIB := -lryml -ldesktoplib $(EXT_LIB) INC := -I./src/ $(EXT_INC) #--------------------------------------------------------------------------------- diff --git a/msys2.ps1 b/msys2.ps1 new file mode 100644 index 0000000..1918e51 --- /dev/null +++ b/msys2.ps1 @@ -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 +} diff --git a/src/kmake/project/Project.cpp b/src/kmake/project/Project.cpp index 6c74ece..b674776 100644 --- a/src/kmake/project/Project.cpp +++ b/src/kmake/project/Project.cpp @@ -32,7 +32,7 @@ namespace kmake { // Extracts a string list and logs unexpected nodes/types static void parse_string_list(ryml::ConstNodeRef node, vector& dest, const string& path, vector& log) { - if (!node.valid()) { + if (!node.readable()) { log.push_back("[WARN] Section missing at path: '" + path + "'"); return; } @@ -53,7 +53,7 @@ namespace kmake { } string val; - child.load(val); + child.load(&val); if (val.empty()) { 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 static void parse_string_map(ryml::ConstNodeRef node, map& dest, const string& path, vector& log) { - if (!node.valid()) { + if (!node.readable()) { log.push_back("[WARN] Section missing at path: '" + path + "'"); return; } @@ -91,7 +91,7 @@ namespace kmake { } string v; - child.load(v); + child.load(&v); if (v.empty()) { log.push_back("[WARN] Value for key '" + key_path + "' is empty."); @@ -133,7 +133,12 @@ namespace kmake { std::streamsize size = file.tellg(); file.seekg(0, std::ios::beg); - vector buffer(size); + if (size < 0) { + logs.push_back("Invalid file size: " + filename); + return false; + } + + vector buffer(static_cast(size)); if (!file.read(buffer.data(), size)) { logs.push_back("Failed to read file content: " + filename); return false; @@ -145,12 +150,12 @@ namespace kmake { if (!root.is_map()) { logs.push_back("[ERROR] Root YAML document must be a map."); - return; + return false; } // Parse 'name' if (root.has_child("name") && root["name"].has_val()) { - root["name"].load(name); + root["name"].load(&name); } else { logs.push_back("[WARN] Key 'name' is missing or empty."); } @@ -158,7 +163,7 @@ namespace kmake { // Parse combined 'author' and 'authors' if (root.has_child("author") && root["author"].has_val()) { string single_author; - root["author"].load(single_author); + root["author"].load(&single_author); authors.push_back(single_author); } if (root.has_child("authors")) { @@ -173,7 +178,7 @@ namespace kmake { // Parse 'verbosity' if (root.has_child("verbosity") && root["verbosity"].has_val()) { string v_str; - root["verbosity"].load(v_str); + root["verbosity"].load(&v_str); v_str = strings::to_lower(v_str); if (v_str == "debug") { verbosity = Verbosity::DEBUG; @@ -196,7 +201,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"].load(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 +211,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"].load(build.out.path); + out_node["path"].load(&build.out.path); } 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")) { ryml::ConstNodeRef bin_node = b_node["bin"]; 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()) { string target; - bin_node["target"].load(target); + bin_node["target"].load(&target); build.bin.targets.push_back(target); } if (bin_node.has_child("targets")) { @@ -231,21 +236,23 @@ 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"].load(build.deps.path); + deps_node["path"].load(&build.deps.path); } 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()) { - 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()) { - 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()) { - b_node["threads"].load(build.threads); + string threads_str; + b_node["threads"].load(&threads_str); + build.threads = std::stoi(threads_str); } }