Skip to content

Commit

Permalink
Merge pull request #9 from mingaldrichgan/ignore_files
Browse files Browse the repository at this point in the history
Use "common_files" config + add "ignore_files" config
  • Loading branch information
melianmiko authored Jan 23, 2024
2 parents ee57603 + 755a25b commit 88fc373
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 10 additions & 10 deletions zmake/project_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion zmake/zmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 88fc373

Please sign in to comment.