Modify build system to properly handle unreal version upgrades
This commit is contained in:
44
build.py
44
build.py
@@ -51,6 +51,20 @@ def read_if_exists(fn):
|
||||
try: return Path(fn).read_text()
|
||||
except: return ""
|
||||
|
||||
#
|
||||
# Fix a chmod bug in the Zipfile module.
|
||||
#
|
||||
|
||||
class JZipFile(zipfile.ZipFile):
|
||||
def _extract_member(self, member, targetpath, pwd):
|
||||
if not isinstance(member, zipfile.ZipInfo):
|
||||
member = self.getinfo(member)
|
||||
targetpath = super()._extract_member(member, targetpath, pwd)
|
||||
attr = member.external_attr >> 16
|
||||
if attr != 0:
|
||||
os.chmod(targetpath, attr)
|
||||
return targetpath
|
||||
|
||||
#
|
||||
# A JSON preprocessor.
|
||||
#
|
||||
@@ -191,20 +205,26 @@ def unzip_unreal_engine_and_apply_patch():
|
||||
"""
|
||||
Unzip the unreal engine source, then apply a patch.
|
||||
"""
|
||||
if not Path(UNREALENGINE).is_dir():
|
||||
zipfn = f"{INTEGRATION}/UnrealEngine.zip";
|
||||
with zipfile.ZipFile(zipfn, 'r') as z:
|
||||
version = z.namelist()[0].split('/')[0]
|
||||
if not fnmatch.fnmatch(version, 'UnrealEngine-*-release'):
|
||||
sys.exit("UnrealEngine.zip does not contain UnrealEngine-*-release")
|
||||
unrealversion = os.path.join(INTEGRATION, version)
|
||||
zips = list(Path(INTEGRATION).glob("UnrealEngine-*-release.zip"))
|
||||
if len(zips) == 0:
|
||||
sys.exit("Cannot find UnrealEngine-*-release.zip")
|
||||
if len(zips) > 1:
|
||||
sys.exit("Found multiple files matching UnrealEngine-*-release.zip")
|
||||
print("Unreal version: ", zips[0].stem)
|
||||
zipfn = os.path.join(INTEGRATION, zips[0].name)
|
||||
extracted = os.path.join(INTEGRATION, zips[0].stem)
|
||||
touchfile = os.path.join(UNREALENGINE, zips[0].stem)
|
||||
if not Path(touchfile).is_file():
|
||||
print("Removing old version of unreal engine source...")
|
||||
shutil.rmtree(UNREALENGINE, ignore_errors=True)
|
||||
shutil.rmtree(unrealversion, ignore_errors=True)
|
||||
print("Unzipping UnrealEngine.zip...")
|
||||
shell(INTEGRATION, "unzip -q UnrealEngine.zip")
|
||||
shutil.rmtree(extracted, ignore_errors=True)
|
||||
print(f"Unzipping {zipfn}...")
|
||||
with JZipFile(zipfn) as zf:
|
||||
zf.extractall(INTEGRATION)
|
||||
patchfile = f"{INTEGRATION}/EnginePatches/EnginePatch"
|
||||
shell(unrealversion, f"patch -p1 < {patchfile}")
|
||||
Path(unrealversion).rename(UNREALENGINE)
|
||||
shell(extracted, f"patch -p1 < {patchfile}")
|
||||
Path(extracted).rename(UNREALENGINE)
|
||||
Path(touchfile).touch()
|
||||
|
||||
|
||||
def generate_buildconfiguration_xml():
|
||||
|
||||
Reference in New Issue
Block a user