prepare for HL/C

This commit is contained in:
Josh Tynjala
2023-10-19 15:00:08 -07:00
parent 21e8e619c3
commit 75bc87102b
3 changed files with 59 additions and 2 deletions

View File

@@ -348,6 +348,10 @@ jobs:
haxelib run lime rebuild tools -nocolor -verbose -nocffi
haxelib run lime setup -alias -y -nocffi
cp project/lib/hashlink/other/osx/entitlements.xml templates/bin/hl/entitlements.xml
mkdir templates/bin/hl/include
cp project/lib/hashlink/src/hlc.h templates/bin/hl/include/hlc.h
cp project/lib/hashlink/src/hl.h templates/bin/hl/include/hl.h
cp project/lib/hashlink/src/hlc_main.c templates/bin/hl/include/hlc_main.c
- uses: actions/download-artifact@v3
with:
name: Android-NDLL

View File

@@ -1,5 +1,6 @@
package lime.tools;
import hxp.Haxelib;
import hxp.Log;
import sys.FileSystem;
import lime.tools.ConfigHelper;
@@ -32,10 +33,25 @@ class HashlinkHelper
{
System.recursiveCopyTemplate(project.templatePaths, 'bin/hl/$bindir', applicationDirectory);
System.renameFile(Path.combine(applicationDirectory, "hl" + (project.target == WINDOWS ? ".exe" : "")), executablePath);
if (project.targetFlags.exists("hlc"))
{
var limeDirectory = Haxelib.getPath(new Haxelib("lime"), true);
var includeDirectory = sys.FileSystem.exists(Path.combine(limeDirectory, "project"))
? Path.combine(limeDirectory, "project/lib/hashlink/src")
: Path.combine(limeDirectory, "templates/bin/hl/include");
System.copyFile(Path.combine(includeDirectory, "hlc.h"), Path.combine(targetDirectory, "obj/hlc.h"), null, false);
System.copyFile(Path.combine(includeDirectory, "hl.h"), Path.combine(targetDirectory, "obj/hl.h"), null, false);
System.copyFile(Path.combine(includeDirectory, "hlc_main.c"), Path.combine(targetDirectory, "obj/hlc_main.c"), null, false);
}
}
else
{
System.copyFile(Path.combine(hlPath, "hl" + (platform == WINDOWS ? ".exe" : "")), executablePath);
if (!project.targetFlags.exists("hlc"))
{
System.copyFile(Path.combine(hlPath, "hl" + (platform == WINDOWS ? ".exe" : "")), executablePath);
}
if (platform == WINDOWS)
{
System.copyFile(Path.combine(hlPath, "libhl.dll"), Path.combine(applicationDirectory, "libhl.dll"));
@@ -66,6 +82,14 @@ class HashlinkHelper
{
System.copyFile(file, Path.combine(applicationDirectory, Path.withoutDirectory(file)));
}
if (project.targetFlags.exists("hlc"))
{
for (file in System.readDirectory(Path.combine(hlPath, "include")))
{
System.copyFile(file, Path.combine(targetDirectory, Path.combine("obj", Path.withoutDirectory(file))));
}
}
}
// make sure no hxcpp hash files or MSVC build artifacts remain
@@ -79,6 +103,31 @@ class HashlinkHelper
default:
}
}
System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat"));
if (project.targetFlags.exists("hlc"))
{
if (sys.FileSystem.exists(executablePath))
{
System.deleteFile(executablePath);
}
var appMainCPath = Path.combine(targetDirectory, "obj/ApplicationMain.c");
var appMainCText = System.readText(appMainCPath);
var index = appMainCText.indexOf("#ifndef HL_MAKE");
appMainCText = appMainCText.substr(0, index) + "
// --------- START LIME HL/C INJECTED CODE --------- //
#ifdef BIG_ENDIAN
#undef BIG_ENDIAN
#endif
#ifdef LITTLE_ENDIAN
#undef LITTLE_ENDIAN
#endif
// ---------- END LIME HL/C INJECTED CODE ---------- //
" + appMainCText.substr(index);
System.writeText(appMainCText, appMainCPath);
}
else
{
System.copyFile(Path.combine(targetDirectory, "obj/ApplicationMain.hl"), Path.combine(applicationDirectory, "hlboot.dat"));
}
}
}

View File

@@ -83,6 +83,10 @@ class ProjectXMLParser extends HXProject
defines.set("targetType", "hl");
defines.set("native", "1");
defines.set("hl", "1");
if (targetFlags.exists("hlc"))
{
defines.set("hlc", "1");
}
}
else if (targetFlags.exists("java"))
{