diff --git a/.github/workflows/test_building_multiple_executables.yml b/.github/workflows/test_building_multiple_executables.yml new file mode 100644 index 0000000..7e3f645 --- /dev/null +++ b/.github/workflows/test_building_multiple_executables.yml @@ -0,0 +1,28 @@ +name: test building multiple executables with CMake + +on: [pull_request] + +jobs: + multiple-executables-example: + runs-on: ubuntu-latest + container: mbedos/mbed-os-env:latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build the multiple_executables example + run: | + mbedtools compile \ + -t GCC_ARM \ + -m ARM_MUSCA_S1 \ + --program-path tools/cmake/tests/multiple_executables/ \ + --mbed-os-path . + + - name: Verify the post-build command has run successfully on each image + run: | + APP1=tools/cmake/tests/multiple_executables/cmake_build/ARM_MUSCA_S1/develop/GCC_ARM/app1/app1.bin + APP2=tools/cmake/tests/multiple_executables/cmake_build/ARM_MUSCA_S1/develop/GCC_ARM/app2/app2.bin + BOOTLOADER=targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/bl2.bin + BOOTLOADER_SIZE=`du -b targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/bl2.bin | cut -f1` + cmp -n $BOOTLOADER_SIZE $APP1 $BOOTLOADER + cmp -n $BOOTLOADER_SIZE $APP2 $BOOTLOADER diff --git a/tools/cmake/tests/multiple_executables/CMakeLists.txt b/tools/cmake/tests/multiple_executables/CMakeLists.txt new file mode 100644 index 0000000..0070dfc --- /dev/null +++ b/tools/cmake/tests/multiple_executables/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright (c) 2021 Arm Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.19.0) + +set(MBED_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../..") +set(MBED_CONFIG_PATH "${CMAKE_CURRENT_BINARY_DIR}") + +include("${MBED_PATH}/tools/cmake/app.cmake") + +project(multiple_executables) + +add_subdirectory("${MBED_PATH}" "mbed-os-build") + +add_subdirectory(app1) +add_subdirectory(app2) diff --git a/tools/cmake/tests/multiple_executables/app1/CMakeLists.txt b/tools/cmake/tests/multiple_executables/app1/CMakeLists.txt new file mode 100644 index 0000000..70e97c3 --- /dev/null +++ b/tools/cmake/tests/multiple_executables/app1/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2021 Arm Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_executable(app1 main.cpp) + +target_link_libraries(app1 mbed-os) + +mbed_set_post_build(app1) diff --git a/tools/cmake/tests/multiple_executables/app1/main.cpp b/tools/cmake/tests/multiple_executables/app1/main.cpp new file mode 100644 index 0000000..b6b6d65 --- /dev/null +++ b/tools/cmake/tests/multiple_executables/app1/main.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2021 Arm Limited + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "mbed.h" + +int main() +{ + printf("Application 1\n"); + return 0; +} diff --git a/tools/cmake/tests/multiple_executables/app2/CMakeLists.txt b/tools/cmake/tests/multiple_executables/app2/CMakeLists.txt new file mode 100644 index 0000000..51d899c --- /dev/null +++ b/tools/cmake/tests/multiple_executables/app2/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2021 Arm Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +add_executable(app2 main.cpp) + +target_link_libraries(app2 mbed-os) + +mbed_set_post_build(app2) diff --git a/tools/cmake/tests/multiple_executables/app2/main.cpp b/tools/cmake/tests/multiple_executables/app2/main.cpp new file mode 100644 index 0000000..cc43503 --- /dev/null +++ b/tools/cmake/tests/multiple_executables/app2/main.cpp @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2021 Arm Limited + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "mbed.h" + +int main() +{ + printf("Application 2\n"); + return 0; +}