diff --git a/examples/chef/chef.py b/examples/chef/chef.py index b13c53207e355c..d73cb8a3611b2b 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -156,8 +156,20 @@ def load_cicd_config() -> Dict[str, Any]: return config -def flush_print(to_print: str) -> None: - """Prints and flushes stdout buffer""" +def flush_print( + to_print: str, + with_border: bool = False) -> None: + """Prints and flushes stdout buffer + + Args: + to_print: The string to print + with_border: Add boarder above and below to_print + Returns: + None + """ + if with_border: + border = ('*' * 64) + '\n' + to_print = f"{border}{to_print}{border}" print(to_print, flush=True) @@ -356,7 +368,9 @@ def main(argv: Sequence[str]) -> None: if options.build_target == "nrfconnect": shell.run_cmd("export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"") shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") - shell.run_cmd(f"./chef.py -cbr --use_zzz -d {device_name} -t {options.build_target}") + command = f"./chef.py -cbr --use_zzz -d {device_name} -t {options.build_target}" + flush_print(f"Building {command}", with_border=True) + shell.run_cmd(command) exit(0) # @@ -378,9 +392,7 @@ def main(argv: Sequence[str]) -> None: label = platform_meta['platform_label'] output_dir = os.path.join(_CHEF_SCRIPT_PATH, directory) command = f"./chef.py -cbr --use_zzz -d {device_name} -t {platform}" - flush_print("-" * 64) - flush_print(f"Building {command}") - flush_print("-" * 64) + flush_print(f"Building {command}", with_border=True) shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") shell.run_cmd("export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"") shell.run_cmd(command) @@ -485,9 +497,19 @@ def main(argv: Sequence[str]) -> None: "zzz_generated", options.sample_device_type_name, "zap-generated") + if not os.path.exists(zzz_dir): + flush_print(f""" + You have specified --use_zzz + for device {options.sample_device_type_name} + which does not exist in the cached ZAP output. + To cache ZAP output for this device: + ensure {options.sample_device_type_name}.zap + is placed in {_DEVICE_FOLDER} + run chef with the option --generate_zzz + """) + exit(1) shutil.rmtree(gen_dir, ignore_errors=True) shutil.copytree(zzz_dir, gen_dir) - flush_print("Building...") if options.do_rpc: flush_print("RPC PW enabled")