Skip to content

Commit

Permalink
Move non re-used logic to chef, simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed May 24, 2022
1 parent 921557a commit 7c9866d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
10 changes: 9 additions & 1 deletion examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,15 @@ def main(argv: Sequence[str]) -> None:
#

if options.build_all:
chef_util.build_all(chef_devices_dir, _CHEF_SCRIPT_PATH)
platforms_and_outputs = chef_util.cd_platforms_and_outputs
for device in os.listdir(chef_devices_dir):
target_file_ext = ".zap"
if device.endswith(target_file_ext):
device_name = device[:-len(target_file_ext)]
for platform, directory in platforms_and_outputs.items():
platforms_and_outputs[platform] = os.path.join(_CHEF_SCRIPT_PATH, directory)
command = './chef.py -czbr -d {} -t {}'.format(device_name, platform)
subprocess.check_call(command, cwd=_CHEF_SCRIPT_PATH, shell=True)
exit(0)

#
Expand Down
15 changes: 0 additions & 15 deletions examples/chef/chef_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,3 @@ 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)

0 comments on commit 7c9866d

Please sign in to comment.