Try to fix Windows mess a bit.

Default to 64 bit on windows too.
This commit is contained in:
Apprentice-Alchemist
2022-05-19 20:46:08 +02:00
parent b2546aac9f
commit ad70700a14
7 changed files with 70 additions and 48 deletions

5
.gitignore vendored
View File

@@ -11,10 +11,7 @@ ndll/*/*.dylib
ndll/*/*.lib
ndll/*/hl*
ndll/*/*.dll
templates/bin/hl/windows
!templates/bin/hl/windows/msvcr120.dll
templates/bin/hl/mac
templates/bin/hl/linux
templates/bin/hl/*
project/all_objs
project/obj
project/vc*.pdb

View File

@@ -347,9 +347,9 @@
<set name="LIBSUFFIX" value="dll" if="windows" />
<set name="LIBSUFFIX" value="dylib" if="mac || ios || tvos" />
<set name="LIBSUFFIX" value="so" unless="LIBSUFFIX" />
<set name="BINDIR" value="linux" if="linux" />
<!-- <set name="BINDIR" value="linux" if="linux" />
<set name="BINDIR" value="mac" if="mac" />
<set name="BINDIR" value="windows" if="windows" />
<set name="BINDIR" value="windows" if="windows" /> -->
<set name="OUTPUT_DIR" value="../templates/bin/hl" unless="OUTPUT_DIR" />

View File

@@ -1,5 +1,7 @@
package lime.tools;
import hxp.Log;
import sys.FileSystem;
import lime.tools.ConfigHelper;
import lime.tools.HXProject;
import lime.tools.Platform;
@@ -8,15 +10,25 @@ import hxp.System;
class HashlinkHelper
{
public static function copyHashlink(project:HXProject, targetDirectory:String, applicationDirectory:String, executablePath:String)
public static function copyHashlink(project:HXProject, targetDirectory:String, applicationDirectory:String, executablePath:String, ?is64 = true)
{
var platform = project.target;
var bindir = (switch project.target
{
case LINUX: "Linux";
case MAC: "Mac";
case WINDOWS: "Windows";
case var target:
Log.error('Hashlink is not supported on $target (Supported: Windows, Mac and Linux)');
Sys.exit(1);
"";
}) + (is64 ? "64" : "");
var hlPath = ConfigHelper.getConfigValue("HL_PATH");
if (hlPath == null)
{
System.recursiveCopyTemplate(project.templatePaths, 'bin/hl/$platform', applicationDirectory);
System.renameFile(Path.combine(applicationDirectory, "hl" + (platform == WINDOWS ? ".exe" : "")), executablePath);
System.recursiveCopyTemplate(project.templatePaths, 'bin/hl/$bindir', applicationDirectory);
System.renameFile(Path.combine(applicationDirectory, "hl" + (project.target == WINDOWS ? ".exe" : "")), executablePath);
}
else
{
@@ -24,7 +36,16 @@ class HashlinkHelper
if (platform == WINDOWS)
{
System.copyFile(Path.combine(hlPath, "libhl.dll"), Path.combine(applicationDirectory, "libhl.dll"));
System.copyFile(Path.combine(hlPath, "msvcr120.dll"), Path.combine(applicationDirectory, "msvcr120.dll"));
var msvcrPath = Path.combine(hlPath, "msvcr120.dll");
if (FileSystem.exists(msvcrPath))
{
System.copyFile(msvcrPath, Path.combine(applicationDirectory, "msvcr120.dll"));
}
var vcruntimePath = Path.combine(hlPath, "vcruntime.dll.dll");
if (FileSystem.exists(vcruntimePath))
{
System.copyFile(vcruntimePath, Path.combine(applicationDirectory, "vcruntime.dll"));
}
}
else if (platform == MAC || platform == IOS)
{
@@ -36,7 +57,7 @@ class HashlinkHelper
}
for (file in System.readDirectory(hlPath)
.filter(function (f) return Path.extension(f) == "hdll"
.filter(function(f) return Path.extension(f) == "hdll"
&& Path.withoutDirectory(f) != "sdl.hdll"
&& Path.withoutDirectory(f) != "openal.hdll"))
{

View File

@@ -221,7 +221,7 @@ class LinuxPlatform extends PlatformTarget
if (noOutput) return;
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath);
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath, is64);
}
else if (targetType == "nodejs")
{

View File

@@ -206,7 +206,7 @@ class MacPlatform extends PlatformTarget
if (noOutput) return;
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath);
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath, is64);
}
else if (targetType == "java")
{

View File

@@ -145,7 +145,7 @@ class WindowsPlatform extends PlatformTarget
else if (project.targetFlags.exists("hl"))
{
targetType = "hl";
is64 = false;
is64 = !project.flags.exists("32");
}
else if (project.targetFlags.exists("cppia"))
{
@@ -331,7 +331,7 @@ class WindowsPlatform extends PlatformTarget
if (noOutput) return;
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath);
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath, is64);
var iconPath = Path.combine(applicationDirectory, "icon.ico");
@@ -634,7 +634,20 @@ class WindowsPlatform extends PlatformTarget
// }
var commands = [];
if (targetType == "hl")
{
// default to 64 bit, just like upstream Hashlink releases
if (!targetFlags.exists("32") && (System.hostArchitecture == X64 || targetFlags.exists("64")))
{
commands.push(["-Dwindows", "-DHXCPP_M64", "-Dhashlink"]);
}
else
{
commands.push(["-Dwindows", "-DHXCPP_M32", "-Dhashlink"]);
}
}
else
{
if (!targetFlags.exists("64")
&& (command == "rebuild" || System.hostArchitecture == X86 || (targetType != "cpp" && targetType != "winrt")))
{
@@ -642,11 +655,6 @@ class WindowsPlatform extends PlatformTarget
{
commands.push(["-Dwinrt", "-DHXCPP_M32"]);
}
else if (targetType == "hl")
{
// TODO: Support single binary
commands.push(["-Dwindows", "-DHXCPP_M32", "-Dhashlink"]);
}
else
{
commands.push(["-Dwindows", "-DHXCPP_M32"]);
@@ -659,22 +667,18 @@ class WindowsPlatform extends PlatformTarget
if (!targetFlags.exists("32")
&& System.hostArchitecture == X64
&& (command != "rebuild" || targetType == "cpp" || targetType == "hl" || targetType == "winrt"))
&& (command != "rebuild" || targetType == "cpp" || targetType == "winrt"))
{
if (targetType == "winrt")
{
commands.push(["-Dwinrt", "-DHXCPP_M64"]);
}
else if (targetType == "hl")
{
// TODO: Support single binary
commands.push(["-Dwindows", "-DHXCPP_M64", "-Dhashlink"]);
}
else
{
commands.push(["-Dwindows", "-DHXCPP_M64"]);
}
}
}
if (targetFlags.exists("hl"))
{