Skip to content

Commit

Permalink
Add pre_build_script support
Browse files Browse the repository at this point in the history
- Add `pre_build_script` support, similar to `post_build_script`.
  - For backwards compatibility with existing `zmake.json` files, `context.config.get("pre_build_script", "")` is called instead of `context.config["post_build_script"]` to avoid errors if `"pre_build_script"` is undefined.
- Expand both `pre_build_script` and `post_build_script` contents with `os.path.expanduser` to expand `~` into the user's home directory.
- Fix a typo in the README.
  • Loading branch information
mingaldrichgan committed Jan 20, 2024
1 parent 9ea32d3 commit 2984d78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cd zmake

# Create and activate venv
python3.10 -m venv venv
source venv/bin/active
source venv/bin/activate

# Install deps and build
pip install -r requirements.txt
Expand Down
10 changes: 9 additions & 1 deletion zmake/project_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
]


@build_handler("Pre-build command")
def post_build(context: ZMakeContext):
if context.config.get("pre_build_script", "") == "":
return

subprocess.Popen([os.path.expanduser(context.config["pre_build_script"]), str(context.path)]).wait()


@build_handler("Prepare")
def prepare(context: ZMakeContext):
path_build = context.path / "build"
Expand Down Expand Up @@ -385,4 +393,4 @@ def post_build(context: ZMakeContext):
if context.config["post_build_script"] == "":
return

subprocess.Popen([context.config["post_build_script"], str(context.path)]).wait()
subprocess.Popen([os.path.expanduser(context.config["post_build_script"]), str(context.path)]).wait()
1 change: 1 addition & 0 deletions zmake/zmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"with_adb": false,
"adb_path": "/storage/emulated/0/Android/data/com.xiaomi.hm.health/files/watch_skin_local",

"pre_build_script": "",
"post_build_script": "",

"common_files": [],
Expand Down

0 comments on commit 2984d78

Please sign in to comment.