diff options
author | xengineering <me@xengineering.eu> | 2025-04-06 17:59:06 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2025-04-06 17:59:06 +0200 |
commit | 867755129e5c50f4e35bc34d5818c2397f3f09db (patch) | |
tree | 72758147e7fe1a10a2202b9fdbd487d587524502 /tools/build_zephyr.py | |
parent | 84ab791be78c4f2014a78b09305c5c332b5383e3 (diff) | |
download | iot-contact-867755129e5c50f4e35bc34d5818c2397f3f09db.tar iot-contact-867755129e5c50f4e35bc34d5818c2397f3f09db.tar.zst iot-contact-867755129e5c50f4e35bc34d5818c2397f3f09db.zip |
tools: Use argparse for build scripts
This makes them re-usable for the application and native_sim firmwares.
Diffstat (limited to 'tools/build_zephyr.py')
-rwxr-xr-x | tools/build_zephyr.py | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/tools/build_zephyr.py b/tools/build_zephyr.py index c99727e..e201bac 100755 --- a/tools/build_zephyr.py +++ b/tools/build_zephyr.py @@ -6,29 +6,42 @@ # obtain one at https://mozilla.org/MPL/2.0/. +import argparse import multiprocessing import shutil import subprocess -import sys import pathlib -build_tree = pathlib.Path(sys.argv[1]) -output_dir = build_tree.parent +def main() -> None: + parser = argparse.ArgumentParser( + description="Build a Zephyr GNU Make build", + ) + parser.add_argument("-B", "--build-tree", required=True) + parser.add_argument("-n", "--target-name", required=True) -subprocess.run( - [ - "make", - f"-j{multiprocessing.cpu_count()}", - "-C", - f"{str(build_tree)}", - ], - shell=False, - check=True, -) + args = parser.parse_args() -shutil.copy( - build_tree / "zephyr" / "zephyr.bin", - output_dir / "bootloader.bin" -) + build_tree = pathlib.Path(args.build_tree) + output_dir = build_tree.parent + + subprocess.run( + [ + "make", + f"-j{multiprocessing.cpu_count()}", + "-C", + f"{str(build_tree)}", + ], + shell=False, + check=True, + ) + + shutil.copy( + build_tree / "zephyr" / "zephyr.bin", + output_dir / args.target_name + ) + + +if __name__ == "__main__": + main() |