瀏覽代碼

Merge branch 'feature/trim_idf_ver_to_fit_32bit_field' into 'master'

tools/test_build_system: Trim IDF_VER to fit a 32-bit field

Closes IDFGH-682

See merge request idf/esp-idf!4477
Ivan Grokhotkov 6 年之前
父節點
當前提交
1b3373543f
共有 4 個文件被更改,包括 10 次插入5 次删除
  1. 3 2
      make/project.mk
  2. 1 1
      tools/ci/test_build_system.sh
  3. 2 0
      tools/ci/test_build_system_cmake.sh
  4. 4 2
      tools/cmake/idf_functions.cmake

+ 3 - 2
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 ?=

+ 1 - 1
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

+ 2 - 0
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."

+ 4 - 2
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}")