From 22a41081e2b973c11b0842c9e69be21d38300c4f Mon Sep 17 00:00:00 2001
From: me-no-dev <hristo@espressif.com>
Date: Mon, 9 Oct 2023 12:59:50 +0300
Subject: [PATCH] Fix standalone component build and enable CI check for it

Fixes: https://github.com/espressif/arduino-esp32/issues/8740
---
 .github/workflows/push.yml | 54 +++++++++++++++++++-------------------
 CMakeLists.txt             |  2 +-
 idf_component.yml          |  4 +++
 3 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index fdb27d30495..feca2dfdf07 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -82,30 +82,30 @@ jobs:
     - name: Build Sketches
       run: bash ./.github/scripts/on-push.sh 1 1 #equal and non-zero to trigger PIO
 
-  # build-esp-idf-component:
-  #   name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
-  #   runs-on: ubuntu-20.04
-  #   strategy:
-  #     matrix:
-  #       # The version names here correspond to the versions of espressif/idf Docker image.
-  #       # See https://hub.docker.com/r/espressif/idf/tags and
-  #       # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
-  #       # for details.
-  #       idf_ver: ["release-v4.4"]
-  #       idf_target: ["esp32", "esp32s2", "esp32s3", "esp32c3"]
-  #   container: espressif/idf:${{ matrix.idf_ver }}
-  #   steps:
-  #     - name: Check out arduino-esp32 as a component
-  #       uses: actions/checkout@v3
-  #       with:
-  #         submodules: recursive
-  #         path: components/arduino-esp32
-  #     - name: Build
-  #       env:
-  #         IDF_TARGET: ${{ matrix.idf_target }}
-  #       shell: bash
-  #       run: |
-  #         . ${IDF_PATH}/export.sh
-  #         idf.py create-project test
-  #         echo CONFIG_FREERTOS_HZ=1000 > test/sdkconfig.defaults
-  #         idf.py -C test -DEXTRA_COMPONENT_DIRS=$PWD/components build
+  build-esp-idf-component:
+    name: Build with ESP-IDF ${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
+    runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+        # The version names here correspond to the versions of espressif/idf Docker image.
+        # See https://hub.docker.com/r/espressif/idf/tags and
+        # https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
+        # for details.
+        idf_ver: ["release-v5.1"]
+        idf_target: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c6", "esp32h2"]
+    container: espressif/idf:${{ matrix.idf_ver }}
+    steps:
+      - name: Check out arduino-esp32 as a component
+        uses: actions/checkout@v3
+        with:
+          submodules: recursive
+          path: components/arduino-esp32
+      - name: Build
+        env:
+          IDF_TARGET: ${{ matrix.idf_target }}
+        shell: bash
+        run: |
+          . ${IDF_PATH}/export.sh
+          idf.py create-project test
+          echo CONFIG_FREERTOS_HZ=1000 > test/sdkconfig.defaults
+          idf.py -C test -DEXTRA_COMPONENT_DIRS=$PWD/components build
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a0cca714048..198200807c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -209,7 +209,7 @@ set(includedirs
 
 set(srcs ${CORE_SRCS} ${LIBRARY_SRCS} ${BLE_SRCS})
 set(priv_includes cores/esp32/libb64)
-set(requires spi_flash mbedtls mdns wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
+set(requires spi_flash mbedtls wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser)
 set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid)
 
 idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
diff --git a/idf_component.yml b/idf_component.yml
index 5418fe0ab00..c19e8ec8a93 100644
--- a/idf_component.yml
+++ b/idf_component.yml
@@ -23,3 +23,7 @@ files:
     - "Kconfig.projbuild"
   exclude:
     - "**/*"
+dependencies:
+  idf: ">=5.1"
+  mdns: "^1.1.0"
+  chmorgan/esp-libhelix-mp3: "1.0.3"