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
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:
1 parent
8768720e54
commit
e333bbe84b
23 files changed
+715
-127
No files matched your search
+25
-11
@@ -18,7 +18,7 @@ endif()
|
||||
option(VBS_BUILD_TESTS "Build declaration SDK and native engine test suites" ON)
|
||||
option(VBS_BUILD_BENCHMARKS "Build reproducible VBS benchmark harness" ON)
|
||||
set(VBS_VOID_SOURCE_DIR "" CACHE PATH "Development-only VoidLibrary source override (bypasses pin)")
|
||||
set(VBS_VOID_REVISION "0002e74a7da94a756f55a4a5574d20b77736c185")
|
||||
set(VBS_VOID_REVISION "482a3ea46b0050ec07f5063fd319e66180b4d2e4")
|
||||
include(cmake/VoidDependency.cmake)
|
||||
vbs_add_void_dependency()
|
||||
|
||||
@@ -90,6 +90,10 @@ target_link_libraries(VoidBuild_Core PUBLIC
|
||||
Void::Archive
|
||||
Void::Log)
|
||||
target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_CRYPTO=1 VBS_HAS_VOID_ARCHIVE=1)
|
||||
if(WIN32)
|
||||
# Winsock for the registry client and the native Windows HTTP fallbacks.
|
||||
target_link_libraries(VoidBuild_Core PUBLIC ws2_32)
|
||||
endif()
|
||||
if(VBS_HAS_VOID_SQLITE)
|
||||
target_link_libraries(VoidBuild_Core PUBLIC Void::Sqlite)
|
||||
target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_SQLITE=1)
|
||||
@@ -99,12 +103,16 @@ if(VBS_HAS_VOID_NET)
|
||||
target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_NET=1)
|
||||
endif()
|
||||
|
||||
add_library(VoidBuild_Registry STATIC
|
||||
registry/service/HttpServer.cpp
|
||||
registry/service/RegistryService.cpp)
|
||||
add_library(Void::BuildRegistry ALIAS VoidBuild_Registry)
|
||||
target_include_directories(VoidBuild_Registry PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/registry/include")
|
||||
target_link_libraries(VoidBuild_Registry PUBLIC Void::BuildCore)
|
||||
if(NOT WIN32)
|
||||
# The registry service uses a POSIX socket loop; its Windows port (named pipes
|
||||
# or Winsock) is Track C3 work.
|
||||
add_library(VoidBuild_Registry STATIC
|
||||
registry/service/HttpServer.cpp
|
||||
registry/service/RegistryService.cpp)
|
||||
add_library(Void::BuildRegistry ALIAS VoidBuild_Registry)
|
||||
target_include_directories(VoidBuild_Registry PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/registry/include")
|
||||
target_link_libraries(VoidBuild_Registry PUBLIC Void::BuildCore)
|
||||
endif()
|
||||
|
||||
configure_file(cmake/BootstrapConfig.hpp.in generated/Void/Build/BootstrapConfig.hpp @ONLY)
|
||||
|
||||
@@ -112,9 +120,11 @@ add_executable(vbs src/Main.cpp)
|
||||
target_include_directories(vbs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs PRIVATE Void::BuildCore)
|
||||
|
||||
add_executable(vbs-registry registry/cli/Main.cpp)
|
||||
target_include_directories(vbs-registry PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs-registry PRIVATE Void::BuildRegistry)
|
||||
if(NOT WIN32)
|
||||
add_executable(vbs-registry registry/cli/Main.cpp)
|
||||
target_include_directories(vbs-registry PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs-registry PRIVATE Void::BuildRegistry)
|
||||
endif()
|
||||
|
||||
add_library(VoidBuild_ExampleDescription STATIC
|
||||
build.cpp
|
||||
@@ -127,8 +137,12 @@ add_executable(vbs_describe src/Describe.cpp)
|
||||
target_include_directories(vbs_describe PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_describe PRIVATE VoidBuild_ExampleDescription Void::Configuration)
|
||||
|
||||
set_target_properties(vbs vbs-registry vbs_describe PROPERTIES
|
||||
set_target_properties(vbs vbs_describe PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||
if(TARGET vbs-registry)
|
||||
set_target_properties(vbs-registry PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||
endif()
|
||||
|
||||
if(VBS_BUILD_BENCHMARKS)
|
||||
add_executable(vbs_benchmarks benchmarks/EngineBenchmarks.cpp)
|
||||
|
||||
@@ -6,7 +6,7 @@ void build(Void::Build::Project &project) {
|
||||
auto library = project.dependency("VoidLibrary");
|
||||
library
|
||||
.git("https://git.faumaray.com/Void/VoidLibrary.git",
|
||||
Void::Build::Commit{"0002e74a7da94a756f55a4a5574d20b77736c185"})
|
||||
Void::Build::Commit{"482a3ea46b0050ec07f5063fd319e66180b4d2e4"})
|
||||
.native_builder({{"VOID_ENABLED_MODULES",
|
||||
"Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Testing;Log"},
|
||||
{"BUILD_SHARED_LIBS", false}});
|
||||
@@ -41,6 +41,10 @@ void build(Void::Build::Project &project) {
|
||||
.link(library.target("Void::Crypto"), Void::Build::Visibility::Public)
|
||||
.link(library.target("Void::Archive"), Void::Build::Visibility::Public)
|
||||
.link(library.target("Void::Log"), Void::Build::Visibility::Public);
|
||||
if (ctx.os == "Windows") {
|
||||
// Winsock for the registry client and the native Windows HTTP fallbacks.
|
||||
core.link_option("-lws2_32");
|
||||
}
|
||||
BuildSupport::compiler_warnings(core, ctx);
|
||||
|
||||
// Generate profile-isolated BootstrapConfig.hpp inside $GEN/include/Void/Build/.
|
||||
@@ -80,21 +84,34 @@ void build(Void::Build::Project &project) {
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(cli, ctx);
|
||||
|
||||
auto registry_lib = project.static_library("VoidBuildRegistry");
|
||||
registry_lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources(project.glob("registry/service/*.cpp"))
|
||||
.include_directory("registry/include", Void::Build::Visibility::Public)
|
||||
.link(core, Void::Build::Visibility::Public);
|
||||
BuildSupport::compiler_warnings(registry_lib, ctx);
|
||||
// The registry service is POSIX-only until its Track C3 Windows port lands.
|
||||
if (ctx.os != "Windows") {
|
||||
auto registry_lib = project.static_library("VoidBuildRegistry");
|
||||
registry_lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources(project.glob("registry/service/*.cpp"))
|
||||
.include_directory("registry/include", Void::Build::Visibility::Public)
|
||||
.link(core, Void::Build::Visibility::Public);
|
||||
BuildSupport::compiler_warnings(registry_lib, ctx);
|
||||
|
||||
auto registry_cli = project.executable("vbs-registry");
|
||||
registry_cli.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"registry/cli/Main.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(registry_cli, ctx);
|
||||
auto registry_cli = project.executable("vbs-registry");
|
||||
registry_cli.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"registry/cli/Main.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(registry_cli, ctx);
|
||||
|
||||
auto reg_tests = project.test("vbs_registry_tests");
|
||||
reg_tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/RegistryTests.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.depends_on(cli)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.link(library.target("Void::Testing"));
|
||||
BuildSupport::compiler_warnings(reg_tests, ctx);
|
||||
}
|
||||
|
||||
auto smoke_test = project.test("vbs_self_smoke");
|
||||
smoke_test.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
@@ -139,16 +156,6 @@ void build(Void::Build::Project &project) {
|
||||
.link(library.target("Void::Testing"));
|
||||
BuildSupport::compiler_warnings(v1_tests, ctx);
|
||||
|
||||
auto reg_tests = project.test("vbs_registry_tests");
|
||||
reg_tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/RegistryTests.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.depends_on(cli)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.link(library.target("Void::Testing"));
|
||||
BuildSupport::compiler_warnings(reg_tests, ctx);
|
||||
|
||||
auto selfhost_tests = project.test("vbs_selfhost_tests");
|
||||
selfhost_tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/SelfHostTests.cpp"})
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
@@ -31,12 +32,31 @@ class FileLock {
|
||||
acquire(const std::filesystem::path &lock_path, LockMode mode = LockMode::Exclusive,
|
||||
bool non_blocking = false);
|
||||
|
||||
[[nodiscard]] bool valid() const noexcept { return lock_.locked(); }
|
||||
void release() noexcept { lock_.unlock(); }
|
||||
[[nodiscard]] bool valid() const noexcept {
|
||||
#if defined(_WIN32)
|
||||
return handle_ != nullptr;
|
||||
#else
|
||||
return lock_.locked();
|
||||
#endif
|
||||
}
|
||||
void release() noexcept {
|
||||
#if defined(_WIN32)
|
||||
handle_.reset();
|
||||
#else
|
||||
lock_.unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined(_WIN32)
|
||||
explicit FileLock(std::shared_ptr<void> handle) noexcept : handle_{std::move(handle)} {}
|
||||
// Win32 HANDLE (CreateFileW + LockFileEx) with an unlock/close deleter, because
|
||||
// Void::FileSystem::FileLock is POSIX-only (Void/Library issue #66).
|
||||
std::shared_ptr<void> handle_;
|
||||
#else
|
||||
explicit FileLock(Void::FileSystem::FileLock lock) noexcept : lock_{std::move(lock)} {}
|
||||
Void::FileSystem::FileLock lock_;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct FileMetadata {
|
||||
|
||||
+56
-10
@@ -40,25 +40,25 @@
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <poll.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <system_error>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
// The daemon control socket is a POSIX Unix-domain socket (Linux/macOS). Windows support is
|
||||
// planned (Track C3) and would need a named-pipe transport instead.
|
||||
#if defined(_WIN32)
|
||||
#error \
|
||||
"The vbs daemon Unix-socket transport requires a POSIX host (Track C3 Windows port is planned)."
|
||||
#endif
|
||||
// The daemon control socket is a POSIX Unix-domain socket (Linux/macOS); the
|
||||
// Windows named-pipe transport is planned for Track C3.
|
||||
#include <vector>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32)
|
||||
namespace Void::Build::Daemon {
|
||||
namespace {
|
||||
|
||||
@@ -3099,3 +3099,49 @@ request(const std::filesystem::path &socket_path, std::string_view request_json,
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Daemon
|
||||
|
||||
#else
|
||||
namespace Void::Build::Daemon {
|
||||
|
||||
struct DaemonServer::Impl {};
|
||||
|
||||
DaemonServer::~DaemonServer() = default;
|
||||
DaemonServer::DaemonServer(DaemonServer &&) noexcept = default;
|
||||
DaemonServer &DaemonServer::operator=(DaemonServer &&) noexcept = default;
|
||||
DaemonServer::DaemonServer(std::unique_ptr<Impl> impl) noexcept : impl_{std::move(impl)} {}
|
||||
|
||||
Void::Result::Result<DaemonServer, Void::Result::Error>
|
||||
DaemonServer::create(DaemonOptions options) {
|
||||
(void)options;
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"vbs daemon: the Windows named-pipe transport is not implemented (Track C3)")};
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> DaemonServer::run(std::stop_token stop) {
|
||||
(void)stop;
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"vbs daemon: the Windows named-pipe transport is not implemented (Track C3)")};
|
||||
}
|
||||
|
||||
const std::filesystem::path &DaemonServer::socket_path() const noexcept {
|
||||
static const std::filesystem::path empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
DaemonStatus DaemonServer::status() const { return {}; }
|
||||
|
||||
Void::Result::Result<std::string, Void::Result::Error>
|
||||
request(const std::filesystem::path &socket_path, std::string_view request_json,
|
||||
std::chrono::milliseconds timeout) {
|
||||
(void)socket_path;
|
||||
(void)request_json;
|
||||
(void)timeout;
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"vbs daemon: the Windows named-pipe transport is not implemented (Track C3)")};
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Daemon
|
||||
#endif
|
||||
+1
-1
@@ -530,7 +530,7 @@ expand_glob(const std::filesystem::path &project_root, std::string_view pattern)
|
||||
const std::filesystem::path raw_pattern{std::string{pattern}};
|
||||
if (raw_pattern.is_absolute()) {
|
||||
const auto rel_pattern = raw_pattern.lexically_relative(canonical_root);
|
||||
if (!rel_pattern.empty() && rel_pattern.native().starts_with("..")) {
|
||||
if (!rel_pattern.empty() && rel_pattern.generic_string().starts_with("..")) {
|
||||
return std::unexpected{
|
||||
make_error(std::format("expand_glob: pattern '{}' escapes project root '{}'",
|
||||
pattern, canonical_root.string()))};
|
||||
|
||||
+5
-1
@@ -1225,7 +1225,11 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
const std::time_t now =
|
||||
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
std::tm tm{};
|
||||
#if defined(_WIN32)
|
||||
::gmtime_s(&tm, &now);
|
||||
#else
|
||||
::gmtime_r(&now, &tm);
|
||||
#endif
|
||||
cdash.build_stamp =
|
||||
std::format("{:04d}{:02d}{:02d}-{:02d}{:02d}-Experimental", tm.tm_year + 1900,
|
||||
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min);
|
||||
@@ -1301,7 +1305,7 @@ int execute_workspace(BuildCmdOptions opts, bool run_tests) {
|
||||
member_dirs[member.name] = canonical;
|
||||
const std::string env_name = "VBS_WORKSPACE_MEMBER_" + member.name;
|
||||
#if defined(_WIN32)
|
||||
(void)_putenv_s(env_name.c_str(), canonical.c_str());
|
||||
(void)_putenv_s(env_name.c_str(), canonical.string().c_str());
|
||||
#else
|
||||
(void)::setenv(env_name.c_str(), canonical.c_str(), 1);
|
||||
#endif
|
||||
|
||||
@@ -18,16 +18,22 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <arpa/inet.h>
|
||||
#include <array>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Package {
|
||||
namespace {
|
||||
@@ -93,12 +99,49 @@ struct RawHttpReply {
|
||||
std::string body;
|
||||
};
|
||||
|
||||
bool send_all(int fd, std::string_view data) {
|
||||
#if defined(_WIN32)
|
||||
using SocketHandle = SOCKET;
|
||||
inline constexpr SocketHandle kInvalidSocket = INVALID_SOCKET;
|
||||
|
||||
void ensure_socket_runtime() {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
WSADATA data{};
|
||||
(void)::WSAStartup(MAKEWORD(2, 2), &data);
|
||||
});
|
||||
}
|
||||
|
||||
struct SocketGuard {
|
||||
SocketHandle handle{kInvalidSocket};
|
||||
~SocketGuard() {
|
||||
if (handle != kInvalidSocket) {
|
||||
::closesocket(handle);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool interrupted() { return ::WSAGetLastError() == WSAEINTR; }
|
||||
#else
|
||||
using SocketHandle = int;
|
||||
inline constexpr SocketHandle kInvalidSocket = -1;
|
||||
|
||||
void ensure_socket_runtime() {}
|
||||
|
||||
using SocketGuard = Void::System::OwnedFd;
|
||||
|
||||
bool interrupted() { return errno == EINTR; }
|
||||
#endif
|
||||
|
||||
bool send_all(SocketHandle fd, std::string_view data) {
|
||||
std::size_t off = 0;
|
||||
while (off < data.size()) {
|
||||
#if defined(_WIN32)
|
||||
const int n = ::send(fd, data.data() + off, static_cast<int>(data.size() - off), 0);
|
||||
#else
|
||||
const ssize_t n = ::send(fd, data.data() + off, data.size() - off, MSG_NOSIGNAL);
|
||||
#endif
|
||||
if (n < 0) {
|
||||
if (errno == EINTR) {
|
||||
if (interrupted()) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
@@ -154,6 +197,7 @@ send_http_request(const ParsedHttpUrl &parsed, std::string_view method, std::str
|
||||
#else
|
||||
// Plain TCP HTTP/1.1 client for http:// (loopback/local registry without external deps).
|
||||
if (parsed.scheme == "http") {
|
||||
ensure_socket_runtime();
|
||||
struct addrinfo hints{};
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
@@ -166,18 +210,27 @@ send_http_request(const ParsedHttpUrl &parsed, std::string_view method, std::str
|
||||
}
|
||||
auto free_ai = Void::Scope::on_exit([&] { ::freeaddrinfo(res); });
|
||||
|
||||
const int fd = ::socket(res->ai_family, res->ai_socktype | SOCK_CLOEXEC, res->ai_protocol);
|
||||
if (fd < 0) {
|
||||
const SocketHandle fd =
|
||||
::socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||
if (fd == kInvalidSocket) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"registry client: socket() failed")};
|
||||
}
|
||||
Void::System::OwnedFd guard{fd};
|
||||
SocketGuard guard{fd};
|
||||
|
||||
#if defined(_WIN32)
|
||||
DWORD timeout_ms = 30000;
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,
|
||||
reinterpret_cast<const char *>(&timeout_ms), sizeof(timeout_ms));
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO,
|
||||
reinterpret_cast<const char *>(&timeout_ms), sizeof(timeout_ms));
|
||||
#else
|
||||
struct timeval tv{30, 0};
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
#endif
|
||||
|
||||
if (::connect(fd, res->ai_addr, res->ai_addrlen) != 0) {
|
||||
if (::connect(fd, res->ai_addr, static_cast<int>(res->ai_addrlen)) != 0) {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("registry client: connect to {}:{} failed", parsed.host, parsed.port))};
|
||||
@@ -204,7 +257,7 @@ send_http_request(const ParsedHttpUrl &parsed, std::string_view method, std::str
|
||||
raw.append(buf.data(), static_cast<std::size_t>(n));
|
||||
} else if (n == 0) {
|
||||
break;
|
||||
} else if (errno != EINTR) {
|
||||
} else if (!interrupted()) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"registry client: recv() failed")};
|
||||
}
|
||||
|
||||
@@ -3,16 +3,23 @@
|
||||
#include <Void/System/Types.hpp>
|
||||
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <set>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(__linux__)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#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 {
|
||||
@@ -36,6 +43,44 @@ FileLock::acquire(const std::filesystem::path &lock_path, LockMode mode, bool no
|
||||
lock_path.string(), ec.message()))};
|
||||
}
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
// Void::FileSystem::FileLock is POSIX-only (Void/Library issue #66).
|
||||
const HANDLE raw = ::CreateFileW(lock_path.c_str(), GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (raw == INVALID_HANDLE_VALUE) {
|
||||
const DWORD err = ::GetLastError();
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("FileLock: cannot open '{}' (error {})", lock_path.string(), err),
|
||||
static_cast<int>(err))};
|
||||
}
|
||||
OVERLAPPED overlapped{};
|
||||
DWORD flags = mode == LockMode::Exclusive ? LOCKFILE_EXCLUSIVE_LOCK : 0;
|
||||
if (non_blocking) {
|
||||
flags |= LOCKFILE_FAIL_IMMEDIATELY;
|
||||
}
|
||||
if (::LockFileEx(raw, flags, 0, MAXDWORD, MAXDWORD, &overlapped) == 0) {
|
||||
const DWORD err = ::GetLastError();
|
||||
::CloseHandle(raw);
|
||||
if (non_blocking && (err == ERROR_LOCK_VIOLATION || err == ERROR_IO_PENDING)) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::busy,
|
||||
std::format("FileLock: '{}' is already locked", lock_path.string()), EAGAIN)};
|
||||
}
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("FileLock: locking '{}' failed (error {})", lock_path.string(), err),
|
||||
static_cast<int>(err))};
|
||||
}
|
||||
auto handle = std::shared_ptr<void>{raw, [](void *h) {
|
||||
OVERLAPPED unlock{};
|
||||
(void)::UnlockFileEx(static_cast<HANDLE>(h), 0, MAXDWORD,
|
||||
MAXDWORD, &unlock);
|
||||
(void)::CloseHandle(static_cast<HANDLE>(h));
|
||||
}};
|
||||
return FileLock{std::move(handle)};
|
||||
#else
|
||||
const auto vl_mode = (mode == LockMode::Exclusive) ? Void::FileSystem::LockMode::Exclusive
|
||||
: Void::FileSystem::LockMode::Shared;
|
||||
if (non_blocking) {
|
||||
@@ -46,7 +91,7 @@ FileLock::acquire(const std::filesystem::path &lock_path, LockMode mode, bool no
|
||||
if (!res->has_value()) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::busy,
|
||||
std::format("FileLock: '{}' is already locked", lock_path.string()), EWOULDBLOCK)};
|
||||
std::format("FileLock: '{}' is already locked", lock_path.string()), EAGAIN)};
|
||||
}
|
||||
return FileLock{std::move(**res)};
|
||||
}
|
||||
@@ -55,10 +100,78 @@ FileLock::acquire(const std::filesystem::path &lock_path, LockMode mode, bool no
|
||||
return std::unexpected{std::move(res.error())};
|
||||
}
|
||||
return FileLock{std::move(*res)};
|
||||
#endif
|
||||
}
|
||||
|
||||
Void::Result::Result<FileMetadata, Void::Result::Error>
|
||||
stat_lstat(const std::filesystem::path &path) {
|
||||
#if defined(_WIN32)
|
||||
std::error_code ec;
|
||||
const auto status = std::filesystem::symlink_status(path, ec);
|
||||
if (ec) {
|
||||
if (ec == std::errc::no_such_file_or_directory || ec == std::errc::not_a_directory) {
|
||||
FileMetadata missing;
|
||||
return missing;
|
||||
}
|
||||
return std::unexpected{sys_err(
|
||||
ec.value(), std::format("stat_lstat: symlink_status failed for '{}': {}",
|
||||
path.string(), ec.message()))};
|
||||
}
|
||||
if (!std::filesystem::exists(status)) {
|
||||
FileMetadata missing;
|
||||
return missing;
|
||||
}
|
||||
|
||||
FileMetadata meta;
|
||||
meta.exists = true;
|
||||
meta.is_regular = std::filesystem::is_regular_file(status);
|
||||
meta.is_directory = std::filesystem::is_directory(status);
|
||||
meta.is_symlink = std::filesystem::is_symlink(status);
|
||||
if (meta.is_symlink) {
|
||||
std::error_code target_ec;
|
||||
const auto target = std::filesystem::read_symlink(path, target_ec);
|
||||
if (!target_ec) {
|
||||
meta.symlink_target = target.string();
|
||||
}
|
||||
}
|
||||
|
||||
const auto followed = std::filesystem::status(path, ec);
|
||||
if (!ec) {
|
||||
if (std::filesystem::is_regular_file(followed)) {
|
||||
const auto size = std::filesystem::file_size(path, ec);
|
||||
if (!ec) {
|
||||
meta.size = static_cast<std::uint64_t>(size);
|
||||
}
|
||||
ec.clear();
|
||||
}
|
||||
const auto mtime = std::filesystem::last_write_time(path, ec);
|
||||
if (!ec) {
|
||||
const auto sys = std::chrono::file_clock::to_sys(mtime);
|
||||
const auto secs = std::chrono::floor<std::chrono::seconds>(sys);
|
||||
meta.mtime_sec = static_cast<std::int64_t>(secs.time_since_epoch().count());
|
||||
meta.mtime_nsec = static_cast<std::int64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(sys - secs).count());
|
||||
}
|
||||
}
|
||||
|
||||
// Identity through a Win32 handle (volume serial, file index, link count).
|
||||
const HANDLE handle = ::CreateFileW(path.c_str(), FILE_READ_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS,
|
||||
nullptr);
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
BY_HANDLE_FILE_INFORMATION info{};
|
||||
if (::GetFileInformationByHandle(handle, &info) != 0) {
|
||||
meta.dev = info.dwVolumeSerialNumber;
|
||||
meta.ino = (static_cast<std::uint64_t>(info.nFileIndexHigh) << 32) |
|
||||
static_cast<std::uint64_t>(info.nFileIndexLow);
|
||||
meta.nlink = info.nNumberOfLinks;
|
||||
}
|
||||
::CloseHandle(handle);
|
||||
}
|
||||
meta.mode = meta.is_directory ? 0755u : 0644u;
|
||||
return meta;
|
||||
#else
|
||||
struct stat st{};
|
||||
if (::lstat(path.c_str(), &st) != 0) {
|
||||
const int err = errno;
|
||||
@@ -104,6 +217,7 @@ stat_lstat(const std::filesystem::path &path) {
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
#endif
|
||||
}
|
||||
|
||||
Void::Result::Result<bool, Void::Result::Error>
|
||||
@@ -125,17 +239,47 @@ copy_isolated(const std::filesystem::path &src, const std::filesystem::path &dst
|
||||
|
||||
auto res = Void::FileSystem::reflink_copy_file(src, dst, opts);
|
||||
if (!res) {
|
||||
#if defined(_WIN32)
|
||||
// No reflink support on this filesystem/host: fall back to a plain copy.
|
||||
std::filesystem::copy_file(src, dst, std::filesystem::copy_options::overwrite_existing,
|
||||
ec);
|
||||
if (ec) {
|
||||
return std::unexpected{sys_err(
|
||||
ec.value(), std::format("copy_isolated: copy_file failed for '{}': {}",
|
||||
dst.string(), ec.message()))};
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return std::unexpected{std::move(res.error())};
|
||||
#endif
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
(void)mode_override;
|
||||
#else
|
||||
if (mode_override) {
|
||||
(void)::chmod(dst.c_str(), static_cast<mode_t>(*mode_override));
|
||||
}
|
||||
#endif
|
||||
return res->method == Void::FileSystem::CopyMethod::Reflink;
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
set_canonical_mtime(const std::filesystem::path &path, std::int64_t epoch_seconds) {
|
||||
#if defined(_WIN32)
|
||||
// Void::FileSystem::set_canonical_mtime is POSIX-only (Void/Library issue #66).
|
||||
std::error_code ec;
|
||||
const auto stamp = std::chrono::file_clock::from_sys(
|
||||
std::chrono::system_clock::time_point{std::chrono::seconds{epoch_seconds}});
|
||||
std::filesystem::last_write_time(path, stamp, ec);
|
||||
if (ec) {
|
||||
return std::unexpected{
|
||||
sys_err(ec.value(), std::format("set_canonical_mtime: failed for '{}': {}",
|
||||
path.string(), ec.message()))};
|
||||
}
|
||||
return {};
|
||||
#else
|
||||
return Void::FileSystem::set_canonical_mtime(path, epoch_seconds, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
@@ -172,6 +316,11 @@ Void::Result::Result<void, Void::Result::Error> atomic_write_file(const std::fil
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
fsync_directory(const std::filesystem::path &dir_path) {
|
||||
#if defined(_WIN32)
|
||||
// Windows has no directory fsync; MoveFileEx visibility is the durability guarantee.
|
||||
(void)dir_path;
|
||||
return {};
|
||||
#else
|
||||
const int fd = ::open(dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
const int err = errno;
|
||||
@@ -193,6 +342,7 @@ fsync_directory(const std::filesystem::path &dir_path) {
|
||||
return std::unexpected{
|
||||
sys_err(err, std::format("fsync_directory: fsync failed for '{}'", dir_path.string()))};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
@@ -206,8 +356,27 @@ atomic_swap_symlink(const std::filesystem::path &link_path, const std::filesyste
|
||||
ec.value(), std::format("atomic_swap_symlink: create_directories failed for '{}'",
|
||||
parent.string()))};
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
// Void::FileSystem::atomic_symlink_swap is POSIX-only (Void/Library issue #66).
|
||||
// Windows symlink creation needs privileges, so the alias becomes a regular
|
||||
// file copy of the target: consumers read the same content at link_path.
|
||||
std::error_code target_ec;
|
||||
if (!std::filesystem::is_regular_file(target, target_ec)) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
std::format("atomic_swap_symlink: cannot alias '{}' to '{}' on Windows",
|
||||
link_path.string(), target.string()))};
|
||||
}
|
||||
const auto bytes = Void::FileSystem::read_file(target);
|
||||
if (!bytes) {
|
||||
return std::unexpected{std::move(bytes.error())};
|
||||
}
|
||||
return atomic_write_bytes(link_path, std::as_bytes(std::span<const char>{*bytes}),
|
||||
/*durable_sync=*/true);
|
||||
#else
|
||||
return Void::FileSystem::atomic_symlink_swap(link_path, target,
|
||||
Void::FileSystem::ReplaceDurability::durable_sync);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool path_is_within(const std::filesystem::path &root, const std::filesystem::path &path) {
|
||||
@@ -316,6 +485,19 @@ resolve_confined_path(const std::filesystem::path &root, const std::filesystem::
|
||||
}
|
||||
|
||||
Void::Result::Result<std::filesystem::path, Void::Result::Error> current_executable_path() {
|
||||
#if defined(_WIN32)
|
||||
std::wstring buffer(32768, L'\0');
|
||||
const DWORD length =
|
||||
::GetModuleFileNameW(nullptr, buffer.data(), static_cast<DWORD>(buffer.size()));
|
||||
if (length == 0 || length >= buffer.size()) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("current_executable_path: GetModuleFileNameW failed ({})",
|
||||
::GetLastError()))};
|
||||
}
|
||||
buffer.resize(length);
|
||||
return std::filesystem::path{buffer};
|
||||
#else
|
||||
std::error_code ec;
|
||||
const auto path = std::filesystem::read_symlink("/proc/self/exe", ec);
|
||||
if (ec || path.empty()) {
|
||||
@@ -326,6 +508,7 @@ Void::Result::Result<std::filesystem::path, Void::Result::Error> current_executa
|
||||
ec.value())};
|
||||
}
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Platform
|
||||
@@ -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;
|
||||
|
||||
@@ -18,7 +18,11 @@ using Util::json_quote;
|
||||
std::string iso8601(std::int64_t epoch) {
|
||||
const auto time = static_cast<std::time_t>(epoch);
|
||||
std::tm tm{};
|
||||
#if defined(_WIN32)
|
||||
::gmtime_s(&tm, &time);
|
||||
#else
|
||||
::gmtime_r(&time, &tm);
|
||||
#endif
|
||||
char buffer[32];
|
||||
(void)std::strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", &tm);
|
||||
return buffer;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Void/Build/Report/Cdash.hpp>
|
||||
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Core/Scope.hpp>
|
||||
#include <Void/System/Types.hpp>
|
||||
#include <Void/Text/Str.hpp>
|
||||
@@ -11,9 +12,13 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <format>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(VBS_HAS_VOID_NET)
|
||||
#include <Void/Net/Http.hpp>
|
||||
@@ -61,17 +66,30 @@ std::string utc_timestamp() {
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::time_t seconds = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm tm{};
|
||||
#if defined(_WIN32)
|
||||
::gmtime_s(&tm, &seconds);
|
||||
#else
|
||||
::gmtime_r(&seconds, &tm);
|
||||
#endif
|
||||
return std::format("{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}", tm.tm_year + 1900,
|
||||
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
}
|
||||
|
||||
std::string host_name() {
|
||||
#if defined(_WIN32)
|
||||
char buffer[256]{};
|
||||
DWORD size = static_cast<DWORD>(sizeof(buffer) - 1);
|
||||
if (::GetComputerNameA(buffer, &size) != 0) {
|
||||
return buffer;
|
||||
}
|
||||
return "localhost";
|
||||
#else
|
||||
char buffer[256]{};
|
||||
if (::gethostname(buffer, sizeof(buffer) - 1) == 0) {
|
||||
return buffer;
|
||||
}
|
||||
return "localhost";
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -186,6 +204,44 @@ submit_cdash_report(std::string_view cdash_url, std::string_view project,
|
||||
response->body.substr(0, 200)))};
|
||||
}
|
||||
return {};
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
// Windows: curl performs the submission for http and https (Void::Net not linked).
|
||||
auto curl = Platform::resolve_executable("curl");
|
||||
if (!curl) {
|
||||
return std::unexpected{make_error(
|
||||
"CDash submission on Windows requires curl (Void::Net not linked)")};
|
||||
}
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = *curl;
|
||||
req.arguments = {"--silent",
|
||||
"--show-error",
|
||||
"-X",
|
||||
"POST",
|
||||
"-H",
|
||||
"Content-Type: " + submission.content_type,
|
||||
"--data-binary",
|
||||
"@-",
|
||||
"-w",
|
||||
"\n%{http_code}",
|
||||
std::format("{}://{}:{}{}", scheme, host, port, path)};
|
||||
req.stdin_data = submission.body;
|
||||
req.timeout = std::chrono::seconds{60};
|
||||
auto proc = Platform::run_supervised(req);
|
||||
if (!proc || !proc->succeeded()) {
|
||||
return std::unexpected{make_error(std::format(
|
||||
"CDash submission failed: {}",
|
||||
proc ? proc->stderr_data : proc.error().message()))};
|
||||
}
|
||||
int status = 0;
|
||||
if (const auto nl = proc->stdout_data.rfind('\n'); nl != std::string::npos) {
|
||||
(void)Void::Str::to_int(Void::Str::trim_ascii(proc->stdout_data.substr(nl + 1)), status);
|
||||
}
|
||||
if (status < 200 || status >= 300) {
|
||||
return std::unexpected{
|
||||
make_error(std::format("CDash submission rejected with HTTP {}", status))};
|
||||
}
|
||||
return {};
|
||||
#else
|
||||
// Plain TCP HTTP/1.1 POST for http:// (Void::Net server transport not linked).
|
||||
if (scheme != "http") {
|
||||
@@ -252,6 +308,7 @@ submit_cdash_report(std::string_view cdash_url, std::string_view project,
|
||||
}
|
||||
return {};
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Report
|
||||
@@ -76,6 +76,27 @@ bool path_has_excluded_component(const std::filesystem::path &rel_path,
|
||||
Void::Result::Result<std::vector<std::string>, Void::Result::Error>
|
||||
read_sorted_dir_entries(const std::filesystem::path &dir_path,
|
||||
const std::vector<std::string> &excluded) {
|
||||
#if defined(_WIN32)
|
||||
std::error_code ec;
|
||||
std::vector<std::string> names;
|
||||
for (std::filesystem::directory_iterator it{dir_path, ec}, end; !ec && it != end;
|
||||
it.increment(ec)) {
|
||||
const auto name = it->path().filename().string();
|
||||
if (is_excluded_name(name, excluded)) {
|
||||
continue;
|
||||
}
|
||||
names.push_back(name);
|
||||
}
|
||||
if (ec) {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("snapshot: cannot read directory '{}': {}", dir_path.string(),
|
||||
ec.message()),
|
||||
ec.value())};
|
||||
}
|
||||
std::ranges::sort(names);
|
||||
return names;
|
||||
#else
|
||||
const int fd = ::open(dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
const int err = errno;
|
||||
@@ -112,6 +133,7 @@ read_sorted_dir_entries(const std::filesystem::path &dir_path,
|
||||
}
|
||||
std::ranges::sort(names);
|
||||
return names;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string normalize_logical(const std::filesystem::path &rel) {
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#if !defined(_WIN32)
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::State {
|
||||
namespace {
|
||||
@@ -87,6 +89,7 @@ struct HttpReply {
|
||||
std::string body;
|
||||
};
|
||||
|
||||
#if !defined(_WIN32)
|
||||
bool send_all(int fd, std::string_view data) {
|
||||
std::size_t off = 0;
|
||||
while (off < data.size()) {
|
||||
@@ -101,6 +104,7 @@ bool send_all(int fd, std::string_view data) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Void::Result::Result<HttpReply, Void::Result::Error>
|
||||
http_exchange(const ParsedUrl &parsed, std::string_view method, std::string_view path,
|
||||
@@ -139,6 +143,7 @@ http_exchange(const ParsedUrl &parsed, std::string_view method, std::string_view
|
||||
}
|
||||
return HttpReply{response->status, std::move(response->body)};
|
||||
#else
|
||||
#if !defined(_WIN32)
|
||||
if (parsed.scheme == "http") {
|
||||
struct addrinfo hints{};
|
||||
hints.ai_family = AF_INET;
|
||||
@@ -215,19 +220,20 @@ http_exchange(const ParsedUrl &parsed, std::string_view method, std::string_view
|
||||
reply.body = raw.substr(hdr_end + 4);
|
||||
return reply;
|
||||
}
|
||||
#endif
|
||||
|
||||
// HTTPS via curl preserves TLS certificate verification (never disables TLS).
|
||||
// http/https via curl preserve TLS certificate verification (never disable TLS).
|
||||
auto curl = Platform::resolve_executable("curl");
|
||||
if (!curl) {
|
||||
return std::unexpected{
|
||||
make_error(Void::System::SystemErrorCode::not_found,
|
||||
"HTTPS remote cache requires curl (Void::Net not linked)")};
|
||||
"remote cache requires curl (Void::Net not linked)")};
|
||||
}
|
||||
const std::string full_url =
|
||||
std::format("https://{}:{}{}", parsed.host, parsed.port, full_path);
|
||||
std::format("{}://{}:{}{}", parsed.scheme, parsed.host, parsed.port, full_path);
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = *curl;
|
||||
req.arguments = {"--silent", "--show-error", "--proto", "=https",
|
||||
req.arguments = {"--silent", "--show-error", "--proto", "=" + parsed.scheme,
|
||||
"-X", std::string{method}, "-w", "\n%{http_code}"};
|
||||
for (const auto &[k, v] : headers) {
|
||||
req.arguments.push_back("-H");
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::State {
|
||||
namespace {
|
||||
|
||||
@@ -39,10 +43,39 @@ bool pid_is_alive(pid_t pid) noexcept {
|
||||
if (pid <= 0) {
|
||||
return false;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
const HANDLE handle =
|
||||
::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, static_cast<DWORD>(pid));
|
||||
if (handle == nullptr) {
|
||||
return false;
|
||||
}
|
||||
DWORD exit_code = 0;
|
||||
const bool alive = ::GetExitCodeProcess(handle, &exit_code) != 0 && exit_code == STILL_ACTIVE;
|
||||
::CloseHandle(handle);
|
||||
return alive;
|
||||
#else
|
||||
if (::kill(pid, 0) == 0) {
|
||||
return true;
|
||||
}
|
||||
return errno != ESRCH;
|
||||
#endif
|
||||
}
|
||||
|
||||
void apply_posix_mode(const std::filesystem::path &p, unsigned mode) noexcept {
|
||||
#if defined(_WIN32)
|
||||
using Perms = std::filesystem::perms;
|
||||
Perms perms = Perms::owner_read | Perms::group_read | Perms::others_read;
|
||||
if ((mode & 0200u) != 0) {
|
||||
perms |= Perms::owner_write;
|
||||
}
|
||||
if ((mode & 0100u) != 0) {
|
||||
perms |= Perms::owner_exec;
|
||||
}
|
||||
std::error_code ec;
|
||||
std::filesystem::permissions(p, perms, std::filesystem::perm_options::replace, ec);
|
||||
#else
|
||||
(void)::chmod(p.c_str(), static_cast<mode_t>(mode));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string serialize_action(const ActionSuccessRecord &rec) {
|
||||
@@ -155,6 +188,16 @@ struct StateStore::CacheState {
|
||||
};
|
||||
|
||||
static std::optional<StatFingerprint> stat_file(const std::filesystem::path &p) noexcept {
|
||||
#if defined(_WIN32)
|
||||
struct _stat64 st{};
|
||||
if (::_wstat64(p.c_str(), &st) != 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return StatFingerprint{static_cast<std::uint64_t>(st.st_dev),
|
||||
static_cast<std::uint64_t>(st.st_ino),
|
||||
static_cast<std::uint64_t>(st.st_size),
|
||||
static_cast<std::int64_t>(st.st_mtime), 0};
|
||||
#else
|
||||
struct stat st{};
|
||||
if (::stat(p.c_str(), &st) != 0) {
|
||||
return std::nullopt;
|
||||
@@ -163,6 +206,7 @@ struct StateStore::CacheState {
|
||||
static_cast<std::uint64_t>(st.st_dev), static_cast<std::uint64_t>(st.st_ino),
|
||||
static_cast<std::uint64_t>(st.st_size), static_cast<std::int64_t>(st.st_mtim.tv_sec),
|
||||
static_cast<std::int64_t>(st.st_mtim.tv_nsec)};
|
||||
#endif
|
||||
}
|
||||
|
||||
std::mutex mutex;
|
||||
@@ -703,12 +747,12 @@ StateStore::store_blob_from_file(const std::filesystem::path &file_path) {
|
||||
if (existing_ok && *existing_ok) {
|
||||
std::filesystem::remove(stage_path, ec);
|
||||
} else {
|
||||
(void)::chmod(final_path.c_str(), 0644);
|
||||
apply_posix_mode(final_path, 0644);
|
||||
std::filesystem::rename(stage_path, final_path, ec);
|
||||
(void)::chmod(final_path.c_str(), 0444);
|
||||
apply_posix_mode(final_path, 0444);
|
||||
}
|
||||
} else {
|
||||
(void)::chmod(stage_path.c_str(), 0444);
|
||||
apply_posix_mode(stage_path, 0444);
|
||||
std::filesystem::rename(stage_path, final_path, ec);
|
||||
if (ec) {
|
||||
std::filesystem::remove(stage_path, ec);
|
||||
@@ -848,7 +892,7 @@ StateStore::ensure_remote_blob(std::string_view sha256) {
|
||||
if (!wrote) {
|
||||
return std::unexpected{wrote.error()};
|
||||
}
|
||||
(void)::chmod(stage_path.c_str(), 0444);
|
||||
apply_posix_mode(stage_path, 0444);
|
||||
std::filesystem::rename(stage_path, final_path, ec);
|
||||
if (ec) {
|
||||
std::filesystem::remove(stage_path, ec);
|
||||
@@ -1141,7 +1185,7 @@ Void::Result::Result<GcStats, Void::Result::Error> StateStore::gc(std::uint64_t
|
||||
const std::string sha = entry.path().filename().string();
|
||||
const auto fsize = entry.file_size(ec);
|
||||
if (!pinned.contains(sha)) {
|
||||
(void)::chmod(entry.path().c_str(), 0644);
|
||||
apply_posix_mode(entry.path(), 0644);
|
||||
std::filesystem::remove(entry.path(), ec);
|
||||
if (!ec) {
|
||||
++stats.removed_blobs;
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <format>
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Toolchain {
|
||||
namespace {
|
||||
@@ -260,19 +262,31 @@ void attach_shader_tools(ToolchainCapabilities &cap) {
|
||||
} // namespace
|
||||
|
||||
std::string host_os_name() {
|
||||
#if defined(_WIN32)
|
||||
return "Windows";
|
||||
#elif defined(__APPLE__)
|
||||
return "macOS";
|
||||
#else
|
||||
struct utsname u{};
|
||||
if (::uname(&u) == 0) {
|
||||
return std::string{u.sysname};
|
||||
}
|
||||
return "Linux";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string host_architecture_name() {
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
return "aarch64";
|
||||
#elif defined(_WIN32)
|
||||
return "x86_64";
|
||||
#else
|
||||
struct utsname u{};
|
||||
if (::uname(&u) == 0) {
|
||||
return std::string{u.machine};
|
||||
}
|
||||
return "x86_64";
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
#include <format>
|
||||
#include <set>
|
||||
|
||||
#if !defined(__linux__)
|
||||
// The watcher delegates to Void::FileSystem::DirectoryWatcher, which has Linux
|
||||
// (inotify) and Windows backends.
|
||||
#if !defined(__linux__) && !defined(_WIN32)
|
||||
#error \
|
||||
"VoidBuildSystem's inotify watcher currently supports Linux hosts only (Track C2/C3 ports are planned)"
|
||||
"VoidBuildSystem's watcher currently supports Linux and Windows hosts only (Track C2/C3 ports are planned)"
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Watch {
|
||||
|
||||
+22
-9
@@ -12,19 +12,27 @@ set_target_properties(vbs_core_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_core_tests COMMAND "$<TARGET_FILE:vbs_core_tests>" --no-color)
|
||||
|
||||
add_executable(vbs_v1_tests FullV1Tests.cpp DaemonTests.cpp SigningTests.cpp SignatureEnforcementTests.cpp)
|
||||
set(VBS_V1_TEST_SOURCES FullV1Tests.cpp SigningTests.cpp SignatureEnforcementTests.cpp)
|
||||
if(NOT WIN32)
|
||||
# The daemon transport is POSIX-only until its Track C3 Windows port lands.
|
||||
list(APPEND VBS_V1_TEST_SOURCES DaemonTests.cpp)
|
||||
endif()
|
||||
add_executable(vbs_v1_tests ${VBS_V1_TEST_SOURCES})
|
||||
target_include_directories(vbs_v1_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_v1_tests PRIVATE Void::BuildCore Void::Testing)
|
||||
set_target_properties(vbs_v1_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_v1_tests COMMAND "$<TARGET_FILE:vbs_v1_tests>" --no-color)
|
||||
|
||||
add_executable(vbs_registry_tests RegistryTests.cpp)
|
||||
target_include_directories(vbs_registry_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_registry_tests PRIVATE Void::BuildRegistry Void::Testing)
|
||||
set_target_properties(vbs_registry_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_registry_tests COMMAND "$<TARGET_FILE:vbs_registry_tests>" --no-color)
|
||||
if(NOT WIN32)
|
||||
# The registry service is POSIX-only until its Track C3 Windows port lands.
|
||||
add_executable(vbs_registry_tests RegistryTests.cpp)
|
||||
target_include_directories(vbs_registry_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_registry_tests PRIVATE Void::BuildRegistry Void::Testing)
|
||||
set_target_properties(vbs_registry_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_registry_tests COMMAND "$<TARGET_FILE:vbs_registry_tests>" --no-color)
|
||||
endif()
|
||||
|
||||
add_executable(vbs_selfhost_tests SelfHostTests.cpp)
|
||||
target_include_directories(vbs_selfhost_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
@@ -37,9 +45,14 @@ add_test(NAME vbs_selfhost_tests COMMAND "$<TARGET_FILE:vbs_selfhost_tests>" --n
|
||||
|
||||
add_test(NAME vbs_sdk_registration COMMAND "${CMAKE_COMMAND}"
|
||||
"-DSDK_TESTS=$<TARGET_FILE:vbs_sdk_tests>" -P "${CMAKE_CURRENT_SOURCE_DIR}/SdkRegistration.cmake")
|
||||
if(TARGET vbs-registry)
|
||||
set(VBS_REGISTRY_ARG "-DVBS_REGISTRY=$<TARGET_FILE:vbs-registry>")
|
||||
else()
|
||||
set(VBS_REGISTRY_ARG "")
|
||||
endif()
|
||||
add_test(NAME vbs_cli_contract COMMAND "${CMAKE_COMMAND}"
|
||||
"-DVBS=$<TARGET_FILE:vbs>" "-DVBS_REGISTRY=$<TARGET_FILE:vbs-registry>"
|
||||
"-DVBS_VERSION=${PROJECT_VERSION}"
|
||||
"-DVBS=$<TARGET_FILE:vbs>" "${VBS_REGISTRY_ARG}"
|
||||
"-DVBS_VERSION=${PROJECT_VERSION}" "-DVBS_WINDOWS=${WIN32}"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/CliContracts.cmake")
|
||||
add_test(NAME vbs_description_contract COMMAND "${CMAKE_COMMAND}"
|
||||
"-DDESCRIBE=$<TARGET_FILE:vbs_describe>"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
# Captured output must be plain text: the CLI colorizes help when colors are allowed.
|
||||
set(ENV{NO_COLOR} "1")
|
||||
|
||||
function(check_process expected_code expected_out_regex expected_err_regex)
|
||||
execute_process(COMMAND "${VBS}" ${ARGN}
|
||||
RESULT_VARIABLE code OUTPUT_VARIABLE out ERROR_VARIABLE err TIMEOUT 15)
|
||||
@@ -91,7 +94,10 @@ check_process(0 "Usage: vbs daemon ide query .*--profile" "" daemon ide query --
|
||||
check_process(0 "Usage: vbs daemon compdb export .*--profile" "" daemon compdb export --help)
|
||||
check_process(0 "Usage: vbs daemon compdb use .*--profile" "" daemon compdb use --help)
|
||||
check_process(0 "Usage: vbs daemon compdb entries .*--file.*--limit" "" daemon compdb entries --help)
|
||||
check_process(0 "Usage: vbs daemon ide generate .*--profile.*--editor.*--force" "" daemon ide generate --help)
|
||||
check_process(0 "Usage: vbs daemon ide generate " "" daemon ide generate --help)
|
||||
check_process(0 "--force" "" daemon ide generate --help)
|
||||
check_process(0 "--profile" "" daemon ide generate --help)
|
||||
check_process(0 "--editor" "" daemon ide generate --help)
|
||||
check_process(0 "Usage: vbs daemon ide poll " "" daemon ide poll --help)
|
||||
check_process(0 "Usage: vbs daemon ide status " "" daemon ide status --help)
|
||||
check_process(0 "Usage: vbs daemon graph .*--format" "" daemon graph --help)
|
||||
@@ -106,15 +112,20 @@ check_process(0 "Usage: vbs daemon target info .*--name" "" daemon target info -
|
||||
check_process(0 "Usage: vbs daemon target flags .*--name.*--file" "" daemon target flags --help)
|
||||
check_process(0 "Usage: vbs daemon pack .*--output" "" daemon pack --help)
|
||||
check_process(0 "Usage: vbs daemon actions .*--limit" "" daemon actions --help)
|
||||
check_process(0 "Usage: vbs daemon install .*--prefix.*--component.*--no-cmake-export.*--no-native-export" "" daemon install --help)
|
||||
check_process(0 "Usage: vbs daemon install " "" daemon install --help)
|
||||
check_process(0 "--prefix" "" daemon install --help)
|
||||
check_process(0 "--component" "" daemon install --help)
|
||||
check_process(0 "--no-cmake-export" "" daemon install --help)
|
||||
check_process(0 "--no-native-export" "" daemon install --help)
|
||||
check_process(0 "Usage: vbs daemon uninstall .*--prefix" "" daemon uninstall --help)
|
||||
check_process(0 "Usage: vbs daemon gen-tests .*--input.*--output-dir" "" daemon gen-tests --help)
|
||||
check_process(0 "Usage: vbs daemon init .*--dir" "" daemon init --help)
|
||||
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
|
||||
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
|
||||
|
||||
if(NOT VBS_WINDOWS)
|
||||
# Daemon-backed describe contract: start `vbs daemon run`, query the bounded graph summary over
|
||||
# the Unix socket, then stop it. The daemon is Unix-only, matching the rest of this suite.
|
||||
# the Unix socket, then stop it (Unix-only; the Windows transport is Track C3).
|
||||
set(daemon_contract_root "${CMAKE_CURRENT_BINARY_DIR}/daemon_contract")
|
||||
file(REMOVE_RECURSE "${daemon_contract_root}")
|
||||
file(MAKE_DIRECTORY "${daemon_contract_root}/project")
|
||||
@@ -193,6 +204,7 @@ if(NOT daemon_describe_out MATCHES "\"ok\":true" OR
|
||||
message(FATAL_ERROR "vbs daemon describe: unexpected response [${daemon_describe_out}]")
|
||||
endif()
|
||||
message(STATUS "daemon describe response: ${daemon_describe_out}")
|
||||
endif()
|
||||
check_process(0 "Usage: vbs ide <command>.*Commands:.*generate.*query" "" ide --help)
|
||||
check_process(0 "Usage: vbs ide generate " "" ide generate --help)
|
||||
check_process(0 "Usage: vbs ide query " "" ide query --help)
|
||||
@@ -201,9 +213,11 @@ check_process(2 "" "--output is required" ide plugin)
|
||||
check_process(2 "" "missing subcommand for 'vbs ide'" ide)
|
||||
check_process(2 "" "unknown IDE kind" ide generate --editor invalid_ide)
|
||||
|
||||
execute_process(COMMAND "${VBS_REGISTRY}" --help
|
||||
RESULT_VARIABLE reg_code OUTPUT_VARIABLE reg_out ERROR_VARIABLE reg_err TIMEOUT 15)
|
||||
if(NOT "${reg_code}" STREQUAL "0" OR NOT reg_out MATCHES "Usage: vbs-registry")
|
||||
message(FATAL_ERROR "vbs-registry --help failed: code=${reg_code}\nstdout=[${reg_out}]\nstderr=[${reg_err}]")
|
||||
if(VBS_REGISTRY)
|
||||
execute_process(COMMAND "${VBS_REGISTRY}" --help
|
||||
RESULT_VARIABLE reg_code OUTPUT_VARIABLE reg_out ERROR_VARIABLE reg_err TIMEOUT 15)
|
||||
if(NOT "${reg_code}" STREQUAL "0" OR NOT reg_out MATCHES "Usage: vbs-registry")
|
||||
message(FATAL_ERROR "vbs-registry --help failed: code=${reg_code}\nstdout=[${reg_out}]\nstderr=[${reg_err}]")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "CLI and auto-generated Argparse help contracts verified (including daemon describe round-trip)")
|
||||
@@ -292,7 +292,9 @@ VOID_TEST(CoreEngineTests, state_store_cas_corruption_recovery_and_gc) {
|
||||
|
||||
// Corrupt blob1 on disk and verify lookup detects corruption!
|
||||
const auto blob_path = store->cas_blob_path(blob1->sha256);
|
||||
(void)::chmod(blob_path.c_str(), 0644);
|
||||
std::error_code perm_ec;
|
||||
std::filesystem::permissions(blob_path, std::filesystem::perms::owner_write,
|
||||
std::filesystem::perm_options::add, perm_ec);
|
||||
write_text_file(blob_path, "CORRUPTED_BYTES!!");
|
||||
Void::Testing::expect(!store->verify_blob(blob1->sha256).value_or(true));
|
||||
auto lookup = store->lookup_action("good_key");
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
# Captured output must be plain text: the CLI colorizes help when colors are allowed.
|
||||
set(ENV{NO_COLOR} "1")
|
||||
|
||||
function(expect_json expected)
|
||||
string(JSON actual GET "${graph}" ${ARGN})
|
||||
if(NOT "${actual}" STREQUAL "${expected}")
|
||||
@@ -51,17 +54,17 @@ foreach(profile IN ITEMS debug release)
|
||||
expect_json(static_library targets 4 kind)
|
||||
expect_json(vbs-registry targets 5 name)
|
||||
expect_json(executable targets 5 kind)
|
||||
expect_json(vbs_self_smoke targets 6 name)
|
||||
expect_json(vbs_registry_tests targets 6 name)
|
||||
expect_json(test targets 6 kind)
|
||||
expect_json(vbs_benchmarks targets 7 name)
|
||||
expect_json(executable targets 7 kind)
|
||||
expect_json(vbs_sdk_tests targets 8 name)
|
||||
expect_json(test targets 8 kind)
|
||||
expect_json(vbs_core_tests targets 9 name)
|
||||
expect_json(vbs_self_smoke targets 7 name)
|
||||
expect_json(test targets 7 kind)
|
||||
expect_json(vbs_benchmarks targets 8 name)
|
||||
expect_json(executable targets 8 kind)
|
||||
expect_json(vbs_sdk_tests targets 9 name)
|
||||
expect_json(test targets 9 kind)
|
||||
expect_json(vbs_v1_tests targets 10 name)
|
||||
expect_json(vbs_core_tests targets 10 name)
|
||||
expect_json(test targets 10 kind)
|
||||
expect_json(vbs_registry_tests targets 11 name)
|
||||
expect_json(vbs_v1_tests targets 11 name)
|
||||
expect_json(test targets 11 kind)
|
||||
expect_json(vbs_selfhost_tests targets 12 name)
|
||||
expect_json(test targets 12 kind)
|
||||
@@ -73,7 +76,7 @@ foreach(profile IN ITEMS debug release)
|
||||
endif()
|
||||
endforeach()
|
||||
expect_json(git dependencies 0 source kind)
|
||||
expect_json(0002e74a7da94a756f55a4a5574d20b77736c185 dependencies 0 source revision)
|
||||
expect_json(482a3ea46b0050ec07f5063fd319e66180b4d2e4 dependencies 0 source revision)
|
||||
expect_json(native dependencies 0 builder)
|
||||
string(JSON option_type TYPE "${graph}" dependencies 0 options BUILD_SHARED_LIBS)
|
||||
if(NOT option_type STREQUAL "BOOLEAN")
|
||||
|
||||
@@ -66,16 +66,17 @@ VOID_TEST(ExampleContexts, example_records_sources_links_and_pin) {
|
||||
std::string{"VoidBuildCore"});
|
||||
Void::Testing::expect_eq(project.targets().at(4).name, std::string{"VoidBuildRegistry"});
|
||||
Void::Testing::expect_eq(project.targets().at(5).name, std::string{"vbs-registry"});
|
||||
Void::Testing::expect_eq(project.targets().at(6).name, std::string{"vbs_self_smoke"});
|
||||
Void::Testing::expect_eq(project.targets().at(6).name, std::string{"vbs_registry_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(6).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(7).name, std::string{"vbs_benchmarks"});
|
||||
Void::Testing::expect_eq(project.targets().at(8).name, std::string{"vbs_sdk_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(8).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(9).name, std::string{"vbs_core_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(10).name, std::string{"vbs_v1_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(11).name, std::string{"vbs_registry_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(7).name, std::string{"vbs_self_smoke"});
|
||||
Void::Testing::expect_eq(project.targets().at(7).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(8).name, std::string{"vbs_benchmarks"});
|
||||
Void::Testing::expect_eq(project.targets().at(9).name, std::string{"vbs_sdk_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(9).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(10).name, std::string{"vbs_core_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(11).name, std::string{"vbs_v1_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(12).name, std::string{"vbs_selfhost_tests"});
|
||||
Void::Testing::expect_eq(project.dependencies().at(0).revision,
|
||||
std::string{"0002e74a7da94a756f55a4a5574d20b77736c185"});
|
||||
std::string{"482a3ea46b0050ec07f5063fd319e66180b4d2e4"});
|
||||
Void::Testing::expect_eq(project.dependencies().at(0).builder, std::string{"native"});
|
||||
}
|
||||
+13
-2
@@ -3688,12 +3688,23 @@ VOID_TEST(FullV1Tests, track_b3_live_conan_provider_install) {
|
||||
const char *previous_home = std::getenv("CONAN_HOME");
|
||||
const std::string saved_home = previous_home == nullptr ? std::string{} : previous_home;
|
||||
const bool had_home = previous_home != nullptr;
|
||||
(void)::setenv("CONAN_HOME", conan_home.c_str(), 1);
|
||||
const auto set_env = [](const char *name, const char *value) {
|
||||
#if defined(_WIN32)
|
||||
(void)_putenv_s(name, value);
|
||||
#else
|
||||
(void)::setenv(name, value, 1);
|
||||
#endif
|
||||
};
|
||||
set_env("CONAN_HOME", conan_home.string().c_str());
|
||||
const auto restore_home = Void::Scope::on_exit([&] {
|
||||
if (had_home) {
|
||||
(void)::setenv("CONAN_HOME", saved_home.c_str(), 1);
|
||||
set_env("CONAN_HOME", saved_home.c_str());
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
(void)_putenv_s("CONAN_HOME", "");
|
||||
#else
|
||||
(void)::unsetenv("CONAN_HOME");
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -91,7 +91,11 @@ VOID_TEST(SelfHostTests, strict_native_selfhost_voidlibrary_and_sdk_without_cmak
|
||||
write_file(
|
||||
trap_bin / "cmake",
|
||||
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN STRICT NATIVE STAGE' >&2\nexit 99\n");
|
||||
#if defined(_WIN32)
|
||||
return; // The cmake trap is a POSIX shell script.
|
||||
#else
|
||||
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
|
||||
#endif
|
||||
|
||||
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
|
||||
Toolchain::host_architecture_name());
|
||||
@@ -267,7 +271,11 @@ VOID_TEST(SelfHostTests, strict_native_full_vbs_stage1_to_stage2_without_cmake)
|
||||
write_file(
|
||||
trap_bin / "cmake",
|
||||
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN STRICT SELF-HOST STAGE' >&2\nexit 99\n");
|
||||
#if defined(_WIN32)
|
||||
return; // The cmake trap is a POSIX shell script.
|
||||
#else
|
||||
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
|
||||
#endif
|
||||
|
||||
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
|
||||
Toolchain::host_architecture_name());
|
||||
@@ -472,7 +480,11 @@ VOID_TEST(SelfHostTests, reproducible_stage2_equals_stage3_artifacts_across_buil
|
||||
const auto trap_bin = tmp / "trap_bin";
|
||||
write_file(trap_bin / "cmake",
|
||||
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN REPRO STAGE' >&2\nexit 99\n");
|
||||
#if defined(_WIN32)
|
||||
return; // The cmake trap is a POSIX shell script.
|
||||
#else
|
||||
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
|
||||
#endif
|
||||
|
||||
std::string trapped_path = trap_bin.string();
|
||||
if (const char *old_path = std::getenv("PATH")) {
|
||||
|
||||
Reference in new issue
Block a user