]> granicus.if.org Git - esp-idf/commitdiff
build: Add trimming PROJECT_VER and PROJECT_NAME vars
authorKonstantin Kondrashov <konstantin@espressif.com>
Fri, 7 Dec 2018 16:23:44 +0000 (00:23 +0800)
committerKonstantin Kondrashov <konstantin@espressif.com>
Tue, 11 Dec 2018 03:23:53 +0000 (11:23 +0800)
components/app_update/CMakeLists.txt
components/app_update/component.mk
tools/ci/test_build_system.sh
tools/ci/test_build_system_cmake.sh
tools/cmake/idf_functions.cmake

index d34462b9ac865dff7e5efb7d827ad7527f0d1011..400e5507a23e6f753e545885cd05f2615f7d6916 100644 (file)
@@ -10,10 +10,14 @@ register_component()
 # linker will ignore this structure as it has no other files depending on it.
 target_link_libraries(${COMPONENT_TARGET} "-u esp_app_desc")
 
+# cut PROJECT_VER and PROJECT_NAME to required 32 characters.
+string(SUBSTRING "${PROJECT_VER}" 0 31 PROJECT_VER_CUT)
+string(SUBSTRING "${PROJECT_NAME}" 0 31 PROJECT_NAME_CUT)
+
 set_source_files_properties(
     SOURCE "esp_app_desc.c"
     PROPERTIES COMPILE_DEFINITIONS 
-    PROJECT_VER=\"${PROJECT_VER}\")
+    "PROJECT_VER=\"${PROJECT_VER_CUT}\"; PROJECT_NAME=\"${PROJECT_NAME_CUT}\"")
 
 # Add custom target for generating empty otadata partition for flashing
 if(OTADATA_PARTITION_OFFSET AND OTADATA_PARTITION_SIZE)
index 924831e386c1094f6859057252c2c57782474175..28125e242becbfe8919fbb16961bfbd2214b6d31 100644 (file)
@@ -31,9 +31,14 @@ PROJECT_VER:= $(GET_PROJECT_VER)
 else
 PROJECT_VER:= $(PROJECT_VER)
 endif
-$(info App "$(PROJECT_NAME)" version: $(PROJECT_VER))
 
-NEW_DEFINES:= $(PROJECT_VER) $(PROJECT_NAME) $(IDF_VER)
+# cut PROJECT_VER and PROJECT_NAME to required 32 characters.
+PROJECT_VER_CUT  := $(shell echo $(PROJECT_VER)  | cut -c 1-31)
+PROJECT_NAME_CUT := $(shell echo $(PROJECT_NAME) | cut -c 1-31)
+
+$(info App "$(PROJECT_NAME_CUT)" version: $(PROJECT_VER_CUT))
+
+NEW_DEFINES:= $(PROJECT_VER_CUT) $(PROJECT_NAME_CUT) $(IDF_VER)
 ifeq ("$(wildcard ${TMP_DEFINES})","")
 OLD_DEFINES:=
 else
@@ -45,5 +50,5 @@ ifneq ("${NEW_DEFINES}", "${OLD_DEFINES}")
 $(shell echo $(NEW_DEFINES) > $(TMP_DEFINES); rm -f esp_app_desc.o;)
 endif
 
-esp_app_desc.o: CPPFLAGS += -D PROJECT_VER=\"$(PROJECT_VER)\" -D PROJECT_NAME=\"$(PROJECT_NAME)\"
+esp_app_desc.o: CPPFLAGS += -D PROJECT_VER=\"$(PROJECT_VER_CUT)\" -D PROJECT_NAME=\"$(PROJECT_NAME_CUT)\"
 endif
index 56daa383c8778cae043ed82e57264d08ab00feb8..58b721154932609b95d83d7ed9f4ea6f887e941d 100755 (executable)
@@ -247,7 +247,7 @@ function run_tests()
     assert_rebuilt ${APP_BINS}
     print_status "Change app version"
     take_build_snapshot
-       echo "project-version-2.0" > ${TESTDIR}/template/version.txt
+       echo "project-version-2.0(012345678901234567890123456789)" > ${TESTDIR}/template/version.txt
        make
     assert_rebuilt ${APP_BINS}
     assert_not_rebuilt ${BOOTLOADER_BINS} esp32/libesp32.a
index b308b9afe6e1ebe6598a594584d0db9257b24086..80c95a530ab1c32e051cc41720c72ee3b0db12e5 100755 (executable)
@@ -103,7 +103,7 @@ function run_tests()
     idf.py build || failure "Failed to build with app version"
     print_status "Change app version"
     take_build_snapshot
-       echo "project-version-2.0" > ${TESTDIR}/template/version.txt
+       echo "project-version-2.0(012345678901234567890123456789)" > ${TESTDIR}/template/version.txt
        idf.py build || failure "Failed to rebuild with changed app version"
     assert_rebuilt ${APP_BINS}
     assert_not_rebuilt ${BOOTLOADER_BINS} esp-idf/esp32/libesp32.a
index 82b00bbbac5febc77e98600184597b7a62eed1ea..a06aa81298e8ef99e0b7bf10b565b1f403af548a 100644 (file)
@@ -86,7 +86,6 @@ function(idf_set_global_compile_options)
     list(APPEND compile_options "${CMAKE_C_FLAGS}")
     list(APPEND c_compile_options "${CMAKE_C_FLAGS}")
     list(APPEND cxx_compile_options "${CMAKE_CXX_FLAGS}")
-    add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")
 
     if(CONFIG_OPTIMIZATION_LEVEL_RELEASE)
         list(APPEND compile_options "-Os")