From 1616084d120c202649d9bda0f26303d0a3248c70 Mon Sep 17 00:00:00 2001 From: Artur Tynecki <77382963+ATmobica@users.noreply.github.com> Date: Tue, 2 Nov 2021 14:58:55 +0100 Subject: [PATCH] [Mbed] Mbed platform examples Python builder (#11197) * Add Mbed python builder Add Mbed targets to python builder * Improve mbed_example.sh script - Python builder compatibility Improve examples cmake file and gitignore * Improve build and outputs definition in Python builder * Update all_targets_except_host.txt * Update testdata Fix mbed builder for testing * Fix mbed unit test build script * Fix mbed builder for Darwin platform * Add mbed-release targets to exampleTarget input - task.json * Changes restyle * Add all Mbed supported targets and sorted - tasks.json * Improve mbed builder - more dry-run commands Add develop and debug profiles to glob-blacklist * Changes restyle --- .vscode/tasks.json | 15 ++ examples/all-clusters-app/mbed/.gitignore | 1 - examples/all-clusters-app/mbed/CMakeLists.txt | 4 +- examples/lighting-app/mbed/.gitignore | 1 - examples/lighting-app/mbed/CMakeLists.txt | 4 +- examples/lock-app/mbed/.gitignore | 1 - examples/lock-app/mbed/CMakeLists.txt | 4 +- examples/pigweed-app/mbed/.gitignore | 1 - examples/pigweed-app/mbed/CMakeLists.txt | 4 +- examples/shell/mbed/.gitignore | 1 - examples/shell/mbed/CMakeLists.txt | 4 +- scripts/build/build/targets.py | 25 +++ scripts/build/builders/mbed.py | 150 +++++++++++++++ .../testdata/all_targets_except_host.txt | 15 ++ .../build/testdata/build_all_except_host.txt | 180 ++++++++++++++++++ .../glob_star_targets_except_host.txt | 5 + scripts/examples/mbed_example.sh | 15 +- scripts/tests/mbed/mbed_unit_tests.sh | 15 +- src/test_driver/mbed/.gitignore | 1 - src/test_driver/mbed/CMakeLists.txt | 4 +- 20 files changed, 410 insertions(+), 40 deletions(-) create mode 100644 scripts/build/builders/mbed.py diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8baf5533a94d4c..b44986db5fd8f7 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -248,6 +248,21 @@ "linux-x64-chip-tool-ipv6only", "linux-x64-thermostat", "linux-x64-thermostat-ipv6only", + "mbed-CY8CPROTO_062_4343W-all-clusters-debug", + "mbed-CY8CPROTO_062_4343W-all-clusters-develop", + "mbed-CY8CPROTO_062_4343W-all-clusters-release", + "mbed-CY8CPROTO_062_4343W-light-debug", + "mbed-CY8CPROTO_062_4343W-light-develop", + "mbed-CY8CPROTO_062_4343W-light-release", + "mbed-CY8CPROTO_062_4343W-lock-debug", + "mbed-CY8CPROTO_062_4343W-lock-develop", + "mbed-CY8CPROTO_062_4343W-lock-release", + "mbed-CY8CPROTO_062_4343W-pigweed-debug", + "mbed-CY8CPROTO_062_4343W-pigweed-develop", + "mbed-CY8CPROTO_062_4343W-pigweed-release", + "mbed-CY8CPROTO_062_4343W-shell-debug", + "mbed-CY8CPROTO_062_4343W-shell-develop", + "mbed-CY8CPROTO_062_4343W-shell-release", "nrf-nrf52840-light", "nrf-nrf52840-lock", "nrf-nrf52840-pump", diff --git a/examples/all-clusters-app/mbed/.gitignore b/examples/all-clusters-app/mbed/.gitignore index 58f6e14fd6f5b2..414487d53eb835 100644 --- a/examples/all-clusters-app/mbed/.gitignore +++ b/examples/all-clusters-app/mbed/.gitignore @@ -1,2 +1 @@ -config/ build-*/ diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index 9f27e485a132e5..12cdd6bf6e6615 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -16,7 +16,7 @@ configure_file( @ONLY ) -set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") +set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "") set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") set(APP_TARGET chip-mbed-all-clusters-app-example) @@ -25,7 +25,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) add_subdirectory(${MBED_PATH} ./mbed_build) -add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) +add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) add_executable(${APP_TARGET}) diff --git a/examples/lighting-app/mbed/.gitignore b/examples/lighting-app/mbed/.gitignore index 58f6e14fd6f5b2..414487d53eb835 100644 --- a/examples/lighting-app/mbed/.gitignore +++ b/examples/lighting-app/mbed/.gitignore @@ -1,2 +1 @@ -config/ build-*/ diff --git a/examples/lighting-app/mbed/CMakeLists.txt b/examples/lighting-app/mbed/CMakeLists.txt index 102159a11f4ccc..c638320b71ea4c 100644 --- a/examples/lighting-app/mbed/CMakeLists.txt +++ b/examples/lighting-app/mbed/CMakeLists.txt @@ -14,7 +14,7 @@ configure_file( @ONLY ) -set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") +set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "") set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") set(APP_TARGET chip-mbed-lighting-app-example) @@ -23,7 +23,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) add_subdirectory(${MBED_PATH} ./mbed_build) -add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) +add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) add_executable(${APP_TARGET}) diff --git a/examples/lock-app/mbed/.gitignore b/examples/lock-app/mbed/.gitignore index 58f6e14fd6f5b2..414487d53eb835 100644 --- a/examples/lock-app/mbed/.gitignore +++ b/examples/lock-app/mbed/.gitignore @@ -1,2 +1 @@ -config/ build-*/ diff --git a/examples/lock-app/mbed/CMakeLists.txt b/examples/lock-app/mbed/CMakeLists.txt index b3bb2b1381cdb4..d6ca61db3ac0d2 100644 --- a/examples/lock-app/mbed/CMakeLists.txt +++ b/examples/lock-app/mbed/CMakeLists.txt @@ -14,7 +14,7 @@ configure_file( @ONLY ) -set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") +set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "") set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") set(APP_TARGET chip-mbed-lock-app-example) @@ -23,7 +23,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) add_subdirectory(${MBED_PATH} ./mbed_build) -add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) +add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) add_executable(${APP_TARGET}) diff --git a/examples/pigweed-app/mbed/.gitignore b/examples/pigweed-app/mbed/.gitignore index 58f6e14fd6f5b2..414487d53eb835 100644 --- a/examples/pigweed-app/mbed/.gitignore +++ b/examples/pigweed-app/mbed/.gitignore @@ -1,2 +1 @@ -config/ build-*/ diff --git a/examples/pigweed-app/mbed/CMakeLists.txt b/examples/pigweed-app/mbed/CMakeLists.txt index 7f53397dfdedb8..140c8a64b61aa8 100644 --- a/examples/pigweed-app/mbed/CMakeLists.txt +++ b/examples/pigweed-app/mbed/CMakeLists.txt @@ -13,7 +13,7 @@ configure_file( @ONLY ) -set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") +set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "") set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") set(APP_TARGET chip-mbed-pigweed-app-example) @@ -22,7 +22,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) add_subdirectory(${MBED_PATH} ./mbed_build) -add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) +add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) add_executable(${APP_TARGET}) diff --git a/examples/shell/mbed/.gitignore b/examples/shell/mbed/.gitignore index 58f6e14fd6f5b2..414487d53eb835 100644 --- a/examples/shell/mbed/.gitignore +++ b/examples/shell/mbed/.gitignore @@ -1,2 +1 @@ -config/ build-*/ diff --git a/examples/shell/mbed/CMakeLists.txt b/examples/shell/mbed/CMakeLists.txt index 17ec6390124cd6..18397ba9b8d689 100644 --- a/examples/shell/mbed/CMakeLists.txt +++ b/examples/shell/mbed/CMakeLists.txt @@ -13,7 +13,7 @@ configure_file( @ONLY ) -set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") +set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "") set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") set(APP_TARGET chip-mbed-shell-example) @@ -22,7 +22,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) add_subdirectory(${MBED_PATH} ./mbed_build) -add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) +add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) add_executable(${APP_TARGET}) diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index ba7927b2deb9a4..c11fe42ee13791 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -24,6 +24,7 @@ from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder from builders.tizen import TizenApp, TizenBoard, TizenBuilder from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder +from builders.mbed import MbedApp, MbedBoard, MbedProfile, MbedBuilder class Target: @@ -191,6 +192,29 @@ def AndroidTargets(): yield target.Extend('androidstudio-x64-chip-tool', board=AndroidBoard.AndroidStudio_X64, app=AndroidApp.CHIP_TOOL) +def MbedTargets(): + target = Target('mbed', MbedBuilder) + + targets = [ + target.Extend('CY8CPROTO_062_4343W', + board=MbedBoard.CY8CPROTO_062_4343W), + ] + + app_targets = [] + for target in targets: + app_targets.append(target.Extend('lock', app=MbedApp.LOCK)) + app_targets.append(target.Extend('light', app=MbedApp.LIGHT)) + app_targets.append(target.Extend( + 'all-clusters', app=MbedApp.ALL_CLUSTERS)) + app_targets.append(target.Extend('pigweed', app=MbedApp.PIGWEED)) + app_targets.append(target.Extend('shell', app=MbedApp.SHELL)) + + for target in app_targets: + yield target.Extend('release', profile=MbedProfile.RELEASE) + yield target.Extend('develop', profile=MbedProfile.DEVELOP).GlobBlacklist('Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html') + yield target.Extend('debug', profile=MbedProfile.DEBUG).GlobBlacklist('Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html') + + ALL = [] target_generators = [ @@ -199,6 +223,7 @@ def AndroidTargets(): Efr32Targets(), NrfTargets(), AndroidTargets(), + MbedTargets() ] for generator in target_generators: diff --git a/scripts/build/builders/mbed.py b/scripts/build/builders/mbed.py new file mode 100644 index 00000000000000..547481a2539bb2 --- /dev/null +++ b/scripts/build/builders/mbed.py @@ -0,0 +1,150 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import os +import platform +import glob +import shlex +import pathlib + +from enum import Enum, auto +from .builder import Builder + + +class MbedApp(Enum): + LOCK = auto() + LIGHT = auto() + ALL_CLUSTERS = auto() + PIGWEED = auto() + SHELL = auto() + + @property + def ExampleName(self): + if self == MbedApp.LOCK: + return 'lock-app' + elif self == MbedApp.LIGHT: + return 'lighting-app' + elif self == MbedApp.ALL_CLUSTERS: + return 'all-clusters-app' + elif self == MbedApp.PIGWEED: + return 'pigweed-app' + elif self == MbedApp.SHELL: + return 'shell' + else: + raise Exception('Unknown app type: %r' % self) + + @property + def AppNamePrefix(self): + if self == MbedApp.LOCK: + return 'chip-mbed-lock-app-example' + elif self == MbedApp.LIGHT: + return 'chip-mbed-lighting-app-example' + elif self == MbedApp.ALL_CLUSTERS: + return 'chip-mbed-all-clusters-app-example' + elif self == MbedApp.PIGWEED: + return 'chip-mbed-pigweed-app-example' + elif self == MbedApp.SHELL: + return 'shell' + else: + raise Exception('Unknown app type: %r' % self) + + +class MbedBoard(Enum): + CY8CPROTO_062_4343W = auto() + + @property + def BoardName(self): + if self == MbedBoard.CY8CPROTO_062_4343W: + return 'CY8CPROTO_062_4343W' + else: + raise Exception('Unknown board type: %r' % self) + + +class MbedProfile(Enum): + RELEASE = auto() + DEVELOP = auto() + DEBUG = auto() + + @property + def ProfileName(self): + if self == MbedProfile.RELEASE: + return 'release' + elif self == MbedProfile.DEVELOP: + return 'develop' + elif self == MbedProfile.DEBUG: + return 'debug' + else: + raise Exception('Unknown board type: %r' % self) + + +class MbedBuilder(Builder): + def __init__(self, + root, + runner, + app: MbedApp = MbedApp.LOCK, + board: MbedBoard = MbedBoard.CY8CPROTO_062_4343W, + profile: MbedProfile = MbedProfile.RELEASE): + super(MbedBuilder, self).__init__(root, runner) + self.app = app + self.board = board + self.profile = profile + self.toolchain = "GCC_ARM" + self.mbed_os_path = os.path.join( + self.root, 'third_party', 'mbed-os', 'repo') + self.mbed_os_posix_socket_path = os.path.join( + self.root, 'third_party', 'mbed-os-posix-socket', 'repo') + + @property + def ExamplePath(self): + return os.path.join(self.root, 'examples', self.app.ExampleName, 'mbed') + + def generate(self): + if not os.path.exists(self.output_dir): + self._Execute(['mbed-tools', 'configure', + '-t', self.toolchain, + '-m', self.board.BoardName, + '-p', self.ExamplePath, + '-o', self.output_dir, + '--mbed-os-path', self.mbed_os_path, + ], title='Generating config ' + self.identifier) + + self._Execute(['cmake', '-S', shlex.quote(self.ExamplePath), '-B', shlex.quote(self.output_dir), '-GNinja', + '-DCMAKE_BUILD_TYPE={}'.format( + self.profile.ProfileName.lower()), + '-DMBED_OS_PATH={}'.format( + shlex.quote(self.mbed_os_path)), + '-DMBED_OS_POSIX_SOCKET_PATH={}'.format( + shlex.quote(self.mbed_os_posix_socket_path)), + ], title='Generating ' + self.identifier) + + def _build(self): + # Remove old artifacts to force linking + cmd = 'rm -rf {}/chip-*'.format(self.output_dir) + self._Execute(['bash', '-c', cmd], + title='Remove old artifacts ' + self.identifier) + + self._Execute(['cmake', '--build', shlex.quote(self.output_dir)], + title='Building ' + self.identifier) + + def build_outputs(self): + return { + self.app.AppNamePrefix + '.elf': + os.path.join(self.output_dir, self.app.AppNamePrefix + '.elf'), + self.app.AppNamePrefix + '.hex': + os.path.join(self.output_dir, self.app.AppNamePrefix + '.hex'), + self.app.AppNamePrefix + '.map': + os.path.join(self.output_dir, + self.app.AppNamePrefix + '.elf.map'), + } diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index 8dc6550999a821..03c247dc42e7b0 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -24,6 +24,21 @@ esp32-m5stack-all-clusters-ipv6only esp32-m5stack-all-clusters-rpc esp32-m5stack-all-clusters-rpc-ipv6only infineon-p6-lock +mbed-CY8CPROTO_062_4343W-all-clusters-debug (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-all-clusters-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-all-clusters-release +mbed-CY8CPROTO_062_4343W-light-debug (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-light-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-light-release +mbed-CY8CPROTO_062_4343W-lock-debug (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-lock-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-lock-release +mbed-CY8CPROTO_062_4343W-pigweed-debug (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-pigweed-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-pigweed-release +mbed-CY8CPROTO_062_4343W-shell-debug (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-shell-develop (NOGLOB: Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html) +mbed-CY8CPROTO_062_4343W-shell-release nrf-nrf52840-light nrf-nrf52840-light-rpc nrf-nrf52840-lock diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 3cb809d040e0c3..3f785fbe107712 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -254,6 +254,96 @@ idf.py -C examples/all-clusters-app/esp32 -B {out}/esp32-m5stack-all-clusters-rp # Generating infineon-p6-lock gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/p6 '--args=p6_board="CY8CKIT-062S2-43012"' {out}/infineon-p6-lock +# Generating config mbed-CY8CPROTO_062_4343W-all-clusters-debug +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/all-clusters-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-all-clusters-debug +cmake -S {root}/examples/all-clusters-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug -GNinja -DCMAKE_BUILD_TYPE=debug -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-all-clusters-develop +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/all-clusters-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-all-clusters-develop --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-all-clusters-develop +cmake -S {root}/examples/all-clusters-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-all-clusters-develop -GNinja -DCMAKE_BUILD_TYPE=develop -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-all-clusters-release +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/all-clusters-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-all-clusters-release --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-all-clusters-release +cmake -S {root}/examples/all-clusters-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-all-clusters-release -GNinja -DCMAKE_BUILD_TYPE=release -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-light-debug +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/lighting-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-light-debug --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-light-debug +cmake -S {root}/examples/lighting-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-light-debug -GNinja -DCMAKE_BUILD_TYPE=debug -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-light-develop +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/lighting-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-light-develop --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-light-develop +cmake -S {root}/examples/lighting-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-light-develop -GNinja -DCMAKE_BUILD_TYPE=develop -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-light-release +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/lighting-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-light-release --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-light-release +cmake -S {root}/examples/lighting-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-light-release -GNinja -DCMAKE_BUILD_TYPE=release -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-lock-debug +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/lock-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-lock-debug --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-lock-debug +cmake -S {root}/examples/lock-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-lock-debug -GNinja -DCMAKE_BUILD_TYPE=debug -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-lock-develop +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/lock-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-lock-develop --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-lock-develop +cmake -S {root}/examples/lock-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-lock-develop -GNinja -DCMAKE_BUILD_TYPE=develop -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-lock-release +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/lock-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-lock-release --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-lock-release +cmake -S {root}/examples/lock-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-lock-release -GNinja -DCMAKE_BUILD_TYPE=release -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-pigweed-debug +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/pigweed-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-pigweed-debug --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-pigweed-debug +cmake -S {root}/examples/pigweed-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-pigweed-debug -GNinja -DCMAKE_BUILD_TYPE=debug -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-pigweed-develop +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/pigweed-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-pigweed-develop --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-pigweed-develop +cmake -S {root}/examples/pigweed-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-pigweed-develop -GNinja -DCMAKE_BUILD_TYPE=develop -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-pigweed-release +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/pigweed-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-pigweed-release --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-pigweed-release +cmake -S {root}/examples/pigweed-app/mbed -B {out}/mbed-CY8CPROTO_062_4343W-pigweed-release -GNinja -DCMAKE_BUILD_TYPE=release -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-shell-debug +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/shell/mbed -o {out}/mbed-CY8CPROTO_062_4343W-shell-debug --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-shell-debug +cmake -S {root}/examples/shell/mbed -B {out}/mbed-CY8CPROTO_062_4343W-shell-debug -GNinja -DCMAKE_BUILD_TYPE=debug -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-shell-develop +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/shell/mbed -o {out}/mbed-CY8CPROTO_062_4343W-shell-develop --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-shell-develop +cmake -S {root}/examples/shell/mbed -B {out}/mbed-CY8CPROTO_062_4343W-shell-develop -GNinja -DCMAKE_BUILD_TYPE=develop -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + +# Generating config mbed-CY8CPROTO_062_4343W-shell-release +mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/shell/mbed -o {out}/mbed-CY8CPROTO_062_4343W-shell-release --mbed-os-path {root}/third_party/mbed-os/repo + +# Generating mbed-CY8CPROTO_062_4343W-shell-release +cmake -S {root}/examples/shell/mbed -B {out}/mbed-CY8CPROTO_062_4343W-shell-release -GNinja -DCMAKE_BUILD_TYPE=release -DMBED_OS_PATH={root}/third_party/mbed-os/repo -DMBED_OS_POSIX_SOCKET_PATH={root}/third_party/mbed-os-posix-socket/repo + # Generating nrf-nrf52840-light bash -c 'source "$ZEPHYR_BASE/zephyr-env.sh"; export GNUARMEMB_TOOLCHAIN_PATH="$PW_PIGWEED_CIPD_INSTALL_DIR"; @@ -539,6 +629,96 @@ idf.py -C examples/all-clusters-app/esp32 -B {out}/esp32-m5stack-all-clusters-rp # Building infineon-p6-lock ninja -C {out}/infineon-p6-lock +# Remove old artifacts mbed-CY8CPROTO_062_4343W-all-clusters-debug +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-all-clusters-debug +cmake --build {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-all-clusters-develop +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-all-clusters-develop/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-all-clusters-develop +cmake --build {out}/mbed-CY8CPROTO_062_4343W-all-clusters-develop + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-all-clusters-release +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-all-clusters-release/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-all-clusters-release +cmake --build {out}/mbed-CY8CPROTO_062_4343W-all-clusters-release + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-light-debug +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-light-debug/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-light-debug +cmake --build {out}/mbed-CY8CPROTO_062_4343W-light-debug + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-light-develop +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-light-develop/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-light-develop +cmake --build {out}/mbed-CY8CPROTO_062_4343W-light-develop + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-light-release +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-light-release/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-light-release +cmake --build {out}/mbed-CY8CPROTO_062_4343W-light-release + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-lock-debug +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-lock-debug/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-lock-debug +cmake --build {out}/mbed-CY8CPROTO_062_4343W-lock-debug + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-lock-develop +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-lock-develop/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-lock-develop +cmake --build {out}/mbed-CY8CPROTO_062_4343W-lock-develop + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-lock-release +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-lock-release/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-lock-release +cmake --build {out}/mbed-CY8CPROTO_062_4343W-lock-release + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-pigweed-debug +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-pigweed-debug/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-pigweed-debug +cmake --build {out}/mbed-CY8CPROTO_062_4343W-pigweed-debug + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-pigweed-develop +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-pigweed-develop/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-pigweed-develop +cmake --build {out}/mbed-CY8CPROTO_062_4343W-pigweed-develop + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-pigweed-release +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-pigweed-release/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-pigweed-release +cmake --build {out}/mbed-CY8CPROTO_062_4343W-pigweed-release + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-shell-debug +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-shell-debug/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-shell-debug +cmake --build {out}/mbed-CY8CPROTO_062_4343W-shell-debug + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-shell-develop +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-shell-develop/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-shell-develop +cmake --build {out}/mbed-CY8CPROTO_062_4343W-shell-develop + +# Remove old artifacts mbed-CY8CPROTO_062_4343W-shell-release +bash -c 'rm -rf {out}/mbed-CY8CPROTO_062_4343W-shell-release/chip-*' + +# Building mbed-CY8CPROTO_062_4343W-shell-release +cmake --build {out}/mbed-CY8CPROTO_062_4343W-shell-release + # Building nrf-nrf52840-light ninja -C {out}/nrf-nrf52840-light diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 72c4fac84e8590..a5e973ae56bad5 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -24,6 +24,11 @@ esp32-m5stack-all-clusters-ipv6only esp32-m5stack-all-clusters-rpc esp32-m5stack-all-clusters-rpc-ipv6only infineon-p6-lock +mbed-CY8CPROTO_062_4343W-all-clusters-release +mbed-CY8CPROTO_062_4343W-light-release +mbed-CY8CPROTO_062_4343W-lock-release +mbed-CY8CPROTO_062_4343W-pigweed-release +mbed-CY8CPROTO_062_4343W-shell-release nrf-nrf52840-light nrf-nrf52840-light-rpc nrf-nrf52840-lock diff --git a/scripts/examples/mbed_example.sh b/scripts/examples/mbed_example.sh index ba66762b6b8f5c..9c26b5b3804e1b 100755 --- a/scripts/examples/mbed_example.sh +++ b/scripts/examples/mbed_example.sh @@ -96,27 +96,20 @@ BUILD_DIRECTORY="$APP"/mbed/build-"$TARGET_BOARD"/"$PROFILE"/ if [[ "$COMMAND" == *"build"* ]]; then echo "Build $APP app for $TARGET_BOARD target with $TOOLCHAIN toolchain and $PROFILE profile" - # Config directory setup - MBED_CONFIG_PATH="$APP"/mbed/config/"$TARGET_BOARD"/"$PROFILE"/"$TOOLCHAIN"/ - # Set Mbed OS path - export MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo + MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo # Set Mbed OS posix socket submodule path - export MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo + MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo # Generate config file for selected target, toolchain and hardware - mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" -p "$APP"/mbed/ -o "$MBED_CONFIG_PATH" --mbed-os-path "$MBED_OS_PATH" + mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" -p "$APP"/mbed/ -o "$BUILD_DIRECTORY" --mbed-os-path "$MBED_OS_PATH" # Remove old artifacts to force linking rm -rf "$BUILD_DIRECTORY/chip-"* - # Create output directory and copy config file there. - mkdir -p "$BUILD_DIRECTORY" - cp -f "$MBED_CONFIG_PATH"/mbed_config.cmake "$BUILD_DIRECTORY"/mbed_config.cmake - # Build application - cmake -S "$APP/mbed" -B "$BUILD_DIRECTORY" -GNinja -DCMAKE_BUILD_TYPE="$PROFILE" + cmake -S "$APP/mbed" -B "$BUILD_DIRECTORY" -GNinja -DCMAKE_BUILD_TYPE="$PROFILE" -DMBED_OS_PATH="$MBED_OS_PATH" -DMBED_OS_POSIX_SOCKET_PATH="$MBED_OS_POSIX_SOCKET_PATH" cmake --build "$BUILD_DIRECTORY" fi diff --git a/scripts/tests/mbed/mbed_unit_tests.sh b/scripts/tests/mbed/mbed_unit_tests.sh index 34fc89a8acc125..8829f3c656c4f5 100755 --- a/scripts/tests/mbed/mbed_unit_tests.sh +++ b/scripts/tests/mbed/mbed_unit_tests.sh @@ -85,27 +85,20 @@ BUILD_DIRECTORY=build-"$TARGET_BOARD"/"$PROFILE"/ if [[ "$COMMAND" == *"build"* ]]; then echo "Build unit tests app for $TARGET_BOARD target with $TOOLCHAIN toolchain and $PROFILE profile" - # Config directory setup - MBED_CONFIG_PATH=./config/"$TARGET_BOARD"/"$PROFILE"/"$TOOLCHAIN"/ - # Set Mbed OS path - export MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo + MBED_OS_PATH="$CHIP_ROOT"/third_party/mbed-os/repo # Set Mbed OS posix socket submodule path - export MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo + MBED_OS_POSIX_SOCKET_PATH="$CHIP_ROOT"/third_party/mbed-os-posix-socket/repo # Generate config file for selected target, toolchain and hardware - mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" -o "$MBED_CONFIG_PATH" --mbed-os-path "$MBED_OS_PATH" + mbed-tools configure -t "$TOOLCHAIN" -m "$TARGET_BOARD" -o "$BUILD_DIRECTORY" --mbed-os-path "$MBED_OS_PATH" # Remove old artifacts to force linking rm -rf "$BUILD_DIRECTORY/chip-"* - # Create output directory and copy config file there. - mkdir -p "$BUILD_DIRECTORY" - cp -f "$MBED_CONFIG_PATH"/mbed_config.cmake "$BUILD_DIRECTORY"/mbed_config.cmake - # Build application - cmake -S "./" -B "$BUILD_DIRECTORY" -GNinja -DCMAKE_BUILD_TYPE="$PROFILE" + cmake -S "./" -B "$BUILD_DIRECTORY" -GNinja -DCMAKE_BUILD_TYPE="$PROFILE" -DMBED_OS_PATH="$MBED_OS_PATH" -DMBED_OS_POSIX_SOCKET_PATH="$MBED_OS_POSIX_SOCKET_PATH" cmake --build "$BUILD_DIRECTORY" fi diff --git a/src/test_driver/mbed/.gitignore b/src/test_driver/mbed/.gitignore index 58f6e14fd6f5b2..414487d53eb835 100644 --- a/src/test_driver/mbed/.gitignore +++ b/src/test_driver/mbed/.gitignore @@ -1,2 +1 @@ -config/ build-*/ diff --git a/src/test_driver/mbed/CMakeLists.txt b/src/test_driver/mbed/CMakeLists.txt index b8600888e5a96a..f4b921528f6317 100644 --- a/src/test_driver/mbed/CMakeLists.txt +++ b/src/test_driver/mbed/CMakeLists.txt @@ -11,7 +11,7 @@ configure_file( @ONLY ) -set(MBED_PATH $ENV{MBED_OS_PATH} CACHE INTERNAL "") +set(MBED_PATH ${MBED_OS_PATH} CACHE INTERNAL "") set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "") set(APP_TARGET chip-mbed-unit-tests) @@ -20,7 +20,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) add_subdirectory(${MBED_PATH} ./mbed_build) -add_subdirectory($ENV{MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) +add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) add_executable(${APP_TARGET})