feat(toolchain): cross-compile Windows targets with MinGW and run tests under Wine
This commit is contained in:
1 parent
70483492aa
commit
a808596462
8 files changed
+157
-31
No files matched your search
@@ -260,12 +260,32 @@ std::string host_architecture_name() {
|
||||
return "x86_64";
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Cross toolchain prefix for a non-host target (Track C: Windows via MinGW-w64 under Wine).
|
||||
std::string cross_compiler_prefix(const ProfileContext &context) {
|
||||
const std::string target_os = Void::Str::to_lower_ascii(context.os);
|
||||
if (target_os != "windows" || Void::Str::to_lower_ascii(host_os_name()) == "windows") {
|
||||
return {};
|
||||
}
|
||||
if (context.architecture == "aarch64" || context.architecture == "arm64") {
|
||||
return "aarch64-w64-mingw32-";
|
||||
}
|
||||
return "x86_64-w64-mingw32-";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Void::Result::Result<ToolchainCapabilities, Void::Result::Error>
|
||||
discover_and_probe(const ProfileContext &context,
|
||||
const std::optional<std::filesystem::path> &cache_dir) {
|
||||
const std::string cross_prefix = cross_compiler_prefix(context);
|
||||
std::filesystem::path requested_compiler;
|
||||
if (!context.compiler_path.empty()) {
|
||||
requested_compiler = context.compiler_path;
|
||||
} else if (!cross_prefix.empty()) {
|
||||
requested_compiler =
|
||||
cross_prefix + (context.compiler == CompilerFamily::Gcc ? "g++" : "clang++");
|
||||
} else if (context.compiler == CompilerFamily::Gcc) {
|
||||
requested_compiler = "g++";
|
||||
} else {
|
||||
@@ -280,7 +300,11 @@ discover_and_probe(const ProfileContext &context,
|
||||
}
|
||||
|
||||
std::filesystem::path requested_c_compiler =
|
||||
context.compiler == CompilerFamily::Gcc ? "gcc" : "clang";
|
||||
!cross_prefix.empty()
|
||||
? std::filesystem::path{cross_prefix +
|
||||
(context.compiler == CompilerFamily::Gcc ? "gcc" : "clang")}
|
||||
: (context.compiler == CompilerFamily::Gcc ? std::filesystem::path{"gcc"}
|
||||
: std::filesystem::path{"clang"});
|
||||
if (!context.compiler_path.empty()) {
|
||||
const std::filesystem::path cp_path{context.compiler_path};
|
||||
const std::string fname = cp_path.filename().string();
|
||||
@@ -307,7 +331,10 @@ discover_and_probe(const ProfileContext &context,
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> resolved_ar;
|
||||
if (context.compiler == CompilerFamily::Clang) {
|
||||
if (!cross_prefix.empty()) {
|
||||
resolved_ar = Platform::resolve_executable(cross_prefix + "ar");
|
||||
}
|
||||
if (!resolved_ar && context.compiler == CompilerFamily::Clang) {
|
||||
resolved_ar = Platform::resolve_executable("llvm-ar");
|
||||
}
|
||||
if (!resolved_ar) {
|
||||
|
||||
Reference in new issue
Block a user