From bbe09cce0eff5dd2bc2270ca424e95595d187bb9 Mon Sep 17 00:00:00 2001 From: Aron Rubin Date: Wed, 31 Jan 2024 07:47:10 -0500 Subject: [PATCH] Separated library sources in cmake for selective. (#5136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Separated library sources in cmake for selective. * Reodered selective process to match CI script * Fixed missing SimpleBLE in library list * fix(cmake): Remove duplicate or non existing sources * fix(cmake): Remove required component --------- Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> --- CMakeLists.txt | 200 +++++++++++++++++++++++++++++++------------------ 1 file changed, 127 insertions(+), 73 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 802a8f87d2a..bba8b88b146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,29 +74,85 @@ set(CORE_SRCS cores/esp32/WString.cpp ) -set(LIBRARY_SRCS - libraries/ArduinoOTA/src/ArduinoOTA.cpp - libraries/AsyncUDP/src/AsyncUDP.cpp +set(ARDUINO_ALL_LIBRARIES + ArduinoOTA + AsyncUDP + BLE + BluetoothSerial + DNSServer + EEPROM + ESP_I2S + ESP_SR + ESPmDNS + Ethernet + FFat + FS + HTTPClient + HTTPUpdate + Insights + LittleFS + NetBIOS + Preferences + RainMaker + SD_MMC + SD + SimpleBLE + SPIFFS + SPI + Ticker + Update + USB + WebServer + WiFiClientSecure + WiFi + WiFiProv + Wire + ) + +set(ARDUINO_LIBRARY_ArduinoOTA_SRCS libraries/ArduinoOTA/src/ArduinoOTA.cpp) +set(ARDUINO_LIBRARY_ArduinoOTA_REQUIRES esp_https_ota) + +set(ARDUINO_LIBRARY_AsyncUDP_SRCS libraries/AsyncUDP/src/AsyncUDP.cpp) + +set(ARDUINO_LIBRARY_BluetoothSerial_SRCS libraries/BluetoothSerial/src/BluetoothSerial.cpp libraries/BluetoothSerial/src/BTAddress.cpp libraries/BluetoothSerial/src/BTAdvertisedDeviceSet.cpp - libraries/BluetoothSerial/src/BTScanResultsSet.cpp - libraries/DNSServer/src/DNSServer.cpp - libraries/EEPROM/src/EEPROM.cpp - libraries/ESP_I2S/src/ESP_I2S.cpp + libraries/BluetoothSerial/src/BTScanResultsSet.cpp) + +set(ARDUINO_LIBRARY_DNSServer_SRCS libraries/DNSServer/src/DNSServer.cpp) + +set(ARDUINO_LIBRARY_EEPROM_SRCS libraries/EEPROM/src/EEPROM.cpp) + +set(ARDUINO_LIBRARY_ESP_I2S_SRCS libraries/ESP_I2S/src/ESP_I2S.cpp) + +set(ARDUINO_LIBRARY_ESP_SR_SRCS libraries/ESP_SR/src/ESP_SR.cpp - libraries/ESP_SR/src/esp32-hal-sr.c - libraries/ESPmDNS/src/ESPmDNS.cpp - libraries/Ethernet/src/ETH.cpp - libraries/FFat/src/FFat.cpp + libraries/ESP_SR/src/esp32-hal-sr.c) + +set(ARDUINO_LIBRARY_ESPmDNS_SRCS libraries/ESPmDNS/src/ESPmDNS.cpp) + +set(ARDUINO_LIBRARY_Ethernet_SRCS libraries/Ethernet/src/ETH.cpp) + +set(ARDUINO_LIBRARY_FFat_SRCS libraries/FFat/src/FFat.cpp) + +set(ARDUINO_LIBRARY_FS_SRCS libraries/FS/src/FS.cpp - libraries/FS/src/vfs_api.cpp - libraries/HTTPClient/src/HTTPClient.cpp - libraries/HTTPUpdate/src/HTTPUpdate.cpp - libraries/LittleFS/src/LittleFS.cpp - libraries/Insights/src/Insights.cpp - libraries/NetBIOS/src/NetBIOS.cpp - libraries/Preferences/src/Preferences.cpp + libraries/FS/src/vfs_api.cpp) + +set(ARDUINO_LIBRARY_HTTPClient_SRCS libraries/HTTPClient/src/HTTPClient.cpp) + +set(ARDUINO_LIBRARY_HTTPUpdate_SRCS libraries/HTTPUpdate/src/HTTPUpdate.cpp) + +set(ARDUINO_LIBRARY_Insights_SRCS libraries/Insights/src/Insights.cpp) + +set(ARDUINO_LIBRARY_LittleFS_SRCS libraries/LittleFS/src/LittleFS.cpp) + +set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp) + +set(ARDUINO_LIBRARY_Preferences_SRCS libraries/Preferences/src/Preferences.cpp) + +set(ARDUINO_LIBRARY_RainMaker_SRCS libraries/RainMaker/src/RMaker.cpp libraries/RainMaker/src/RMakerNode.cpp libraries/RainMaker/src/RMakerParam.cpp @@ -104,17 +160,28 @@ set(LIBRARY_SRCS libraries/RainMaker/src/RMakerType.cpp libraries/RainMaker/src/RMakerQR.cpp libraries/RainMaker/src/RMakerUtils.cpp - libraries/RainMaker/src/AppInsights.cpp - libraries/SD_MMC/src/SD_MMC.cpp + libraries/RainMaker/src/AppInsights.cpp) + +set(ARDUINO_LIBRARY_SD_MMC_SRCS libraries/SD_MMC/src/SD_MMC.cpp) + +set(ARDUINO_LIBRARY_SD_SRCS libraries/SD/src/SD.cpp libraries/SD/src/sd_diskio.cpp - libraries/SD/src/sd_diskio_crc.c - libraries/SimpleBLE/src/SimpleBLE.cpp - libraries/SPIFFS/src/SPIFFS.cpp - libraries/SPI/src/SPI.cpp - libraries/Ticker/src/Ticker.cpp + libraries/SD/src/sd_diskio_crc.c) + +set(ARDUINO_LIBRARY_SimpleBLE_SRCS libraries/SimpleBLE/src/SimpleBLE.cpp) + +set(ARDUINO_LIBRARY_SPIFFS_SRCS libraries/SPIFFS/src/SPIFFS.cpp) + +set(ARDUINO_LIBRARY_SPI_SRCS libraries/SPI/src/SPI.cpp) + +set(ARDUINO_LIBRARY_Ticker_SRCS libraries/Ticker/src/Ticker.cpp) + +set(ARDUINO_LIBRARY_Update_SRCS libraries/Update/src/Updater.cpp - libraries/Update/src/HttpsOTAUpdate.cpp + libraries/Update/src/HttpsOTAUpdate.cpp) + +set(ARDUINO_LIBRARY_USB_SRCS libraries/USB/src/USBHID.cpp libraries/USB/src/USBMIDI.cpp libraries/USB/src/USBHIDMouse.cpp @@ -123,12 +190,18 @@ set(LIBRARY_SRCS libraries/USB/src/USBHIDConsumerControl.cpp libraries/USB/src/USBHIDSystemControl.cpp libraries/USB/src/USBHIDVendor.cpp - libraries/USB/src/USBVendor.cpp + libraries/USB/src/USBVendor.cpp) + +set(ARDUINO_LIBRARY_WebServer_SRCS libraries/WebServer/src/WebServer.cpp libraries/WebServer/src/Parsing.cpp - libraries/WebServer/src/detail/mimetable.cpp + libraries/WebServer/src/detail/mimetable.cpp) + +set(ARDUINO_LIBRARY_WiFiClientSecure_SRCS libraries/WiFiClientSecure/src/ssl_client.cpp - libraries/WiFiClientSecure/src/WiFiClientSecure.cpp + libraries/WiFiClientSecure/src/WiFiClientSecure.cpp) + +set(ARDUINO_LIBRARY_WiFi_SRCS libraries/WiFi/src/WiFiAP.cpp libraries/WiFi/src/WiFiClient.cpp libraries/WiFi/src/WiFi.cpp @@ -137,12 +210,13 @@ set(LIBRARY_SRCS libraries/WiFi/src/WiFiScan.cpp libraries/WiFi/src/WiFiServer.cpp libraries/WiFi/src/WiFiSTA.cpp - libraries/WiFi/src/WiFiUdp.cpp - libraries/WiFiProv/src/WiFiProv.cpp - libraries/Wire/src/Wire.cpp - ) + libraries/WiFi/src/WiFiUdp.cpp) + +set(ARDUINO_LIBRARY_WiFiProv_SRCS libraries/WiFiProv/src/WiFiProv.cpp) -set(BLE_SRCS +set(ARDUINO_LIBRARY_Wire_SRCS libraries/Wire/src/Wire.cpp) + +set(ARDUINO_LIBRARY_BLE_SRCS libraries/BLE/src/BLE2902.cpp libraries/BLE/src/BLE2904.cpp libraries/BLE/src/BLEAddress.cpp @@ -174,48 +248,28 @@ set(BLE_SRCS libraries/BLE/src/GeneralUtils.cpp ) -set(includedirs - variants/${CONFIG_ARDUINO_VARIANT}/ - cores/esp32/ - libraries/ArduinoOTA/src - libraries/AsyncUDP/src - libraries/BLE/src - libraries/BluetoothSerial/src - libraries/DNSServer/src - libraries/EEPROM/src - libraries/ESP_I2S/src - libraries/ESP_SR/src - libraries/ESP32/src - libraries/ESPmDNS/src - libraries/Ethernet/src - libraries/FFat/src - libraries/FS/src - libraries/HTTPClient/src - libraries/HTTPUpdate/src - libraries/LittleFS/src - libraries/Insights/src - libraries/NetBIOS/src - libraries/Preferences/src - libraries/RainMaker/src - libraries/SD_MMC/src - libraries/SD/src - libraries/SimpleBLE/src - libraries/SPIFFS/src - libraries/SPI/src - libraries/Ticker/src - libraries/Update/src - libraries/USB/src - libraries/WebServer/src - libraries/WiFiClientSecure/src - libraries/WiFi/src - libraries/WiFiProv/src - libraries/Wire/src - ) +set(ARDUINO_LIBRARIES_SRCS) +set(ARDUINO_LIBRARIES_REQUIRES) +set(ARDUINO_LIBRARIES_INCLUDEDIRS) +foreach(libname IN LISTS ARDUINO_ALL_LIBRARIES) + if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_${libname}) + if(ARDUINO_LIBRARY_${libname}_SRCS) + list(APPEND ARDUINO_LIBRARIES_SRCS ${ARDUINO_LIBRARY_${libname}_SRCS}) + endif() + if(ARDUINO_LIBRARY_${libname}_REQUIRES) + list(APPEND ARDUINO_LIBRARIES_REQUIRES ${ARDUINO_LIBRARY_${libname}_REQUIRES}) + endif() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/${libname}/src) + list(APPEND ARDUINO_LIBRARIES_INCLUDEDIRS libraries/${libname}/src) + endif() + endif() +endforeach() -set(srcs ${CORE_SRCS} ${LIBRARY_SRCS} ${BLE_SRCS}) +set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRARIES_INCLUDEDIRS}) +set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS}) set(priv_includes cores/esp32/libb64) set(requires spi_flash esp_partition 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) +set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid ${ARDUINO_LIBRARIES_REQUIRES}) idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})