From 187f9945bc22ab84a6728379f262c2ab0065a673 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Fri, 11 Jan 2019 18:09:12 +0800 Subject: [PATCH 1/3] tools: Add --always option to git describe for Cmake Fixed differences in getting of the project version for Make and Cmake. --- tools/cmake/third_party/GetGitRevisionDescription.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/cmake/third_party/GetGitRevisionDescription.cmake b/tools/cmake/third_party/GetGitRevisionDescription.cmake index 70aaedd706..51468b39b3 100644 --- a/tools/cmake/third_party/GetGitRevisionDescription.cmake +++ b/tools/cmake/third_party/GetGitRevisionDescription.cmake @@ -112,6 +112,7 @@ function(git_describe _var _repo_dir) "-C" ${_repo_dir} describe + "--always" ${hash} ${ARGN} WORKING_DIRECTORY From 3d1e064e1a6f4af7bcacf89f641a904d24abac12 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Wed, 23 Jan 2019 20:27:28 +0800 Subject: [PATCH 2/3] tools: Add unit tests --- tools/ci/test_build_system.sh | 11 +++++++++++ tools/ci/test_build_system_cmake.sh | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/ci/test_build_system.sh b/tools/ci/test_build_system.sh index 305a6e4899..99da318d61 100755 --- a/tools/ci/test_build_system.sh +++ b/tools/ci/test_build_system.sh @@ -251,7 +251,18 @@ function run_tests() make assert_rebuilt ${APP_BINS} assert_not_rebuilt ${BOOTLOADER_BINS} esp32/libesp32.a + + print_status "Re-building does not change app.bin" + take_build_snapshot + make + assert_not_rebuilt ${APP_BINS} ${BOOTLOADER_BINS} esp32/libesp32.a 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." + make >> log.log || failure "Failed to build" + version="App \"app-template\" version: " + version+=$(git describe --always --tags --dirty) + grep "${version}" log.log || failure "Project version should have a hash commit" print_status "Build fails if partitions don't fit in flash" sed -i.bak "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 46abc89d5c..3fb5cb103d 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -107,8 +107,19 @@ function run_tests() 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 + + print_status "Re-building does not change app.bin" + take_build_snapshot + idf.py build + assert_not_rebuilt ${APP_BINS} ${BOOTLOADER_BINS} esp-idf/esp32/libesp32.a 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." + idf.py build >> log.log || failure "Failed to build" + version="Project version: " + version+=$(git describe --always --tags --dirty) + grep "${version}" log.log || failure "Project version should have a hash commit" + print_status "Moving BUILD_DIR_BASE out of tree" clean_build_dir OUTOFTREE_BUILD=${TESTDIR}/alt_build From 00c1a40006d5e1620af0822e0fd53a50ed4a1a10 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Wed, 23 Jan 2019 21:46:11 +0800 Subject: [PATCH 3/3] app_update: Fix a handling of version as string --- components/app_update/component.mk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/app_update/component.mk b/components/app_update/component.mk index 4d4097f267..3914d42fd1 100644 --- a/components/app_update/component.mk +++ b/components/app_update/component.mk @@ -35,22 +35,22 @@ PROJECT_VER:= $(PROJECT_VER) endif # 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) +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) +NEW_DEFINES:= "$(PROJECT_VER_CUT) $(PROJECT_NAME_CUT) $(IDF_VER)" ifeq ("$(wildcard ${TMP_DEFINES})","") -OLD_DEFINES:= +OLD_DEFINES:= "" else -OLD_DEFINES:= $(shell cat $(TMP_DEFINES)) +OLD_DEFINES:= "$(shell cat $(TMP_DEFINES))" endif # If NEW_DEFINES (PROJECT_VER, PROJECT_NAME) were changed then rebuild only esp_app_desc. -ifneq ("${NEW_DEFINES}", "${OLD_DEFINES}") +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_CUT)\" -D PROJECT_NAME=\"$(PROJECT_NAME_CUT)\" +esp_app_desc.o: CPPFLAGS += -D PROJECT_VER=\""$(PROJECT_VER_CUT)"\" -D PROJECT_NAME=\""$(PROJECT_NAME_CUT)"\" endif