diff --git a/zmake/project_build.py b/zmake/project_build.py index bcf1496..b9d8d04 100644 --- a/zmake/project_build.py +++ b/zmake/project_build.py @@ -13,13 +13,13 @@ from zmake.context import build_handler, ZMakeContext from zmake.third_tools_manager import run_ext_tool -LIST_COMMON_FILES = [ - "README.txt", - "LICENSE.txt", - "README", - "LICENSE", - "secondary-widget" -] + +def should_ignore_file(filename: str, context: ZMakeContext): + for file_to_ignore in context.config.get("ignore_files", [".DS_Store", "Thumbs.db"]): + if file_to_ignore in filename: + return True + + return False @build_handler("Pre-build command") @@ -138,7 +138,7 @@ def handle_assets(context: ZMakeContext): @build_handler("Common files") def common_files(context: ZMakeContext): context.logger.info("Copying common files:") - files = LIST_COMMON_FILES + files = context.config["common_files"] for fn in files: p = context.path / fn if p.is_dir(): @@ -317,7 +317,7 @@ def package(context: ZMakeContext): with ZipFile(device_zip, "w", ZIP_DEFLATED) as arc: for file in (context.path / "build").rglob("**/*"): fn = str(file)[len(str(context.path / "build")):] - if ".DS_Store" in fn or "Thumbs.db" in fn: + if should_ignore_file(fn, context): context.logger.info(f"Skip: {fn}") continue arc.write(file, fn) @@ -349,7 +349,7 @@ def make_zeus_pkg(context: ZMakeContext): with ZipFile(device_zip_file, "w", ZIP_DEFLATED) as archive: for file in (context.path / "build").rglob("**/*"): fn = str(file)[len(str(context.path / "build")):] - if ".DS_Store" in fn or "Thumbs.db" in fn: + if should_ignore_file(fn, context): continue archive.write(file, fn) diff --git a/zmake/zmake.json b/zmake/zmake.json index 61bd15f..9ca746e 100644 --- a/zmake/zmake.json +++ b/zmake/zmake.json @@ -23,7 +23,8 @@ "pre_build_script": "", "post_build_script": "", - "common_files": [], + "common_files": ["README.txt", "LICENSE.txt", "README", "LICENSE", "secondary-widget"], + "ignore_files": [".gitignore", ".DS_Store", "Thumbs.db"], "with_zeus_compat": false, "zeus_target": "mi-band7",