Add support for dumb natives

This commit is contained in:
Fierelier 2021-06-16 12:55:30 +02:00
parent 35f0dfb892
commit bc16466585

View File

@ -173,6 +173,9 @@ def processVersion(versionsPath,libraryPath,nativePath,version):
if lv["osName"] == "macos" and native == False and "natives-osx" in library["downloads"]["classifiers"]: if lv["osName"] == "macos" and native == False and "natives-osx" in library["downloads"]["classifiers"]:
native = library["downloads"]["classifiers"]["natives-osx"] native = library["downloads"]["classifiers"]["natives-osx"]
if native == False:
continue
elif "name" in library: elif "name" in library:
# Dumb libraries # Dumb libraries
if not "url" in library: library["url"] = "https://libraries.minecraft.net" if not "url" in library: library["url"] = "https://libraries.minecraft.net"
@ -180,7 +183,24 @@ def processVersion(versionsPath,libraryPath,nativePath,version):
while len(l["url"]) > 0 and l["url"][-1] == "/": l["url"] = l["url"][:-1] while len(l["url"]) > 0 and l["url"][-1] == "/": l["url"] = l["url"][:-1]
l["url"] = l["url"] + "/" + l["filePath"] l["url"] = l["url"] + "/" + l["filePath"]
l["filePathOS"] = p(libraryPath,l["filePath"].replace("/",os.path.sep)) if "natives" in library:
input(library)
l["type"] = "native"
if lv["osName"] in library["natives"]:
native = library["natives"][lv["osName"]]
if lv["osName"] == "macos" and native == False and "osx" in library["natives"]:
native = library["natives"]["osx"]
if native == False:
continue
l["filePath"] = l["filePath"][:-4] + "-" + native + ".jar"
l["url"] = l["url"][:-4] + "-" + native + ".jar"
l["filePathOS"] = p(nativePath,l["filePath"].replace("/",os.path.sep))
#input(l)
else:
l["filePathOS"] = p(libraryPath,l["filePath"].replace("/",os.path.sep))
libraries.append(l) libraries.append(l)
if os.path.isfile(p(versionPath,version + ".jar")): if os.path.isfile(p(versionPath,version + ".jar")):
@ -318,6 +338,9 @@ def main():
for library in libraries: for library in libraries:
if library["type"] == "native": if library["type"] == "native":
if "rules" in library and checkRules(library["rules"]) == "disallow": continue if "rules" in library and checkRules(library["rules"]) == "disallow": continue
if not os.path.isfile(library["filePathOS"]):
print("Native not found: " +library["path"]+ ":" +library["version"])
continue
proc = subprocess.Popen(["7z","x",library["filePathOS"],"-o" +nativesOutPath,"-aos"],stdout=subprocess.DEVNULL) proc = subprocess.Popen(["7z","x",library["filePathOS"],"-o" +nativesOutPath,"-aos"],stdout=subprocess.DEVNULL)
rtn = proc.wait() rtn = proc.wait()
if rtn != 0: raise Exception("process","return code isn't 0") if rtn != 0: raise Exception("process","return code isn't 0")
@ -388,7 +411,7 @@ def main():
pkwargs = { pkwargs = {
"stdout": subprocess.DEVNULL, "stdout": subprocess.DEVNULL,
"stdin": subprocess.DEVNULL, "stdin": subprocess.DEVNULL,
"stderr": subprocess.DEVNULL, "stderr": subprocess.DEVNULL
} }
if lv["osName"] == "windows": pkwargs["creationflags"] = 0x00000008 if lv["osName"] == "windows": pkwargs["creationflags"] = 0x00000008
subprocess.Popen([lv["java"] + "w"] + args,**pkwargs) subprocess.Popen([lv["java"] + "w"] + args,**pkwargs)