From 50d70673918809b636df8bd2cfc56adaa65afeba Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Fri, 30 Nov 2018 16:07:09 +0800 Subject: [PATCH 1/3] cmake: fix mconf path for existing mconf Fixes https://github.com/espressif/esp-idf/issues/2771 Fixes https://github.com/espressif/esp-idf/issues/2722 --- tools/cmake/kconfig.cmake | 121 +++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index 2b3dbcb8ba..05976aca66 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -13,6 +13,64 @@ macro(kconfig_set_variables) set(ROOT_KCONFIG ${IDF_PATH}/Kconfig) endmacro() +if(CMAKE_HOST_WIN32) + # Prefer a prebuilt mconf-idf on Windows + if(DEFINED ENV{MSYSTEM}) + find_program(WINPTY winpty) + else() + unset(WINPTY CACHE) # in case previous CMake run was in a tty and this one is not + endif() + find_program(MCONF mconf-idf) + + # Fall back to the old binary which was called 'mconf' not 'mconf-idf' + if(NOT MCONF) + find_program(MCONF mconf) + if(MCONF) + message(WARNING "Falling back to mconf binary '${MCONF}' not mconf-idf. " + "This is probably because an old version of IDF mconf is installed and this is fine. " + "However if there are config problems please check the Getting Started guide for your platform.") + endif() + endif() + + if(NOT MCONF) + find_program(NATIVE_GCC gcc) + if(NOT NATIVE_GCC) + message(FATAL_ERROR + "Windows requires a prebuilt mconf-idf for your platform " + "on the PATH, or an MSYS2 version of gcc on the PATH to build mconf-idf. " + "Consult the setup docs for ESP-IDF on Windows.") + endif() + elseif(WINPTY) + set(MCONF "${WINPTY}" "${MCONF}") + endif() +endif() + +if(NOT MCONF) + # Use the existing Makefile to build mconf (out of tree) when needed + # + set(MCONF ${CMAKE_BINARY_DIR}/kconfig_bin/mconf-idf) + + externalproject_add(mconf-idf + SOURCE_DIR ${IDF_PATH}/tools/kconfig + CONFIGURE_COMMAND "" + BINARY_DIR "kconfig_bin" + BUILD_COMMAND make -f ${IDF_PATH}/tools/kconfig/Makefile mconf-idf + BUILD_BYPRODUCTS ${MCONF} + INSTALL_COMMAND "" + EXCLUDE_FROM_ALL 1 + ) + + file(GLOB mconf_srcfiles ${IDF_PATH}/tools/kconfig/*.c) + externalproject_add_stepdependencies(mconf-idf build + ${mconf_srcfiles} + ${IDF_PATH}/tools/kconfig/Makefile + ${CMAKE_CURRENT_LIST_FILE}) + unset(mconf_srcfiles) + + set(menuconfig_depends DEPENDS mconf-idf) + +endif() + # Find all Kconfig files for all components function(kconfig_process_config) file(MAKE_DIRECTORY "${CONFIG_DIR}") @@ -68,7 +126,7 @@ function(kconfig_process_config) "IDF_CMAKE=y" "KCONFIG_CONFIG=${SDKCONFIG}" "IDF_TARGET=${IDF_TARGET}" - ${CMAKE_BINARY_DIR}/${MCONF} ${ROOT_KCONFIG} + ${MCONF} ${ROOT_KCONFIG} VERBATIM USES_TERMINAL) @@ -111,63 +169,4 @@ function(kconfig_process_config) ADDITIONAL_MAKE_CLEAN_FILES "${SDKCONFIG_HEADER}" "${SDKCONFIG_CMAKE}") -endfunction() - -if(CMAKE_HOST_WIN32) - # Prefer a prebuilt mconf-idf on Windows - if(DEFINED ENV{MSYSTEM}) - find_program(WINPTY winpty) - else() - unset(WINPTY CACHE) # in case previous CMake run was in a tty and this one is not - endif() - find_program(MCONF mconf-idf) - - # Fall back to the old binary which was called 'mconf' not 'mconf-idf' - if(NOT MCONF) - find_program(MCONF mconf) - if(MCONF) - message(WARNING "Falling back to mconf binary '${MCONF}' not mconf-idf. " - "This is probably because an old version of IDF mconf is installed and this is fine. " - "However if there are config problems please check the Getting Started guide for your platform.") - endif() - endif() - - if(NOT MCONF) - find_program(NATIVE_GCC gcc) - if(NOT NATIVE_GCC) - message(FATAL_ERROR - "Windows requires a prebuilt mconf-idf for your platform " - "on the PATH, or an MSYS2 version of gcc on the PATH to build mconf-idf. " - "Consult the setup docs for ESP-IDF on Windows.") - endif() - elseif(WINPTY) - set(MCONF "${WINPTY}" "${MCONF}") - endif() -endif() - -if(NOT MCONF) - # Use the existing Makefile to build mconf (out of tree) when needed - # - set(MCONF kconfig_bin/mconf-idf) - - externalproject_add(mconf-idf - SOURCE_DIR ${IDF_PATH}/tools/kconfig - CONFIGURE_COMMAND "" - BINARY_DIR "kconfig_bin" - BUILD_COMMAND make -f ${IDF_PATH}/tools/kconfig/Makefile mconf-idf - BUILD_BYPRODUCTS ${MCONF} - INSTALL_COMMAND "" - EXCLUDE_FROM_ALL 1 - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} # Put built files on top level build directory - ) - - file(GLOB mconf_srcfiles ${IDF_PATH}/tools/kconfig/*.c) - externalproject_add_stepdependencies(mconf-idf build - ${mconf_srcfiles} - ${IDF_PATH}/tools/kconfig/Makefile - ${CMAKE_CURRENT_LIST_FILE}) - unset(mconf_srcfiles) - - set(menuconfig_depends DEPENDS mconf-idf) - -endif() \ No newline at end of file +endfunction() \ No newline at end of file From d411175e47f104996e99724d45684eab8b664438 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Fri, 30 Nov 2018 19:48:05 +0800 Subject: [PATCH 2/3] mbedtls, cmake: set host as unix when building in msys --- components/mbedtls/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index e9cd58153b..e138c2df8f 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -18,6 +18,10 @@ endfunction() # Needed to for include_next includes to work from within mbedtls include_directories("${COMPONENT_PATH}/port/include") +if(MSYS) + set(CMAKE_HOST_UNIX 1) +endif() + # Import mbedtls library targets add_subdirectory(mbedtls) From deaecf164d8da2a8ebf8718f3ab167b597ded480 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Mon, 3 Dec 2018 18:11:13 +0800 Subject: [PATCH 3/3] make: fix unexpected operator warning --- components/app_update/Makefile.projbuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/app_update/Makefile.projbuild b/components/app_update/Makefile.projbuild index c9ee591373..26a987ac7c 100644 --- a/components/app_update/Makefile.projbuild +++ b/components/app_update/Makefile.projbuild @@ -9,11 +9,11 @@ PARTTOOL_PY := $(PYTHON) $(IDF_PATH)/components/partition_table/parttool.py BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin $(BLANK_OTA_DATA_FILE): partition_table_get_info $(PARTITION_TABLE_BIN) | check_python_dependencies - $(shell if [ $(OTA_DATA_OFFSET) != "" ] && [ $(OTA_DATA_SIZE) != "" ]; then \ + $(shell if [ "$(OTA_DATA_OFFSET)" != "" ] && [ "$(OTA_DATA_SIZE)" != "" ]; then \ $(PARTTOOL_PY) --partition-type data --partition-subtype ota --partition-table-file $(PARTITION_TABLE_BIN) \ -q generate_blank_partition_file --output $(BLANK_OTA_DATA_FILE); \ fi; ) - $(eval BLANK_OTA_DATA_FILE = $(shell if [ $(OTA_DATA_OFFSET) != "" ] && [ $(OTA_DATA_SIZE) != "" ]; then \ + $(eval BLANK_OTA_DATA_FILE = $(shell if [ "$(OTA_DATA_OFFSET)" != "" ] && [ "$(OTA_DATA_SIZE)" != "" ]; then \ echo $(BLANK_OTA_DATA_FILE); else echo " "; fi) ) blank_ota_data: $(BLANK_OTA_DATA_FILE)