feat(platform): build on native Windows hosts
VoidBuildSystem CI / 1 · Requirements (push) Successful in 6s
VoidBuildSystem CI / 2C · Windows native build (debug) (push) Failing after 1m32s
VoidBuildSystem CI / 2C · Windows native build (sanitizers) (push) Failing after 18s
VoidBuildSystem CI / 2C · Windows native build (relwithdebinfo) (push) Failing after 3m4s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 6m20s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 6m32s
VoidBuildSystem CI / 3C · Windows native test (debug) (push) Failing after 1m45s
VoidBuildSystem CI / 2B · Windows Wine build (sanitizers) (push) Successful in 6m55s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 6m59s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 6m59s
VoidBuildSystem CI / 3C · Windows native test (sanitizers) (push) Failing after 15s
VoidBuildSystem CI / 3C · Windows native test (relwithdebinfo) (push) Failing after 1m47s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 2m4s
VoidBuildSystem CI / 4B · Windows package (debug) (push) Successful in 1m6s
VoidBuildSystem CI / 4B · Windows package (sanitizers) (push) Successful in 12s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m2s
VoidBuildSystem CI / 4B · Windows package (relwithdebinfo) (push) Successful in 1m44s
VoidBuildSystem CI / 3B · Windows Wine test (sanitizers) (push) Successful in 3m16s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 3m21s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 6m45s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 6m54s
VoidBuildSystem CI / 4A · Linux package (debug) (push) Skipped
VoidBuildSystem CI / 4A · Linux package (relwithdebinfo) (push) Skipped
VoidBuildSystem CI / 4A · Linux package (sanitizers) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 3m42s

Bump VoidLibrary to 482a3ea (Windows target support: qualified
Configuration/Crypto/System/Archive, Windows DirectoryWatcher,
TempDir/TempFile, process pipes) and port VBS's own host backends:

- Toolchain: Windows/macOS host names and architectures without uname.
- Platform FileOps: Win32 stat metadata, CreateFileW+LockFileEx file
  locks (Void FileLock is POSIX-only, Void/Library#66), no-op
  directory fsync, GetModuleFileNameW executable path, mtime via
  std::filesystem, and a file-copy fallback for the compdb alias.
- ProcessSupervisor: Windows PATH/PATHEXT resolution and no POSIX
  waitpid reaping (job objects own descendants).
- Snapshot: directory listing through std::filesystem on Windows.
- Remote cache/registry client/CDash: curl or Winsock-based HTTP on
  Windows (Void::Net is not qualified there yet).
- Daemon: explicit unsupported errors on Windows (named-pipe
  transport is Track C3); the registry service stays POSIX-only and
  is excluded from the Windows build.
- StateStore/Sbom/Main/Graph: portable stat, time and path handling.

Verified: MinGW-w64 GCC 16.2 builds vbs, vbs_describe, vbs_benchmarks
and the sdk/core/v1/selfhost test executables; vbs runs under Wine
and the SDK suite passes 17/17. The Linux suite stays green (8/8).
This commit is contained in:
faumaray committed 2026-12-06 02:01:24 +03:00
1 parent 8768720e54
commit e333bbe84b
23 files changed
+715 -127

No files matched your search

+72 -16
View File
@@ -4,32 +4,77 @@
#include <Void/System/Process.hpp>
#include <Void/System/Types.hpp>
#include <algorithm>
#include <chrono>
#include <mutex>
#include <thread>
#if defined(_WIN32)
#include <cwctype>
#else
#include <sys/stat.h>
#include <sys/wait.h>
#include <thread>
#include <unistd.h>
#endif
#if !defined(__linux__)
#if !defined(__linux__) && !defined(_WIN32)
#error \
"VoidBuildSystem's process and file backends currently support Linux hosts only (Track C2/C3 ports are planned)"
"VoidBuildSystem's process and file backends currently support Linux and Windows hosts only (Track C2/C3 ports are planned)"
#endif
namespace Void::Build::Platform {
namespace {
#if defined(_WIN32)
constexpr char kPathSeparator = ';';
#else
constexpr char kPathSeparator = ':';
#endif
bool is_executable_file(const std::filesystem::path &p) {
#if defined(_WIN32)
std::error_code ec;
if (!std::filesystem::is_regular_file(p, ec)) {
return false;
}
std::string ext = p.extension().string();
std::ranges::transform(ext, ext.begin(), [](unsigned char c) {
return static_cast<char>(std::tolower(c));
});
return ext.empty() || ext == ".exe" || ext == ".com" || ext == ".bat" || ext == ".cmd";
#else
struct stat st{};
if (::stat(p.c_str(), &st) != 0) {
return false;
}
return S_ISREG(st.st_mode) && ::access(p.c_str(), X_OK) == 0;
#endif
}
std::optional<std::filesystem::path> resolve_candidate(const std::filesystem::path &candidate) {
std::vector<std::filesystem::path> names{candidate};
#if defined(_WIN32)
if (!candidate.has_extension()) {
for (const char *ext : {".exe", ".cmd", ".bat", ".com"}) {
names.push_back(candidate.string() + ext);
}
}
#endif
for (const auto &name : names) {
if (is_executable_file(name)) {
std::error_code ec;
auto abs = std::filesystem::absolute(name, ec);
return ec ? name : abs.lexically_normal();
}
}
return std::nullopt;
}
void ensure_subreaper() noexcept {
#if !defined(_WIN32)
static std::once_flag once;
std::call_once(once, [] { (void)Void::Process::enable_subreaper(); });
#endif
}
} // namespace
@@ -40,11 +85,14 @@ resolve_executable(const std::filesystem::path &executable,
if (executable.empty()) {
return std::nullopt;
}
if (executable.is_absolute() || executable.string().find('/') != std::string::npos) {
if (executable.is_absolute() ||
executable.string().find_first_of(std::string_view{"/\\"}) != std::string::npos) {
std::error_code ec;
const auto abs = std::filesystem::absolute(executable, ec);
if (!ec && is_executable_file(abs)) {
return abs.lexically_normal();
if (!ec) {
if (auto resolved = resolve_candidate(abs); resolved) {
return resolved;
}
}
return std::nullopt;
}
@@ -58,21 +106,23 @@ resolve_executable(const std::filesystem::path &executable,
}
std::size_t start = 0;
while (start <= path_env.size()) {
const auto colon = path_env.find(':', start);
const auto segment = path_env.substr(
start, colon == std::string_view::npos ? std::string_view::npos : colon - start);
const auto separator = path_env.find(kPathSeparator, start);
auto segment = path_env.substr(
start, separator == std::string_view::npos ? std::string_view::npos : separator - start);
// Windows PATH entries may be quoted.
if (segment.size() >= 2 && segment.front() == '"' && segment.back() == '"') {
segment.remove_prefix(1);
segment.remove_suffix(1);
}
const std::filesystem::path dir =
segment.empty() ? std::filesystem::path{"."} : std::filesystem::path{segment};
const auto candidate = dir / executable;
if (is_executable_file(candidate)) {
std::error_code ec;
auto abs = std::filesystem::absolute(candidate, ec);
return ec ? candidate : abs.lexically_normal();
if (auto resolved = resolve_candidate(dir / executable); resolved) {
return resolved;
}
if (colon == std::string_view::npos) {
if (separator == std::string_view::npos) {
break;
}
start = colon + 1;
start = separator + 1;
}
return std::nullopt;
}
@@ -159,15 +209,19 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
bool group_timed_out = comm->timed_out;
bool group_cancelled = comm->cancelled;
bool descendants_terminated = false;
#if !defined(_WIN32)
const pid_t pgid = static_cast<pid_t>(child->pgid());
#endif
if (!group_timed_out && !group_cancelled && !comm->overflowed) {
const auto descendant_deadline =
std::chrono::steady_clock::now() + request.descendant_grace;
while (child->process_group_alive()) {
#if !defined(_WIN32)
// Reap any adopted descendants in this process group (subreaper) so zombies clear.
int wstatus = 0;
while (pgid > 0 && ::waitpid(-pgid, &wstatus, WNOHANG) > 0) {
}
#endif
if (!child->process_group_alive()) {
break;
}
@@ -192,6 +246,7 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
if (group_cancelled || group_timed_out || descendants_terminated || comm->overflowed ||
child->process_group_alive()) {
(void)child->terminate(request.kill_grace);
#if !defined(_WIN32)
// Reap the whole group until it is really gone (bounded), so no zombie or orphan is
// left behind after test supervision.
const auto reap_deadline =
@@ -210,6 +265,7 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
continue;
}
}
#endif
}
ProcessResult result;