Skip to content

Commit 16f4b0f

Browse files
me-no-devigrrvaleros
authoredJul 16, 2021
IDF master d93887f9f (#5336)
* Update toolchain * Update package_esp32_index.template.json * add optional component dependencies after Kconfig options are known (#5404) Until this commit, Kconfig options (e.g. CONFIG_TINYUSB_ENABLED) were used in conditions preceding idf_component_register to determine which components need to be added to `arduino` component requirements. However the Kconfig options aren't known at the early expansion stage, when the component CMakeLists.txt files are expanded the first time and requirements are evaluated. So all the conditions evaluated as if the options were not set. This commit changes the logic to only add these components as dependencies when the Kconfig options are known. Dependencies become "weak", which means that if one of the components isn't included into the build for some reason, it is not added as a dependency. This may happen, for example, if the component is not present in the `components` directory or is excluded by setting `COMPONENTS` variable in the project CMakeLists.txt file. This also ensures that if the component is not present, it will not be added as a dependency, and this will allow the build to proceed. Follow-up to #5391. Closes #5319. * IDF master d93887f9f * PlatformIO updates for CI (#5387) * Update PlatformIO CI build script - Switch to the latest toolchains 8.4.0 for ESP32, ESP32S2, ESP32C3 - Use PlatformIO from master branch for better robustness * Update package.json for PlatformIO Co-authored-by: Ivan Grokhotkov <[email protected]> Co-authored-by: Valerii Koval <[email protected]>
1 parent 780588d commit 16f4b0f

File tree

812 files changed

+29969
-7336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

812 files changed

+29969
-7336
lines changed
 

‎.github/scripts/install-platformio-esp32.sh

+30-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,43 @@
11
#!/bin/bash
22

33
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
4-
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git#feature/idf-master"
4+
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master"
5+
6+
XTENSA32_TOOLCHAIN_VERSION="8.4.0+2021r1"
7+
XTENSA32S2_TOOLCHAIN_VERSION="8.4.0+2021r1"
8+
RISCV_TOOLCHAIN_VERSION="8.4.0+2021r1"
9+
ESPTOOLPY_VERSION="~1.30100.0"
10+
ESPRESSIF_ORGANIZATION_NAME="espressif"
511

612
echo "Installing Python Wheel ..."
713
pip install wheel > /dev/null 2>&1
814

915
echo "Installing PlatformIO ..."
10-
pip install -U https://github.com/platformio/platformio/archive/develop.zip > /dev/null 2>&1
16+
pip install -U https://github.com/platformio/platformio/archive/master.zip > /dev/null 2>&1
1117

1218
echo "Installing Platform ESP32 ..."
13-
python -m platformio platform install $PLATFORMIO_ESP32_URL > /dev/null 2>&1
14-
15-
echo "Replacing the framework version ..."
16-
python -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoespressif32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()"
19+
python -m platformio platform install $PLATFORMIO_ESP32_URL > /dev/null 2>&1
20+
21+
echo "Replacing the package versions ..."
22+
replace_script="import json; import os;"
23+
replace_script+="fp=open(os.path.expanduser('~/.platformio/platforms/espressif32/platform.json'), 'r+');"
24+
replace_script+="data=json.load(fp);"
25+
# Use framework sources from the repository
26+
replace_script+="data['packages']['framework-arduinoespressif32']['version'] = '*';"
27+
replace_script+="del data['packages']['framework-arduinoespressif32']['owner'];"
28+
# Use toolchain packages from the "espressif" organization
29+
replace_script+="data['packages']['toolchain-xtensa-esp32']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
30+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
31+
replace_script+="data['packages']['toolchain-riscv32-esp']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
32+
# Update versions to use the upstream
33+
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$XTENSA32_TOOLCHAIN_VERSION';"
34+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$XTENSA32S2_TOOLCHAIN_VERSION';"
35+
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$RISCV_TOOLCHAIN_VERSION';"
36+
# esptool.py may require an upstream version (for now platformio is the owner)
37+
replace_script+="data['packages']['tool-esptoolpy']['version']='$ESPTOOLPY_VERSION';"
38+
# Save results
39+
replace_script+="fp.seek(0);fp.truncate();json.dump(data, fp, indent=2);fp.close()"
40+
python -c "$replace_script"
1741

1842
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
1943
echo "Linking Core..."

‎CMakeLists.txt

+31-18
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,16 @@ set(priv_includes cores/esp32/libb64)
163163
set(requires spi_flash mbedtls mdns esp_adc_cal wifi_provisioning nghttp)
164164
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support openssl bt esp_ipc)
165165

166-
if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED)
167-
list(APPEND priv_requires arduino_tinyusb)
168-
endif()
169-
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA)
170-
list(APPEND priv_requires esp_https_ota)
171-
endif()
172-
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LITTLEFS)
173-
if(CONFIG_LITTLEFS_PAGE_SIZE)
174-
list(APPEND priv_requires esp_littlefs)
175-
endif()
176-
endif()
177-
178166
idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires})
179167

180-
if(IDF_TARGET STREQUAL "esp32")
181-
target_compile_options(${COMPONENT_TARGET} PUBLIC -DARDUINO=10812 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32_DEV" -DARDUINO_VARIANT="esp32" -DESP32)
182-
endif()
183-
if(IDF_TARGET STREQUAL "esp32s2")
184-
target_compile_options(${COMPONENT_TARGET} PUBLIC -DARDUINO=10812 -DARDUINO_ESP32S2_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32S2_DEV" -DARDUINO_VARIANT="esp32s2" -DESP32)
185-
endif()
168+
string(TOUPPER ${CONFIG_IDF_TARGET} idf_target_caps)
169+
target_compile_options(${COMPONENT_TARGET} PUBLIC
170+
-DARDUINO=10812
171+
-DARDUINO_${idf_target_caps}_DEV
172+
-DARDUINO_ARCH_ESP32
173+
-DARDUINO_BOARD="${idf_target_caps}_DEV"
174+
-DARDUINO_VARIANT="${CONFIG_IDF_TARGET}"
175+
-DESP32)
186176

187177
if(CONFIG_AUTOSTART_ARDUINO)
188178
# in autostart mode, arduino-esp32 contains app_main() function and needs to
@@ -195,3 +185,26 @@ if(CONFIG_AUTOSTART_ARDUINO)
195185
# (As they are C++ symbol, we need to add the C++ mangled names.)
196186
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u _Z5setupv -u _Z4loopv")
197187
endif()
188+
189+
# This function adds a dependency on the given component if the component is included into the build.
190+
function(maybe_add_component component_name)
191+
idf_build_get_property(components BUILD_COMPONENTS)
192+
if (${component_name} IN_LIST components)
193+
idf_component_get_property(lib_name ${component_name} COMPONENT_LIB)
194+
target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name})
195+
endif()
196+
endfunction()
197+
198+
if(IDF_TARGET MATCHES "esp32" AND CONFIG_ESP_RMAKER_TASK_STACK)
199+
maybe_add_component(esp_rainmaker)
200+
maybe_add_component(qrcode)
201+
endif()
202+
if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED)
203+
maybe_add_component(arduino_tinyusb)
204+
endif()
205+
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA)
206+
maybe_add_component(esp_https_ota)
207+
endif()
208+
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_LITTLEFS)
209+
maybe_add_component(esp_littlefs)
210+
endif()

0 commit comments

Comments
 (0)