From 921557a830aea09855070a1fff93fb15733febcb Mon Sep 17 00:00:00 2001 From: Austin Bozowski Date: Tue, 24 May 2022 20:10:35 +0000 Subject: [PATCH] Build all function --- examples/chef/chef.py | 2 ++ examples/chef/chef_util.py | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/chef/chef.py b/examples/chef/chef.py index ece284f34f4e7f..a0e06f6e08a4ef 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -253,11 +253,13 @@ def main(argv: Sequence[str]) -> None: shell.run_cmd(f"touch {device_out_dir}/af-gen-event.h") chef_util.generate_device_manifest(chef_devices_dir, include_zap_submod=True, write_manifest_file = True, ci_manifest_file_name = ci_manifest_file_name, repo_base_path=_REPO_BASE_PATH) exit(0) + # # Build all # if options.build_all: + chef_util.build_all(chef_devices_dir, _CHEF_SCRIPT_PATH) exit(0) # diff --git a/examples/chef/chef_util.py b/examples/chef/chef_util.py index b675db8d802598..348e841f0b6ea7 100644 --- a/examples/chef/chef_util.py +++ b/examples/chef/chef_util.py @@ -4,7 +4,7 @@ import hashlib ci_allowlist = ['lighting-app.zap'] -cd_output_dirs = { +cd_platforms_and_outputs = { 'linux': 'linux/out', 'esp32': 'esp32/build', 'nrfconnect': 'nrfconnect/build', @@ -38,3 +38,18 @@ def generate_device_manifest(chef_devices_dir: str, include_zap_submod: bool = F with open(ci_manifest_file_name, "w+", encoding="utf-8") as ci_manifest_file: ci_manifest_file.write(json.dumps(ci_manifest, indent=4)) return ci_manifest + +def create_build_command(zap: str, platform: str) -> str: + return './chef.py -czbr -d {} -t {}'.format(zap, platform) + +def build_all(device_dir: str, chef_script_path: str) -> None: + devices = [] + for device in os.listdir(device_dir): + target_file_ext = ".zap" + if device.endswith(target_file_ext): + devices.append(device[:-len(target_file_ext)]) + for platform, directory in cd_platforms_and_outputs.items(): + cd_platforms_and_outputs[platform] = os.path.join(chef_script_path, directory) + for device in devices: + command = create_build_command(device, platform) + subprocess.check_call(command, cwd=chef_script_path, shell=True)