41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
from .util import *
|
|
from . import fileutil
|
|
|
|
import shutil
|
|
|
|
# Task dependencies
|
|
from .extract import extract
|
|
|
|
def patch_resources():
|
|
_ = extract()
|
|
|
|
# The way we merge resources is as follows:
|
|
# First, we copy our raw-resources from src/resources
|
|
# Second, we apply our patches, which are handled by polly
|
|
# Finally, we populate all missing entries from build/extracted
|
|
# The reason we do this is that build/extracted will always have a date greater than src/resources
|
|
# until the files are modified after first build, which makes simply merging-by-date impossible.
|
|
|
|
s = fileutil.merge_into(SRC_RESOURCES_DIR, PATCHED_RSC_DIR)
|
|
if s:
|
|
print("Copied custom resources from src/resources")
|
|
else:
|
|
print("Skipped copying resources from src/resources")
|
|
|
|
print("Copying original resources...")
|
|
for (cd, _, files) in EXTRACTED_DIR.walk():
|
|
for file in files:
|
|
# Don't copy smali code
|
|
if file.startswith("smali"):
|
|
continue
|
|
|
|
src_file = cd / file
|
|
dest_file = PATCHED_RSC_DIR / src_file.relative_to(EXTRACTED_DIR)
|
|
|
|
# Don't update if dest is newer than source
|
|
if dest_file.exists() and src_file.stat().st_mtime < dest_file.stat().st_mtime:
|
|
continue
|
|
|
|
dest_file.parent.mkdir(parents=True, exist_ok=True)
|
|
_ = shutil.copyfile(src_file, dest_file)
|
|
|