Skip to content

Commit

Permalink
Pull only chef changes from update2
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed May 31, 2022
1 parent c8ce60f commit f6358a7
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)

#
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f6358a7

Please sign in to comment.