Skip to content

Commit

Permalink
Split builds
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed May 25, 2022
1 parent 56afe21 commit 86de3af
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 23 deletions.
22 changes: 13 additions & 9 deletions examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def main(argv: Sequence[str]) -> None:
dest="validate_zzz", action="store_true")
parser.add_option("", "--use_zzz", help="Use pre generated output from the ZAP tool found in the zzz_generated folder. Used to decrease execution time of CI jobs",
dest="use_zzz", action="store_true")
parser.add_option("", "--build_all", help="Builds all chef examples across all platforms and collates artifacts. Chef exits after completion.",
parser.add_option("", "--build_all", help="Builds all chef examples for the specified platform and collates artifacts. Chef exits after completion.",
dest="build_all", action="store_true")
parser.add_option(
"", "--ci", help="Builds Chef examples defined in chef_util.ci_allowlist. Uses specified target. Chef exits after completion.", dest="ci", action="store_true")
Expand Down Expand Up @@ -283,21 +283,25 @@ def main(argv: Sequence[str]) -> None:
if options.build_all:
print("Building all chef examples")
os.environ['GNUARMEMB_TOOLCHAIN_PATH'] = os.environ['PW_ARM_CIPD_INSTALL_DIR']
platforms_and_outputs = chef_util.cd_platforms_and_outputs
archive_prefix = "/workspace/artifacts/"
if not os.path.exists(archive_prefix):
# shutil.rmtree(archive_prefix)
os.mkdir(archive_prefix)
archive_suffix = ".tar.gz"

cd_platforms_meta = chef_util.cd_platforms_meta
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():
for platform, platform_meta in cd_platforms_meta.items():
directory = platform_meta['build_dir']
label = platform_meta['platform_label']
output_dir = os.path.join(_CHEF_SCRIPT_PATH, directory)
command = './chef.py -czbr -d {} -t {}'.format(device_name, platform)
command = './chef.py -czbr -d {} -t {}'.format(device_name, options.build_target)
print(f"Building {command}")
subprocess.check_call(command, cwd=_CHEF_SCRIPT_PATH, shell=True)
archive_prefix = "/workspace/artifacts/"
if not os.path.exists(archive_prefix):
os.mkdir(archive_prefix)
archive_name = f"{platform}-chef-{device_name}-wifi-rpc"
archive_suffix = ".tar.gz"
archive_name = f"{label}-chef-{device_name}-wifi-rpc"
archive_full_name = archive_prefix + archive_name + archive_suffix
print(f"Adding build output to archive {archive_full_name}")
with tarfile.open(archive_full_name, "w:gz") as tar:
Expand Down
26 changes: 22 additions & 4 deletions examples/chef/chef_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,32 @@
import os
import hashlib


ci_allowlist = ['lighting-app.zap']
cd_platforms_and_outputs = {
'linux': 'linux/out',
'esp32': 'esp32/build',
'nrfconnect': 'nrfconnect/build',
cd_platforms_meta = {
'linux': {
'build_dir': 'linux/out',
'platform_label': 'linux_x86',
},
'esp32': {
'build_dir': 'esp32/build',
'platform_label': 'esp32-m5stack',
},
'nrfconnect': {
'build_dir': 'nrfconnect/build',
'platform_label': 'nrf-nrf52840dk',
},
}


def bundle(platform: str):
if platform == 'linux':
pass
if platform == 'esp32':
pass
if platform == 'nrfconnect':
pass

def check_zap_master(repo_base_path: str) -> str:
"""Produces hash of ZAP submodule in branch master"""
git_cmd = ["git", "ls-tree", "master", "third_party/zap/repo"]
Expand Down
34 changes: 24 additions & 10 deletions integrations/cloudbuild/chef.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
steps:
- name: "connectedhomeip/chip-build-vscode:0.5.75"

- name: "connectedhomeip/chip-build:0.5.73"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
- "-c"
- source ./scripts/bootstrap.sh
id: Bootstrap
entrypoint: /usr/bin/bash
- >-
./examples/chef/chef.py --build_all -t linux
id: Linux
entrypoint: ./scripts/run_in_build_env.sh
volumes:
- name: pwenv
path: /pwenv

- name: "connectedhomeip/chip-build-esp32:0.5.73"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
- >-
./examples/chef/chef.py --build_all -t esp32
id: ESP32
waitFor:
- Linux
entrypoint: ./scripts/run_in_build_env.sh
volumes:
- name: pwenv
path: /pwenv
timeout: 900s

- name: "connectedhomeip/chip-build-vscode:0.5.75"
- name: "connectedhomeip/chip-build-nrf-platform:0.5.73"
env:
- PW_ENVIRONMENT_ROOT=/pwenv
args:
- >-
./examples/chef/chef.py --build_all
id: CompileAll
./examples/chef/chef.py --build_all -t nrfconnect
id: NRFConnect
waitFor:
- Bootstrap
- ESP32
entrypoint: ./scripts/run_in_build_env.sh
volumes:
- name: pwenv
Expand Down

0 comments on commit 86de3af

Please sign in to comment.