From 53208f6324904cc0b0114f532a534ab1664e3ffc Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Wed, 13 Mar 2019 20:01:28 +0800 Subject: [PATCH 1/3] make: Trim IDF_VER to fit a 32-bit field Closes: https://github.com/espressif/esp-idf/issues/3131 --- make/project.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/make/project.mk b/make/project.mk index a1307b0454..d9729c7194 100644 --- a/make/project.mk +++ b/make/project.mk @@ -270,10 +270,11 @@ endif # If we have `version.txt` then prefer that for extracting IDF version ifeq ("$(wildcard ${IDF_PATH}/version.txt)","") -IDF_VER := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty) +IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty) else -IDF_VER := `cat ${IDF_PATH}/version.txt` +IDF_VER_T := `cat ${IDF_PATH}/version.txt` endif +IDF_VER := $(shell echo "$(IDF_VER_T)" | cut -c 1-31) # Set default LDFLAGS EXTRA_LDFLAGS ?= From f8ca296438857ce0f77006e26ba675a16be6a8b0 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Wed, 13 Mar 2019 20:04:43 +0800 Subject: [PATCH 2/3] cmake: Trim IDF_VER to fit a 32-bit field --- tools/cmake/idf_functions.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/cmake/idf_functions.cmake b/tools/cmake/idf_functions.cmake index 3ea818ec80..01035a0b17 100644 --- a/tools/cmake/idf_functions.cmake +++ b/tools/cmake/idf_functions.cmake @@ -223,11 +223,13 @@ endfunction() function(idf_get_git_revision) git_describe(IDF_VER_GIT "${IDF_PATH}") if(EXISTS "${IDF_PATH}/version.txt") - file(STRINGS "${IDF_PATH}/version.txt" IDF_VER) + file(STRINGS "${IDF_PATH}/version.txt" IDF_VER_T) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${IDF_PATH}/version.txt") else() - set(IDF_VER ${IDF_VER_GIT}) + set(IDF_VER_T ${IDF_VER_GIT}) endif() + # cut IDF_VER to required 32 characters. + string(SUBSTRING "${IDF_VER_T}" 0 31 IDF_VER) message(STATUS "IDF_VER: ${IDF_VER}") add_definitions(-DIDF_VER=\"${IDF_VER}\") git_submodule_check("${IDF_PATH}") From 126d6b2de289ed71c9b6b6eae7f99cd76de289f7 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Wed, 13 Mar 2019 20:43:33 +0800 Subject: [PATCH 3/3] tools/test_build_system: Add tests with long IDF_VER --- tools/ci/test_build_system.sh | 2 +- tools/ci/test_build_system_cmake.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/ci/test_build_system.sh b/tools/ci/test_build_system.sh index 91c7e85df5..0915f23768 100755 --- a/tools/ci/test_build_system.sh +++ b/tools/ci/test_build_system.sh @@ -223,7 +223,7 @@ function run_tests() print_status "Can build without git installed on system" clean_build_dir # Make provision for getting IDF version - echo "custom-version-x.y" > ${IDF_PATH}/version.txt + echo "IDF_VER_0123456789_0123456789_0123456789" > ${IDF_PATH}/version.txt echo "project-version-w.z" > ${TESTDIR}/template/version.txt # Hide .gitmodules so that submodule check is avoided [ -f ${IDF_PATH}/.gitmodules ] && mv ${IDF_PATH}/.gitmodules ${IDF_PATH}/.gitmodules_backup diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 3dd1bea577..ae6bbd5baa 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -99,6 +99,7 @@ function run_tests() print_status "Rebuild when app version was changed" clean_build_dir # App version + echo "IDF_VER_0123456789_0123456789_0123456789" > ${IDF_PATH}/version.txt echo "project-version-1.0" > ${TESTDIR}/template/version.txt idf.py build || failure "Failed to build with app version" print_status "Change app version" @@ -112,6 +113,7 @@ function run_tests() take_build_snapshot idf.py build assert_not_rebuilt ${APP_BINS} ${BOOTLOADER_BINS} esp-idf/esp32/libesp32.a + rm -f ${IDF_PATH}/version.txt rm -f ${TESTDIR}/template/version.txt print_status "Get the version of app from git describe. Project is not inside IDF and do not have a tag only a hash commit."