From 6e19e26f45564e87cd5b90a1b3cb7574c61189f7 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 3 Nov 2023 09:38:42 -0700 Subject: [PATCH] HL/C on Linux --- tools/platforms/LinuxPlatform.hx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index d032080f1..9d1ac90bc 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -224,6 +224,23 @@ class LinuxPlatform extends PlatformTarget if (noOutput) return; HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath, is64); + + if (project.targetFlags.exists("hlc")) + { + var command = ["gcc", "-O3", "-o", executablePath, "-std=c11", "-Wl,-rpath,$ORIGIN", "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c"), "-L", applicationDirectory]; + for (file in System.readDirectory(applicationDirectory)) + { + switch Path.extension(file) + { + case "so", "hdll": + // ensure the executable knows about every library + command.push("-l:" + Path.withoutDirectory(file)); + default: + } + } + command.push("-lm"); + System.runCommand("", command.shift(), command); + } } else if (targetType == "nodejs") { @@ -350,7 +367,7 @@ class LinuxPlatform extends PlatformTarget context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n"; context.NODE_FILE = targetDirectory + "/bin/ApplicationMain.js"; - context.HL_FILE = targetDirectory + "/obj/ApplicationMain.hl"; + context.HL_FILE = targetDirectory + "/obj/ApplicationMain" + (project.defines.exists("hlc") ? ".c" : ".hl"); context.CPP_DIR = targetDirectory + "/obj/"; context.BUILD_DIR = project.app.path + "/linux" + (is64 ? "64" : "") + (isRaspberryPi ? "-rpi" : ""); context.WIN_ALLOW_SHADERS = false;