feat: adopt VoidLibrary VL-001..VL-013, self-building build.cpp, live logs, and generated CLI help
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 10s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 10s
This commit is contained in:
1 parent
ab64147f9d
commit
363fb8200e
33 files changed
+1754
-3155
No files matched your search
+2
-93
@@ -1,7 +1,6 @@
|
||||
#include <Void/Build/Package/Solver.hpp>
|
||||
|
||||
#include <Void/System/Types.hpp>
|
||||
#include <Void/Text/Str.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
@@ -16,99 +15,9 @@ Void::Result::Error solve_err(std::string msg) {
|
||||
std::move(msg));
|
||||
}
|
||||
|
||||
bool all_digits(std::string_view s) { return Void::Str::is_digit_ascii(s); }
|
||||
|
||||
std::string normalize_semver_token(std::string_view tok) {
|
||||
if (tok.empty() || tok == "*") {
|
||||
return std::string{tok};
|
||||
}
|
||||
std::string_view op;
|
||||
if (tok.starts_with(">=") || tok.starts_with("<=")) {
|
||||
op = tok.substr(0, 2);
|
||||
tok.remove_prefix(2);
|
||||
} else if (tok.starts_with('^') || tok.starts_with('~') || tok.starts_with('>') ||
|
||||
tok.starts_with('<') || tok.starts_with('=')) {
|
||||
op = tok.substr(0, 1);
|
||||
tok.remove_prefix(1);
|
||||
}
|
||||
|
||||
const auto meta_pos = tok.find_first_of("-+");
|
||||
const auto core = meta_pos == std::string_view::npos ? tok : tok.substr(0, meta_pos);
|
||||
const auto meta =
|
||||
meta_pos == std::string_view::npos ? std::string_view{} : tok.substr(meta_pos);
|
||||
|
||||
if (core.find_first_of("xX*") != std::string_view::npos) {
|
||||
return std::string{op} + std::string{tok};
|
||||
}
|
||||
|
||||
const auto dot1 = core.find('.');
|
||||
if (dot1 == std::string_view::npos) {
|
||||
if (!all_digits(core)) {
|
||||
return std::string{op} + std::string{tok};
|
||||
}
|
||||
if ((op == "~" || op == "^") && meta.empty()) {
|
||||
const unsigned long maj = std::stoul(std::string{core});
|
||||
if (op == "~" || maj == 0) {
|
||||
return std::format(">={}.0.0 <{}.0.0", maj, maj + 1);
|
||||
}
|
||||
}
|
||||
return std::string{op} + std::string{core} + ".0.0" + std::string{meta};
|
||||
}
|
||||
const auto dot2 = core.find('.', dot1 + 1);
|
||||
if (dot2 == std::string_view::npos) {
|
||||
const auto p1 = core.substr(0, dot1);
|
||||
const auto p2 = core.substr(dot1 + 1);
|
||||
if (!all_digits(p1) || !all_digits(p2)) {
|
||||
return std::string{op} + std::string{tok};
|
||||
}
|
||||
return std::string{op} + std::string{p1} + "." + std::string{p2} + ".0" + std::string{meta};
|
||||
}
|
||||
return std::string{op} + std::string{tok};
|
||||
}
|
||||
|
||||
// Adapter for shorthand SemVer comparator tokens (^1, ^1.0, ~1.2, <2) since
|
||||
// pinned Void::Semver::parse_range requires full major.minor.patch triplets.
|
||||
// Delegates directly to Void::Semver::parse_range (VL-013 shorthand comparators now upstream).
|
||||
std::optional<Void::Semver::VersionRange> parse_semver_range_compat(std::string_view expr) {
|
||||
if (auto direct = Void::Semver::parse_range(expr); direct) {
|
||||
return direct;
|
||||
}
|
||||
std::string normalized;
|
||||
std::size_t pos = 0;
|
||||
bool first_clause = true;
|
||||
while (pos <= expr.size()) {
|
||||
const auto sep = expr.find("||", pos);
|
||||
const auto clause = expr.substr(pos, sep == std::string_view::npos ? sep : sep - pos);
|
||||
if (!first_clause) {
|
||||
normalized += " || ";
|
||||
}
|
||||
first_clause = false;
|
||||
|
||||
bool first_tok = true;
|
||||
std::size_t i = 0;
|
||||
while (i < clause.size()) {
|
||||
while (i < clause.size() && (clause[i] == ' ' || clause[i] == '\t')) {
|
||||
++i;
|
||||
}
|
||||
if (i == clause.size()) {
|
||||
break;
|
||||
}
|
||||
auto end = clause.find_first_of(" \t", i);
|
||||
if (end == std::string_view::npos) {
|
||||
end = clause.size();
|
||||
}
|
||||
if (!first_tok) {
|
||||
normalized.push_back(' ');
|
||||
}
|
||||
first_tok = false;
|
||||
normalized += normalize_semver_token(clause.substr(i, end - i));
|
||||
i = end;
|
||||
}
|
||||
if (sep == std::string_view::npos) {
|
||||
break;
|
||||
}
|
||||
pos = sep + 2;
|
||||
}
|
||||
return Void::Semver::parse_range(normalized);
|
||||
return Void::Semver::parse_range(expr);
|
||||
}
|
||||
|
||||
struct ActiveConstraint {
|
||||
|
||||
Reference in new issue
Block a user