examples: Move idf_as_lib sdkconfig file to the project directory

Also add some explanation about configuring the project in the README

Previously with the default build-esp32.sh script, the build directory was
deleted and recreated so the project would always be built with default config.
This commit is contained in:
Angus Gratton 2020-05-08 10:39:39 +10:00
parent e5fe4ffb08
commit 2a7dfb2320
3 changed files with 34 additions and 13 deletions

View File

@ -14,7 +14,7 @@ if("${TARGET}" STREQUAL "esp32")
# processing the component is needed for flashing related # processing the component is needed for flashing related
# targets and file generation # targets and file generation
COMPONENTS esp32 freertos esptool_py COMPONENTS esp32 freertos esptool_py
SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig SDKCONFIG ${CMAKE_CURRENT_LIST_DIR}/sdkconfig
BUILD_DIR ${CMAKE_BINARY_DIR}) BUILD_DIR ${CMAKE_BINARY_DIR})
else() else()
# Create stubs for esp32 and freertos, stub::esp32 and stub::freertos # Create stubs for esp32 and freertos, stub::esp32 and stub::freertos

View File

@ -44,6 +44,8 @@ or run [build.sh](./build.sh) to build for the host:
./build-esp32.sh ./build-esp32.sh
``` ```
Note: To build for a different target SoC, copy the `build-esp32.sh` file and change the `-DTARGET=esp32` clause on the second line.
or or
```bash ```bash
@ -68,6 +70,24 @@ or
./run.sh ./run.sh
``` ```
## Configuring this Example
To modify the example ESP-IDF project configuration, first create the CMake build directory. This can be done by running `build-esp32.sh` or by running only the first two lines in `build-esp32.sh` (which won't build the actual project yet).
Then execute the menuconfig build target in the build directory:
```bash
cmake --build build -- menuconfig
```
If using ninja directly:
```bash
ninja -C build menuconfig
```
Note: ESP-IDF project configuration isn't used by the host CMake builds, the config is only read when the project is built using the ESP-IDF build system.
--- ---
There is a discussion on using ESP-IDF in custom CMake projects in the programming guide under `API Guides` -> `Build System` -> `Using ESP-IDF in Custom CMake Projects` There is a discussion on using ESP-IDF in custom CMake projects in the programming guide under `API Guides` -> `Build System` -> `Using ESP-IDF in Custom CMake Projects`

View File

@ -455,35 +455,36 @@ function run_tests()
print_status "Building a project with CMake library imported and PSRAM workaround, all files compile with workaround" print_status "Building a project with CMake library imported and PSRAM workaround, all files compile with workaround"
# Test for libraries compiled within ESP-IDF # Test for libraries compiled within ESP-IDF
rm -rf build rm -r build sdkconfig
echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" >> sdkconfig.defaults echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" >> sdkconfig.defaults
echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> sdkconfig.defaults echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> sdkconfig.defaults
# note: we do 'reconfigure' here, as we just need to run cmake # note: we do 'reconfigure' here, as we just need to run cmake
idf.py -C $IDF_PATH/examples/build_system/cmake/import_lib -B `pwd`/build -D SDKCONFIG_DEFAULTS="`pwd`/sdkconfig.defaults" reconfigure idf.py -C $IDF_PATH/examples/build_system/cmake/import_lib -B `pwd`/build -D SDKCONFIG_DEFAULTS="`pwd`/sdkconfig.defaults" reconfigure
grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it" grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it"
(grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-issue) && failure "All commands in compile_commands.json should use PSRAM cache workaround" (grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-issue) && failure "All commands in compile_commands.json should use PSRAM cache workaround"
rm -r sdkconfig.defaults build rm -r build sdkconfig sdkconfig.defaults
# Test for external libraries in custom CMake projects with ESP-IDF components linked
mkdir build && touch build/sdkconfig print_status "Test for external libraries in custom CMake projects with ESP-IDF components linked"
echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" >> build/sdkconfig mkdir build
echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> build/sdkconfig IDF_AS_LIB=$IDF_PATH/examples/build_system/cmake/idf_as_lib
echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" > $IDF_AS_LIB/sdkconfig
echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> $IDF_AS_LIB/sdkconfig
# note: we just need to run cmake # note: we just need to run cmake
(cd build && cmake $IDF_PATH/examples/build_system/cmake/idf_as_lib -DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-esp32.cmake -DTARGET=esp32) (cd build && cmake $IDF_AS_LIB -DCMAKE_TOOLCHAIN_FILE=$IDF_PATH/tools/cmake/toolchain-esp32.cmake -DTARGET=esp32)
grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it" grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it"
(grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-issue) && failure "All commands in compile_commands.json should use PSRAM cache workaround" (grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-issue) && failure "All commands in compile_commands.json should use PSRAM cache workaround"
rm -r build
#Test for various strategies
for strat in MEMW NOPS DUPLDST; do for strat in MEMW NOPS DUPLDST; do
rm -r build sdkconfig.defaults sdkconfig sdkconfig.defaults.esp32 print_status "Test for external libraries in custom CMake projects with PSRAM strategy $strat"
rm -r build sdkconfig sdkconfig.defaults sdkconfig.defaults.esp32
stratlc=`echo $strat | tr A-Z a-z` stratlc=`echo $strat | tr A-Z a-z`
mkdir build && touch build/sdkconfig
echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" > sdkconfig.defaults echo "CONFIG_ESP32_SPIRAM_SUPPORT=y" > sdkconfig.defaults
echo "CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_$strat=y" >> sdkconfig.defaults echo "CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_$strat=y" >> sdkconfig.defaults
echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> sdkconfig.defaults echo "CONFIG_SPIRAM_CACHE_WORKAROUND=y" >> sdkconfig.defaults
# note: we do 'reconfigure' here, as we just need to run cmake # note: we do 'reconfigure' here, as we just need to run cmake
idf.py reconfigure idf.py reconfigure
grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it" grep -q '"command"' build/compile_commands.json || failure "compile_commands.json missing or has no no 'commands' in it"
(grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-strategy=$stratlc) && failure "All commands in compile_commands.json should use PSRAM cache workaround strategy $strat when selected" (grep '"command"' build/compile_commands.json | grep -v mfix-esp32-psram-cache-strategy=$stratlc) && failure "All commands in compile_commands.json should use PSRAM cache workaround strategy"
echo ${PWD} echo ${PWD}
rm -r sdkconfig.defaults build rm -r sdkconfig.defaults build
done done