feat(toolchain): cross-compile Windows targets with MinGW and run tests under Wine
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 4s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-05 04:47:18 +03:00
1 parent 70483492aa
commit a808596462
8 files changed
+157 -31

No files matched your search

+32 -7
View File
@@ -39,13 +39,13 @@
#include <Void/Log/Formatter.hpp>
#include <Void/Log/Log.hpp>
#include <Void/Log/LoggingAdapter.hpp>
#include <unistd.h>
#include <Void/System/SignalWatcher.hpp>
#include <Void/System/TempDir.hpp>
#include <Void/Text/Semver.hpp>
#include <Void/Text/Str.hpp>
#include <Void/Text/Url.hpp>
#include <Void/Time/Stopwatch.hpp>
#include <unistd.h>
#include <algorithm>
#include <array>
@@ -136,7 +136,8 @@ class ConsoleLogGuard {
}
logger_ = std::make_unique<Void::Logging::ConsoleLogger>();
if (color_enabled()) {
auto formatter = std::make_shared<Void::Logging::PatternFormatter>("[{level:,auto}] {message}");
auto formatter =
std::make_shared<Void::Logging::PatternFormatter>("[{level:,auto}] {message}");
formatter->set_color_policy(Void::Logging::ColorPolicy::defaults());
logger_->set_formatter(std::move(formatter));
}
@@ -373,6 +374,8 @@ struct BuildCmdOptions {
std::optional<std::filesystem::path> state_dir;
std::vector<std::string> trusted_public_keys;
std::vector<std::string> trusted_key_files;
std::optional<std::string> target_os_arg;
std::optional<std::string> target_arch_arg;
bool publish_editor_selection{true};
bool no_cache{false};
bool locked{false};
@@ -491,13 +494,19 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
return 1;
}
const std::string target_os = opts.target_os_arg.value_or(Toolchain::host_os_name());
const std::string target_arch =
opts.target_arch_arg.value_or(Toolchain::host_architecture_name());
const bool windows_cross_target =
Void::Str::to_lower_ascii(target_os) == "windows" &&
Void::Str::to_lower_ascii(Toolchain::host_os_name()) != "windows";
bool all_ok = true;
for (const auto &prof_name : opts.profiles) {
const auto prof_sw = Void::Time::Stopwatch::started();
ProfileContext ctx;
try {
ctx = profs->resolve(prof_name, compiler_override, Toolchain::host_os_name(),
Toolchain::host_architecture_name());
ctx = profs->resolve(prof_name, compiler_override, target_os, target_arch);
} catch (const std::exception &ex) {
std::cerr << "vbs: " << ex.what() << '\n';
return 2;
@@ -810,7 +819,19 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
Void::Log::info("Test", "[{}] Running test target '{}'...", prof_name, t.name);
const auto tsw = Void::Time::Stopwatch::started();
Platform::ProcessRequest treq;
treq.executable = t.primary_outputs.front();
if (windows_cross_target) {
// Cross-built Windows test binaries execute under Wine (Track C3 Wine-first).
auto wine = Platform::resolve_executable("wine");
if (!wine) {
std::cerr << "vbs test: Windows target tests require 'wine' in PATH\n";
all_ok = false;
continue;
}
treq.executable = *wine;
treq.arguments = {t.primary_outputs.front().string()};
} else {
treq.executable = t.primary_outputs.front();
}
treq.working_directory = project_root;
treq.timeout = std::chrono::seconds{300};
auto tres = Platform::run_supervised(treq);
@@ -1703,8 +1724,8 @@ int execute_install_command(const InstallCmdOptions &opts) {
iopts.export_native_metadata = !opts.no_native_export;
iopts.bundle_runtime_dependencies = opts.bundle_dependencies;
if (opts.archive_format_arg != "tar" && opts.archive_format_arg != "sh") {
std::cerr << "vbs install: unsupported --archive-format '"
<< opts.archive_format_arg << "' (expected tar or sh)\n";
std::cerr << "vbs install: unsupported --archive-format '" << opts.archive_format_arg
<< "' (expected tar or sh)\n";
return 2;
}
if (opts.archive_arg && !opts.archive_arg->empty()) {
@@ -2729,6 +2750,10 @@ int main(int argc, char **argv) {
.option_many("--target", "-t", "Target to build/test", build_opts.targets)
.option("--compiler", "", "Override compiler family (gcc|clang)",
build_opts.compiler_arg)
.option("--target-os", "", "Target operating system (default: host, e.g. windows)",
build_opts.target_os_arg)
.option("--target-arch", "", "Target architecture (default: host, e.g. x86_64)",
build_opts.target_arch_arg)
.option("--editor-profile", "", "Editor profile for compile_commands.json",
build_opts.editor_profile)
.option_many("--build-source", "", "Additional build description source",