Grabbing geo files over http instead of requiring submodule

This commit is contained in:
jaburns
2020-10-10 13:25:50 -06:00
parent b7d546099d
commit f7e141bdf1
+20 -24
View File
@@ -1,8 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import os import os
import subprocess
import shutil import shutil
import requests
GEO_URL = "https://raw.githubusercontent.com/n64decomp/sm64/06ec56df7f951f88da05f468cdcacecba496145a/actors/mario/geo.inc.c"
MODEL_URL = "https://raw.githubusercontent.com/n64decomp/sm64/06ec56df7f951f88da05f468cdcacecba496145a/actors/mario/model.inc.c"
geo_inc_c_header = """ geo_inc_c_header = """
#include "../include/sm64.h" #include "../include/sm64.h"
@@ -44,38 +46,32 @@ geo_inc_h = """
extern void *mario_geo_ptr; extern void *mario_geo_ptr;
""" """
anim_data_h = """ model_inc_h = """
#pragma once #pragma once
#include "../include/types.h"
extern void *mario_anims_ptr; #include "../include/PR/gbi.h"
"""
anim_data_c_footer = """
void *mario_anims_ptr = &gMarioAnims;
""" """
def main(): def main():
os.chdir(os.path.dirname(sys.argv[0])) global model_inc_h
if os.path.exists("src/mario/geo.inc.c") and os.path.exists("src/mario/model.inc.c") \
and os.path.exists("src/mario/geo.inc.h") and os.path.exists("src/mario/model.inc.h"):
return;
shutil.rmtree("src/mario", ignore_errors=True) shutil.rmtree("src/mario", ignore_errors=True)
os.makedirs("src/mario", exist_ok=True) os.makedirs("src/mario", exist_ok=True)
geo_inc_c = "" print("Downloading " + GEO_URL)
model_inc_c = "" geo_inc_c = requests.get(GEO_URL).text
model_inc_h_lines = [ print("Downloading " + MODEL_URL)
"#pragma once", model_inc_c = requests.get(MODEL_URL).text
'#include "../include/types.h"',
'#include "../include/PR/gbi.h"'
]
with open("sm64-port/actors/mario/geo.inc.c", "r") as file: lines = model_inc_c.splitlines()
geo_inc_c = file.read()
with open("sm64-port/actors/mario/model.inc.c", "r") as file:
lines = file.read().splitlines()
for line in lines: for line in lines:
if line.startswith("const "): if line.startswith("const "):
model_inc_h_lines.append("extern " + line.replace(" = {", ";")) model_inc_h += "\nextern " + line.replace(" = {", ";")
lines = [ x.replace("#include", "//#include") for x in lines ] lines = [ x.replace("#include", "//#include") for x in lines ]
lines.insert(0, "#include \"../model_hack.h\"") lines.insert(0, "#include \"../model_hack.h\"")
@@ -88,7 +84,7 @@ def main():
file.write(model_inc_c) file.write(model_inc_c)
with open("src/mario/model.inc.h", "w") as file: with open("src/mario/model.inc.h", "w") as file:
file.write("\n".join(model_inc_h_lines)) file.write(model_inc_h)
with open("src/mario/geo.inc.h", "w") as file: with open("src/mario/geo.inc.h", "w") as file:
file.write(geo_inc_h) file.write(geo_inc_h)