39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
class PatchTask:
|
|
def __init__(self, config, input_dir, output_dir, renpy_path, registry):
|
|
self.config = config
|
|
self.input_dir = input_dir
|
|
self.output_dir = output_dir
|
|
self.renpy_path = renpy_path
|
|
self.registry = registry
|
|
|
|
def pre_build(self, on_builds):
|
|
import subprocess
|
|
from os.path import exists
|
|
|
|
if exists(f"{self.renpy_path}/patched.txt"):
|
|
print("================File already patched!==================")
|
|
else:
|
|
patch_exec = "patch"
|
|
if self.config.get('patch_path') != None and self.config['patch_path'] != "":
|
|
patch_exec = self.config['patch_path']
|
|
|
|
print("================Initiating patching==================")
|
|
|
|
try:
|
|
subprocess.run([patch_exec, f"{self.renpy_path}/renpy.py", f"{self.input_dir}/build_patch/patch.diff"])
|
|
except Exception as e:
|
|
print(e)
|
|
raise e
|
|
|
|
# Create a flag so we don't try to patch this again on re-runs
|
|
try:
|
|
flag = open(f"{self.renpy_path}/patched.txt", 'x')
|
|
except Exception as e:
|
|
print(e)
|
|
raise e
|
|
|
|
print("================File Patched==================")
|
|
|
|
def post_build(self, on_builds):
|
|
pass
|