diff --git a/.gitignore b/.gitignore index fe0ba3eba..37e1b844d 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/project/BuildHashlink.xml b/project/BuildHashlink.xml index 06d9e1719..b0a8e0f12 100644 --- a/project/BuildHashlink.xml +++ b/project/BuildHashlink.xml @@ -347,9 +347,9 @@ - + diff --git a/src/lime/tools/HashlinkHelper.hx b/src/lime/tools/HashlinkHelper.hx index ddc3adfae..2a23b859e 100644 --- a/src/lime/tools/HashlinkHelper.hx +++ b/src/lime/tools/HashlinkHelper.hx @@ -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")) { diff --git a/templates/bin/hl/windows/msvcr120.dll b/templates/bin/hl/windows/msvcr120.dll deleted file mode 100644 index c58afec39..000000000 Binary files a/templates/bin/hl/windows/msvcr120.dll and /dev/null differ diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index 00dab4a36..f1b98633f 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -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") { diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 6b5d867ef..ac655a0d0 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -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") { diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 6d6ef3094..46433c6e9 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -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,45 +634,49 @@ class WindowsPlatform extends PlatformTarget // } var commands = []; - - if (!targetFlags.exists("64") - && (command == "rebuild" || System.hostArchitecture == X86 || (targetType != "cpp" && targetType != "winrt"))) + if (targetType == "hl") { - if (targetType == "winrt") + // default to 64 bit, just like upstream Hashlink releases + if (!targetFlags.exists("32") && (System.hostArchitecture == X64 || targetFlags.exists("64"))) { - 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"]); - } - } - - // TODO: Compiling with -Dfulldebug overwrites the same "-debug.pdb" - // as previous Windows builds. For now, force -64 to be done last - // so that it can be debugged in a default "rebuild" - - if (!targetFlags.exists("32") - && System.hostArchitecture == X64 - && (command != "rebuild" || targetType == "cpp" || targetType == "hl" || 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"]); + commands.push(["-Dwindows", "-DHXCPP_M32", "-Dhashlink"]); + } + } + else + { + if (!targetFlags.exists("64") + && (command == "rebuild" || System.hostArchitecture == X86 || (targetType != "cpp" && targetType != "winrt"))) + { + if (targetType == "winrt") + { + commands.push(["-Dwinrt", "-DHXCPP_M32"]); + } + else + { + commands.push(["-Dwindows", "-DHXCPP_M32"]); + } + } + + // TODO: Compiling with -Dfulldebug overwrites the same "-debug.pdb" + // as previous Windows builds. For now, force -64 to be done last + // so that it can be debugged in a default "rebuild" + + if (!targetFlags.exists("32") + && System.hostArchitecture == X64 + && (command != "rebuild" || targetType == "cpp" || targetType == "winrt")) + { + if (targetType == "winrt") + { + commands.push(["-Dwinrt", "-DHXCPP_M64"]); + } + else + { + commands.push(["-Dwindows", "-DHXCPP_M64"]); + } } }