Skip to content

Commit

Permalink
Respect 'static' attribute on ndll haxelib entry and define haxelib l…
Browse files Browse the repository at this point in the history
…ibname_static_link. Do not allow GL.hx with nme_no_ogl. Provide empty dll name when linking statically
  • Loading branch information
hughsando committed Dec 31, 2024
1 parent 260840e commit a677cad
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/nme/Loader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Loader
{
#if nme_static_link
return Lib.load(moduleName, func, args);
#end
#else

if (moduleInit)
{
Expand Down Expand Up @@ -145,6 +145,7 @@ class Loader
#end

return result;
#end
}

#if neko
Expand Down
4 changes: 4 additions & 0 deletions src/nme/PrimeLoader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

2 changes: 2 additions & 0 deletions src/nme/gl/GL.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
10 changes: 7 additions & 3 deletions tools/nme/src/project/NMEProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -869,7 +874,6 @@ class NMEProject
haxedefs.set("lime_legacy","1");
}
haxeflags.push("--remap openfl:nme");
addLib("nme","",false);
}

if (export!=null && export!="")
Expand Down
6 changes: 4 additions & 2 deletions tools/nme/src/project/NMMLParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -888,8 +888,10 @@ class NMMLParser
if (element.has.version)
version = substitute(element.att.version);

var isStatic:Null<Bool> = 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":
Expand Down

0 comments on commit a677cad

Please sign in to comment.