diff --git a/project/Build.xml b/project/Build.xml index f5d35a593..1a07f66b3 100644 --- a/project/Build.xml +++ b/project/Build.xml @@ -17,7 +17,7 @@ - + @@ -436,7 +436,7 @@ - + @@ -460,7 +460,7 @@ - + diff --git a/src/haxe/io/Bytes.hx b/src/haxe/io/Bytes.hx index 46c86eb9e..a9d660811 100644 --- a/src/haxe/io/Bytes.hx +++ b/src/haxe/io/Bytes.hx @@ -1060,7 +1060,7 @@ class Bytes setInt32(pos, v.low); } - public function getString(pos:Int, len:Int, ?encoding:#if (haxe_ver >= 4) haxe.io.Encoding #else Dynamic #end):String + public function getString(pos:Int, len:Int #if (!hl || haxe_ver >= 4), ?encoding:#if (haxe_ver >= 4) haxe.io.Encoding #else Dynamic #end #end):String { if (outRange(pos, len)) throw Error.OutsideBounds; @@ -1110,7 +1110,7 @@ class Bytes return new Bytes(b, length); } - public static function ofString(s:String, ?encoding:#if (haxe_ver >= 4) haxe.io.Encoding #else Dynamic #end):Bytes@:privateAccess { + public static function ofString(s:String #if (!hl || haxe_ver >= 4) , ?encoding:#if (haxe_ver >= 4) haxe.io.Encoding #else Dynamic #end #end):Bytes@:privateAccess { var size = 0; var b = s.bytes.utf16ToUtf8(0, size); return new Bytes(b, size); @@ -1121,6 +1121,7 @@ class Bytes return new Bytes(b.bytes, b.length); } + #if (!hl || haxe_ver >= 4) public static function ofHex(s:String):Bytes { var len = s.length; @@ -1138,6 +1139,7 @@ class Bytes return new Bytes(b, l); } + #end public inline static function fastGet(b:BytesData, pos:Int):Int { diff --git a/templates/bin/hl/linux/hl b/templates/bin/hl/linux/hl new file mode 100755 index 000000000..d82db7479 Binary files /dev/null and b/templates/bin/hl/linux/hl differ diff --git a/templates/bin/hl/linux/libhl.so b/templates/bin/hl/linux/libhl.so new file mode 100755 index 000000000..91f069c4c Binary files /dev/null and b/templates/bin/hl/linux/libhl.so differ diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index a838c7a56..c6a15596f 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -59,7 +59,7 @@ class LinuxPlatform extends PlatformTarget else if (project.targetFlags.exists("hl")) { targetType = "hl"; - is64 = false; + is64 = true; } else if (project.targetFlags.exists("nodejs")) { @@ -92,7 +92,13 @@ class LinuxPlatform extends PlatformTarget for (ndll in project.ndlls) { - if (isRaspberryPi) + // TODO: Support single binary for HashLink + if (targetType == "hl") + { + ProjectHelper.copyLibrary(project, ndll, "Linux" + (is64 ? "64" : ""), "", ".hdll", applicationDirectory, project + .debug, targetSuffix); + } + else if (isRaspberryPi) { ProjectHelper.copyLibrary(project, ndll, "RPi", "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dso" : ".ndll", applicationDirectory, @@ -101,8 +107,8 @@ class LinuxPlatform extends PlatformTarget else { ProjectHelper.copyLibrary(project, ndll, "Linux" + (is64 ? "64" : ""), "", - (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dso" : ".ndll", applicationDirectory, - project.debug, targetSuffix); + (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", + applicationDirectory, project.debug, targetSuffix); } } } @@ -130,8 +136,11 @@ class LinuxPlatform extends PlatformTarget if (noOutput) return; - System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", - Path.combine(applicationDirectory, project.app.file + ".hl")); + // System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", + // Path.combine(applicationDirectory, project.app.file + ".hl")); + System.recursiveCopyTemplate(project.templatePaths, "bin/hl/linux", applicationDirectory); + System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat")); + System.renameFile(Path.combine(applicationDirectory, "hl"), executablePath); } else if (targetType == "nodejs") { @@ -293,6 +302,11 @@ class LinuxPlatform extends PlatformTarget "-DHXCPP_RANLIB=arm-linux-gnueabihf-ranlib" ]); } + else if (targetFlags.exists("hl") && System.hostArchitecture == X64) + { + // TODO: Support single binary + commands.push(["-Dlinux", "-DHXCPP_M64", "-Dhashlink"]); + } else { if (!targetFlags.exists("32") && System.hostArchitecture == X64) @@ -318,11 +332,7 @@ class LinuxPlatform extends PlatformTarget arguments.push("-verbose"); } - if (targetType == "hl") - { - System.runCommand(applicationDirectory, "hl", [project.app.file + ".hl"].concat(arguments)); - } - else if (targetType == "nodejs") + if (targetType == "nodejs") { NodeJSHelper.run(project, targetDirectory + "/bin/ApplicationMain.js", arguments); } diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 075149ee5..67c942d82 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -53,7 +53,7 @@ class MacPlatform extends PlatformTarget else if (project.targetFlags.exists("hl")) { targetType = "hl"; - is64 = false; + is64 = true; } else if (project.targetFlags.exists("java")) { @@ -92,9 +92,18 @@ class MacPlatform extends PlatformTarget for (ndll in project.ndlls) { - ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "", - (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dylib" : ".ndll", executableDirectory, - project.debug, targetSuffix); + // TODO: Support single binary for HashLink + if (targetType == "hl") + { + ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "", ".hdll", applicationDirectory, project + .debug, targetSuffix); + } + else + { + ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "", + (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", + applicationDirectory, project.debug, targetSuffix); + } } } @@ -113,8 +122,11 @@ class MacPlatform extends PlatformTarget if (noOutput) return; - System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", - Path.combine(executableDirectory, project.app.file + ".hl")); + // System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl", + // Path.combine(executableDirectory, project.app.file + ".hl")); + System.recursiveCopyTemplate(project.templatePaths, "bin/hl/mac", applicationDirectory); + System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat")); + System.renameFile(Path.combine(applicationDirectory, "hl"), executablePath); } else if (targetType == "java") { @@ -254,14 +266,22 @@ class MacPlatform extends PlatformTarget { var commands = []; - if (!targetFlags.exists("32") && (command == "rebuild" || System.hostArchitecture == X64)) + if (targetFlags.exists("hl") && System.hostArchitecture == X64) { - commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64"]); + // TODO: Support single binary + commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64", "-Dhashlink"]); } - - if (!targetFlags.exists("64") && (targetFlags.exists("32") || System.hostArchitecture == X86)) + else { - commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]); + if (!targetFlags.exists("32") && (command == "rebuild" || System.hostArchitecture == X64)) + { + commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64"]); + } + + if (!targetFlags.exists("64") && (targetFlags.exists("32") || System.hostArchitecture == X86)) + { + commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]); + } } CPPHelper.rebuild(project, commands); @@ -276,11 +296,7 @@ class MacPlatform extends PlatformTarget arguments.push("-verbose"); } - if (targetType == "hl") - { - System.runCommand(applicationDirectory, "hl", [project.app.file + ".hl"].concat(arguments)); - } - else if (targetType == "nodejs") + if (targetType == "nodejs") { NodeJSHelper.run(project, executableDirectory + "/ApplicationMain.js", arguments); }