From 2d22fbd4ff34ca821078dc2f85c7792211bff057 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 28 Aug 2018 11:10:48 +0800 Subject: [PATCH] cmake: Add missing example CMakeLists.txt files, CI check all examples have both --- .gitlab-ci.yml | 14 +++++++++++ .../bluetooth/a2dp_gatts_coex/CMakeLists.txt | 12 ++++++++++ .../ble_hid_device_demo/CMakeLists.txt | 11 +++++++++ .../get-started/hello_world/partitions.csv | 5 ++++ .../mcpwm/mcpwm_basic_config/CMakeLists.txt | 8 +++++++ .../mcpwm/mcpwm_bldc_control/CMakeLists.txt | 8 +++++++ .../mcpwm_brushed_dc_control/CMakeLists.txt | 8 +++++++ .../mcpwm/mcpwm_servo_control/CMakeLists.txt | 8 +++++++ .../spi_slave/receiver/CMakeLists.txt | 8 +++++++ .../spi_slave/sender}/CMakeLists.txt | 4 ++-- .../protocols/https_mbedtls/CMakeLists.txt | 14 +++++++++++ examples/system/esp_timer/CMakeLists.txt | 8 +++++++ .../ota/native_ota_example/CMakeLists.txt | 14 +++++++++++ .../ota/simple_ota_example/CMakeLists.txt | 14 +++++++++++ examples/wifi/simple_wifi/CMakeLists.txt | 8 +++++++ tools/ci/check_examples_cmake_make.sh | 24 +++++++++++++++++++ tools/ci/executable-list.txt | 1 + 17 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 examples/bluetooth/a2dp_gatts_coex/CMakeLists.txt create mode 100644 examples/bluetooth/ble_hid_device_demo/CMakeLists.txt create mode 100644 examples/get-started/hello_world/partitions.csv create mode 100644 examples/peripherals/mcpwm/mcpwm_basic_config/CMakeLists.txt create mode 100644 examples/peripherals/mcpwm/mcpwm_bldc_control/CMakeLists.txt create mode 100644 examples/peripherals/mcpwm/mcpwm_brushed_dc_control/CMakeLists.txt create mode 100644 examples/peripherals/mcpwm/mcpwm_servo_control/CMakeLists.txt create mode 100644 examples/peripherals/spi_slave/receiver/CMakeLists.txt rename examples/{system/ota => peripherals/spi_slave/sender}/CMakeLists.txt (79%) create mode 100644 examples/protocols/https_mbedtls/CMakeLists.txt create mode 100644 examples/system/esp_timer/CMakeLists.txt create mode 100644 examples/system/ota/native_ota_example/CMakeLists.txt create mode 100644 examples/system/ota/simple_ota_example/CMakeLists.txt create mode 100644 examples/wifi/simple_wifi/CMakeLists.txt create mode 100755 tools/ci/check_examples_cmake_make.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac3ecd984b..fe3437b1f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -473,6 +473,20 @@ check_permissions: script: - tools/ci/check-executable.sh +check_examples_cmake_make: + stage: deploy + image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG + tags: + - build + except: + - master + - /^release\/v/ + - /^v\d+\.\d+(\.\d+)?($|-)/ + dependencies: [] + before_script: *do_nothing_before + script: + - tools/ci/check_examples_cmake_make.sh + check_submodule_sync: stage: deploy image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG diff --git a/examples/bluetooth/a2dp_gatts_coex/CMakeLists.txt b/examples/bluetooth/a2dp_gatts_coex/CMakeLists.txt new file mode 100644 index 0000000000..3243515f39 --- /dev/null +++ b/examples/bluetooth/a2dp_gatts_coex/CMakeLists.txt @@ -0,0 +1,12 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS + main/bt_app_av.c + main/bt_app_core.c + main/main.c + ) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(bt_ble_coex) diff --git a/examples/bluetooth/ble_hid_device_demo/CMakeLists.txt b/examples/bluetooth/ble_hid_device_demo/CMakeLists.txt new file mode 100644 index 0000000000..9cacc34898 --- /dev/null +++ b/examples/bluetooth/ble_hid_device_demo/CMakeLists.txt @@ -0,0 +1,11 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/ble_hidd_demo_main.c + main/hid_dev.c + main/hid_device_le_prf.c + main/esp_hidd_prf_api.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(hidd_demos) diff --git a/examples/get-started/hello_world/partitions.csv b/examples/get-started/hello_world/partitions.csv new file mode 100644 index 0000000000..22cf97bacb --- /dev/null +++ b/examples/get-started/hello_world/partitions.csv @@ -0,0 +1,5 @@ +# Name, Type, SubType, Offset, Size, Flags +# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild +nvs, data, nvs, , 0x6000, +phy_init, data, phy, , 0x1000, +factory, app, factory, , 1M, diff --git a/examples/peripherals/mcpwm/mcpwm_basic_config/CMakeLists.txt b/examples/peripherals/mcpwm/mcpwm_basic_config/CMakeLists.txt new file mode 100644 index 0000000000..a3ee8315fb --- /dev/null +++ b/examples/peripherals/mcpwm/mcpwm_basic_config/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/mcpwm_basic_config_example.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(mcpwm_basic_config) diff --git a/examples/peripherals/mcpwm/mcpwm_bldc_control/CMakeLists.txt b/examples/peripherals/mcpwm/mcpwm_bldc_control/CMakeLists.txt new file mode 100644 index 0000000000..ed09e85b2c --- /dev/null +++ b/examples/peripherals/mcpwm/mcpwm_bldc_control/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/mcpwm_bldc_control_hall_sensor_example.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(mcpwm_bldc_control_hall_sensor) diff --git a/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/CMakeLists.txt b/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/CMakeLists.txt new file mode 100644 index 0000000000..4076c28394 --- /dev/null +++ b/examples/peripherals/mcpwm/mcpwm_brushed_dc_control/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/mcpwm_brushed_dc_control_example.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(mcpwm_brushed_dc_control) diff --git a/examples/peripherals/mcpwm/mcpwm_servo_control/CMakeLists.txt b/examples/peripherals/mcpwm/mcpwm_servo_control/CMakeLists.txt new file mode 100644 index 0000000000..fc3fab8093 --- /dev/null +++ b/examples/peripherals/mcpwm/mcpwm_servo_control/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/mcpwm_servo_control_example.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(mcpwm_servo_control) diff --git a/examples/peripherals/spi_slave/receiver/CMakeLists.txt b/examples/peripherals/spi_slave/receiver/CMakeLists.txt new file mode 100644 index 0000000000..21c05d9e67 --- /dev/null +++ b/examples/peripherals/spi_slave/receiver/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/app_main.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(spi-slave-receiver) diff --git a/examples/system/ota/CMakeLists.txt b/examples/peripherals/spi_slave/sender/CMakeLists.txt similarity index 79% rename from examples/system/ota/CMakeLists.txt rename to examples/peripherals/spi_slave/sender/CMakeLists.txt index 0b66883d12..0c95698e96 100644 --- a/examples/system/ota/CMakeLists.txt +++ b/examples/peripherals/spi_slave/sender/CMakeLists.txt @@ -2,7 +2,7 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(MAIN_SRCS main/ota_example_main.c) +set(MAIN_SRCS main/app_main.c) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(ota) +project(spi-slave-sender) diff --git a/examples/protocols/https_mbedtls/CMakeLists.txt b/examples/protocols/https_mbedtls/CMakeLists.txt new file mode 100644 index 0000000000..b564db2fa3 --- /dev/null +++ b/examples/protocols/https_mbedtls/CMakeLists.txt @@ -0,0 +1,14 @@ +# The following five lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/https_mbedtls_example_main.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(https-mbedtls) + +# Embed the server root certificate into the final binary +# +# (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.) +target_add_binary_data(https-mbedtls.elf + "main/server_root_cert.pem" TEXT) diff --git a/examples/system/esp_timer/CMakeLists.txt b/examples/system/esp_timer/CMakeLists.txt new file mode 100644 index 0000000000..5165f3d2a0 --- /dev/null +++ b/examples/system/esp_timer/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/esp_timer_example_main.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(esp_timer_example) diff --git a/examples/system/ota/native_ota_example/CMakeLists.txt b/examples/system/ota/native_ota_example/CMakeLists.txt new file mode 100644 index 0000000000..c4aa4d0d48 --- /dev/null +++ b/examples/system/ota/native_ota_example/CMakeLists.txt @@ -0,0 +1,14 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/native_ota_example.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(native_ota) + +# Embed the server root certificate into the final binary +# +# (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.) +target_add_binary_data(native_ota.elf + "../server_certs/ca_cert.pem" TEXT) diff --git a/examples/system/ota/simple_ota_example/CMakeLists.txt b/examples/system/ota/simple_ota_example/CMakeLists.txt new file mode 100644 index 0000000000..f15e708741 --- /dev/null +++ b/examples/system/ota/simple_ota_example/CMakeLists.txt @@ -0,0 +1,14 @@ +# The following four lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/simple_ota_example.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(simple_ota) + +# Embed the server root certificate into the final binary +# +# (If this was a component, we would set COMPONENT_EMBED_TXTFILES here.) +target_add_binary_data(simple_ota.elf + "../server_certs/ca_cert.pem" TEXT) diff --git a/examples/wifi/simple_wifi/CMakeLists.txt b/examples/wifi/simple_wifi/CMakeLists.txt new file mode 100644 index 0000000000..57158b16b8 --- /dev/null +++ b/examples/wifi/simple_wifi/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following five lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(MAIN_SRCS main/simple_wifi.c) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(simple_wifi) diff --git a/tools/ci/check_examples_cmake_make.sh b/tools/ci/check_examples_cmake_make.sh new file mode 100755 index 0000000000..2f2d844132 --- /dev/null +++ b/tools/ci/check_examples_cmake_make.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# While we support GNU Make & CMake together, check the same examples are present for both + +CMAKE_EXAMPLE_PATHS=$( find ${IDF_PATH}/examples/ -type f -name CMakeLists.txt | grep -v "/components/") +MAKE_EXAMPLE_PATHS=$( find ${IDF_PATH}/examples/ -type f -name Makefile ) + +# temporary: ignore ULP examples as no ULP toolchain support +CMAKE_EXAMPLE_PATHS=$( echo "$CMAKE_EXAMPLE_PATHS" | grep -v "/system/ulp") +MAKE_EXAMPLE_PATHS=$( echo "$MAKE_EXAMPLE_PATHS" | grep -v "/system/ulp") + +CMAKE_EXAMPLE_PATHS="$(/usr/bin/dirname $CMAKE_EXAMPLE_PATHS | sort -n)" +MAKE_EXAMPLE_PATHS="$(/usr/bin/dirname $MAKE_EXAMPLE_PATHS | sort -n)" + +MISMATCH=$(comm -3 <(echo "$MAKE_EXAMPLE_PATHS") <(echo "$CMAKE_EXAMPLE_PATHS")) + +if [ -n "$MISMATCH" ]; then + echo "Some examples are not in both CMake and GNU Make:" + echo "$MISMATCH" + exit 1 +fi + +echo "Example lists match" +exit 0 diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 54dcfaaffc..0cf23a8f7e 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -36,6 +36,7 @@ tools/kconfig/mconf tools/windows/eclipse_make.sh tools/ci/build_examples_cmake.sh tools/ci/test_build_system_cmake.sh +tools/ci/check_examples_cmake_make.sh tools/cmake/convert_to_cmake.py tools/cmake/run_cmake_lint.sh tools/idf.py