This commit is contained in:
2026-08-06 00:29:37 +02:00
parent 31d458f8b7
commit fedc18c3ca
19 changed files with 779 additions and 131 deletions

View File

@@ -25,6 +25,9 @@ class AssetMacro {
Context.warning("AssetMacro is running", Context.currentPos());
#end
// A compilation server can retain macro statics between builds.
assetMap = new Map();
// Get current build context
var fields = Context.getBuildFields();
var localClass = Context.getLocalClass().get();
@@ -41,6 +44,7 @@ class AssetMacro {
// Create directories if they don't exist
createDirectory(manifestDir);
createDirectory(assetsOutputDir);
copyLimeNativeLibrary(outputDir);
// Process asset fields
for (field in fields) {
@@ -237,6 +241,44 @@ class AssetMacro {
}
}
/** Stage the Lime CFFI module that matches the selected haxelib version. */
private static function copyLimeNativeLibrary(outputDir:String):Void {
var platformDirectory = if (Context.defined("linux")) {
"Linux64";
} else if (Context.defined("windows")) {
"Windows64";
} else if (Context.defined("mac")) {
Context.defined("arm64") ? "MacArm64" : "Mac64";
} else {
return;
}
var limeRoot:String = null;
for (classPath in Context.getClassPath()) {
var normalized = classPath.split("\\").join("/");
if (normalized.indexOf("/lime/") != -1 && normalized.endsWith("/src/")) {
limeRoot = normalized.substr(0, normalized.length - 4);
break;
}
}
if (limeRoot == null) {
Context.warning("Could not locate Lime native library from the compiler class path", Context.currentPos());
return;
}
var source = limeRoot + "ndll/" + platformDirectory + "/lime.ndll";
if (!FileSystem.exists(source)) {
Context.warning("Lime native library not found: " + source, Context.currentPos());
return;
}
try {
File.copy(source, outputDir + "/lime.ndll");
} catch (e:Dynamic) {
Context.error("Failed to copy Lime native library: " + e, Context.currentPos());
}
}
private static function findAssetsMeta(metaAccess:Array<MetadataEntry>):MetadataEntry {
if (metaAccess == null) return null;