WindowsPlatform: Visual Studio HashLink/C build

Currently required to run in Visual Studio Developer command prompt
This commit is contained in:
Josh Tynjala
2023-11-17 15:15:21 -08:00
parent c81591c887
commit 0a83f5c61f
2 changed files with 46 additions and 8 deletions

View File

@@ -98,8 +98,13 @@ class HashlinkHelper
{ {
switch Path.extension(file) switch Path.extension(file)
{ {
case "hash", "lib", "pdb", "ilk", "exp": case "hash", "pdb", "ilk", "exp":
System.deleteFile(file); System.deleteFile(file);
case "lib":
if (platform != WINDOWS)
{
System.deleteFile(file);
}
default: default:
} }
} }

View File

@@ -297,6 +297,8 @@ class WindowsPlatform extends PlatformTarget
{ {
ProjectHelper.copyLibrary(project, ndll, "Windows" + (is64 ? "64" : ""), "", ".hdll", applicationDirectory, project.debug, ProjectHelper.copyLibrary(project, ndll, "Windows" + (is64 ? "64" : ""), "", ".hdll", applicationDirectory, project.debug,
targetSuffix); targetSuffix);
ProjectHelper.copyLibrary(project, ndll, "Windows" + (is64 ? "64" : ""), "", ".lib", applicationDirectory, project.debug,
".lib");
} }
else else
{ {
@@ -335,20 +337,51 @@ class WindowsPlatform extends PlatformTarget
if (project.targetFlags.exists("hlc")) if (project.targetFlags.exists("hlc"))
{ {
var command = ["gcc", "-O3", "-o", executablePath, "-std=c11", "-Wl,-subsystem,windows", "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c"), "C:/Windows/System32/dbghelp.dll"]; var command:Array<String> = null;
for (file in System.readDirectory(applicationDirectory)) if (project.targetFlags.exists("gcc"))
{ {
switch Path.extension(file) command = ["gcc", "-O3", "-o", executablePath, "-std=c11", "-Wl,-subsystem,windows", "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c"), "C:/Windows/System32/dbghelp.dll"];
for (file in System.readDirectory(applicationDirectory))
{ {
case "dll", "hdll": switch Path.extension(file)
// ensure the executable knows about every library {
command.push(file); case "dll", "hdll":
default: // ensure the executable knows about every library
command.push(file);
default:
}
} }
} }
else
{
command = ["cl.exe", "/Ox", "/Fe:" + executablePath, "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c")];
for (file in System.readDirectory(applicationDirectory))
{
switch Path.extension(file)
{
case "lib":
// ensure the executable knows about every library
command.push(file);
default:
}
}
command.push("/link");
command.push("/subsystem:windows");
}
System.runCommand("", command.shift(), command); System.runCommand("", command.shift(), command);
} }
for (file in System.readDirectory(applicationDirectory))
{
switch Path.extension(file)
{
case "lib":
// lib files required only for hlc compilation
System.deleteFile(file);
default:
}
}
var iconPath = Path.combine(applicationDirectory, "icon.ico"); var iconPath = Path.combine(applicationDirectory, "icon.ico");
if (IconHelper.createWindowsIcon(icons, iconPath) && System.hostPlatform == WINDOWS) if (IconHelper.createWindowsIcon(icons, iconPath) && System.hostPlatform == WINDOWS)