Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cross compiling Windows projects with MinGW #1661

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lime/system/System.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import sys.io.Process;
@:access(lime._internal.backend.native.NativeCFFI)
@:access(lime.system.Display)
@:access(lime.system.DisplayMode)
#if (cpp && windows && !HXCPP_MINGW && !lime_disable_gpu_hint)
#if (cpp && windows && !lime_disable_gpu_hint)
@:cppFileCode('
#if defined(HX_WINDOWS)
#if defined(HX_WINDOWS) && !defined(__MINGW32__)
extern "C" {
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
_declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/lime/tools/ProjectXMLParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ProjectXMLParser extends HXProject
{
defines.set("native", "1");

if (target == Platform.WINDOWS)
if (target == Platform.WINDOWS && targetFlags.exists("mingw"))
{
defines.set("targetType", "cpp");
defines.set("cpp", "1");
Expand Down
20 changes: 19 additions & 1 deletion tools/platforms/WindowsPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class WindowsPlatform extends PlatformTarget
{
targetType = "winjs";
}
else if (project.targetFlags.exists("neko") || project.target != cast System.hostPlatform)
else if (project.targetFlags.exists("neko"))
{
targetType = "neko";
}
Expand Down Expand Up @@ -496,6 +496,24 @@ class WindowsPlatform extends PlatformTarget
CPPHelper.compile(project, targetDirectory + "/obj", flags);

System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-debug" : "") + ".exe", executablePath);

if (project.targetFlags.exists("mingw"))
{
var libraries = ["libwinpthread-1.dll", "libstdc++-6.dll"];
if (is64)
{
libraries.push("libgcc_s_seh-1.dll");
}
else
{
libraries.push("libgcc_s_dw2-1.dll");
}

for (library in libraries)
{
System.copyIfNewer(targetDirectory + "/obj/" + library, Path.combine(applicationDirectory, library));
}
}
}
else
{
Expand Down