From a677cad62ed7db2c7d9e61a77ac809703b668c37 Mon Sep 17 00:00:00 2001 From: Hugh Sanderson Date: Tue, 31 Dec 2024 14:56:12 +0800 Subject: [PATCH] Respect 'static' attribute on ndll haxelib entry and define haxelib libname_static_link. Do not allow GL.hx with nme_no_ogl. Provide empty dll name when linking statically --- src/nme/Loader.hx | 3 ++- src/nme/PrimeLoader.hx | 4 ++++ src/nme/gl/GL.hx | 2 ++ tools/nme/src/project/NMEProject.hx | 10 +++++++--- tools/nme/src/project/NMMLParser.hx | 6 ++++-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/nme/Loader.hx b/src/nme/Loader.hx index 1ed1b1799..2e28d57df 100644 --- a/src/nme/Loader.hx +++ b/src/nme/Loader.hx @@ -86,7 +86,7 @@ class Loader { #if nme_static_link return Lib.load(moduleName, func, args); - #end + #else if (moduleInit) { @@ -145,6 +145,7 @@ class Loader #end return result; + #end } #if neko diff --git a/src/nme/PrimeLoader.hx b/src/nme/PrimeLoader.hx index 4f7c4e838..70fed5eaa 100644 --- a/src/nme/PrimeLoader.hx +++ b/src/nme/PrimeLoader.hx @@ -6,7 +6,11 @@ class PrimeLoader { public static inline macro function load(inName2:Expr, inSig:Expr) { + #if nme_static_link + return macro nme.macros.Prime.load("", $inName2, $inSig, false); + #else return macro nme.macros.Prime.load("nme", $inName2, $inSig, false); + #end } } diff --git a/src/nme/gl/GL.hx b/src/nme/gl/GL.hx index cf471e5d8..88279b1f8 100644 --- a/src/nme/gl/GL.hx +++ b/src/nme/gl/GL.hx @@ -2,6 +2,8 @@ package nme.gl; #if nme_metal #error "GL not supported with NME_METAL" +#elseif nme_no_ogl +#error "GL not supported with nme_no_ogl" #else diff --git a/tools/nme/src/project/NMEProject.hx b/tools/nme/src/project/NMEProject.hx index 6db8fffc3..b19b206a4 100644 --- a/tools/nme/src/project/NMEProject.hx +++ b/tools/nme/src/project/NMEProject.hx @@ -730,6 +730,9 @@ class NMEProject if (name=="nme" && inStatic==null) isStatic = isStaticNme(); + if (isStatic) + haxedefs.set(name.toLowerCase() + "_static_link", "1"); + ndlls.push( new NDLL(name, base, isStatic, inHaxelibName, noCopy) ); } else if (inStatic && optionalStaticLink) @@ -742,7 +745,7 @@ class NMEProject } } - public function addLib(name:String, version:String="",inNoCopy:Bool) + public function addLib(name:String, version:String="",inNoCopy:Bool, ?inStatic:Bool) { var haxelib = findHaxelib(name); if (haxelib==null) @@ -779,7 +782,9 @@ class NMEProject raiseLib("nme"); if (name=="nme" && !hasDef("watchos") ) - addNdll("nme", haxelib.getBase(), null, "nme", inNoCopy); + { + addNdll("nme", haxelib.getBase(), inStatic, "nme", inNoCopy); + } } return haxelib; } @@ -869,7 +874,6 @@ class NMEProject haxedefs.set("lime_legacy","1"); } haxeflags.push("--remap openfl:nme"); - addLib("nme","",false); } if (export!=null && export!="") diff --git a/tools/nme/src/project/NMMLParser.hx b/tools/nme/src/project/NMMLParser.hx index fd679188f..bd7d4b762 100644 --- a/tools/nme/src/project/NMMLParser.hx +++ b/tools/nme/src/project/NMMLParser.hx @@ -873,7 +873,7 @@ class NMMLParser var base = extensionPath; if (haxelib!="") { - var lib = project.addLib(haxelib,version,nocopy); + var lib = project.addLib(haxelib,version,nocopy,isStatic); base = lib.getBase(); } if (name!="lime" && name!="openfl") @@ -888,8 +888,10 @@ class NMMLParser if (element.has.version) version = substitute(element.att.version); + var isStatic:Null = element.x.exists("static") ? parseBool(substitute(element.x.get("static"))) : null; + var nocopy = element.has.nocopy && parseBool(substitute(element.att.nocopy)); - project.addLib(name,version,nocopy); + project.addLib(name,version,nocopy,isStatic); case "launchImage", "splashScreen":