Merge branch 'bugfix/git_describe_always_for_cmake' into 'master'

tools: Add --always option to git describe for Cmake

See merge request idf/esp-idf!4107
This commit is contained in:
Ivan Grokhotkov
2019-01-30 17:48:11 +08:00
4 changed files with 30 additions and 7 deletions

View File

@@ -35,22 +35,22 @@ PROJECT_VER:= $(PROJECT_VER)
endif endif
# cut PROJECT_VER and PROJECT_NAME to required 32 characters. # cut PROJECT_VER and PROJECT_NAME to required 32 characters.
PROJECT_VER_CUT := $(shell echo $(PROJECT_VER) | 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) PROJECT_NAME_CUT := $(shell echo "$(PROJECT_NAME)" | cut -c 1-31)
$(info App "$(PROJECT_NAME_CUT)" version: $(PROJECT_VER_CUT)) $(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})","") ifeq ("$(wildcard ${TMP_DEFINES})","")
OLD_DEFINES:= OLD_DEFINES:= ""
else else
OLD_DEFINES:= $(shell cat $(TMP_DEFINES)) OLD_DEFINES:= "$(shell cat $(TMP_DEFINES))"
endif endif
# If NEW_DEFINES (PROJECT_VER, PROJECT_NAME) were changed then rebuild only esp_app_desc. # 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;) $(shell echo $(NEW_DEFINES) > $(TMP_DEFINES); rm -f esp_app_desc.o;)
endif 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 endif

View File

@@ -251,8 +251,19 @@ function run_tests()
make make
assert_rebuilt ${APP_BINS} assert_rebuilt ${APP_BINS}
assert_not_rebuilt ${BOOTLOADER_BINS} esp32/libesp32.a 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 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" print_status "Build fails if partitions don't fit in flash"
sed -i.bak "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config sed -i.bak "s/CONFIG_ESPTOOLPY_FLASHSIZE.\+//" sdkconfig # remove all flashsize config
echo "CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y" >> sdkconfig # introduce undersize flash echo "CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y" >> sdkconfig # introduce undersize flash

View File

@@ -107,8 +107,19 @@ function run_tests()
idf.py build || failure "Failed to rebuild with changed app version" idf.py build || failure "Failed to rebuild with changed app version"
assert_rebuilt ${APP_BINS} assert_rebuilt ${APP_BINS}
assert_not_rebuilt ${BOOTLOADER_BINS} esp-idf/esp32/libesp32.a 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 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" print_status "Moving BUILD_DIR_BASE out of tree"
clean_build_dir clean_build_dir
OUTOFTREE_BUILD=${TESTDIR}/alt_build OUTOFTREE_BUILD=${TESTDIR}/alt_build

View File

@@ -112,6 +112,7 @@ function(git_describe _var _repo_dir)
"-C" "-C"
${_repo_dir} ${_repo_dir}
describe describe
"--always"
${hash} ${hash}
${ARGN} ${ARGN}
WORKING_DIRECTORY WORKING_DIRECTORY