ykit/buildtool/task/merge_resources.py

33 lines
1.1 KiB
Python

from .util import *
from . import fileutil
import shutil
# Task dependencies
from .patch_resources import patch_resources
from .compile_smali import compile_smali
# Merges resources from all the previous steps
def merge_resources():
_ = patch_resources()
_ = compile_smali()
first_time = False
# Copy original resources only the first time
if not MERGED_RSC_DIR.exists():
print("Merging original resources...")
shutil.copytree(EXTRACTED_DIR, MERGED_RSC_DIR, ignore=shutil.ignore_patterns("smali", "smali_classes*"))
first_time = True
updated = first_time
# Make sure to place "or updated" *after* the statement, not before, because 'and' and 'or' are short-circuting... ya idiot
print("Merging patched resources...")
updated = fileutil.merge_into(PATCHED_RSC_DIR, MERGED_RSC_DIR, check_date=not first_time) or updated
print("Merging dex files...")
updated = fileutil.merge_into(COMPILED_SMALI_DIR, MERGED_RSC_DIR, check_date=not first_time) or updated
return updated