From e0273185db3c6392692f1eba3877e8f2999196bd Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 11 Jul 2019 22:49:26 +0200 Subject: [PATCH] include buildinfo generation in makefile --- Makefile | 7 ++++++- app/include/user_version.h | 2 +- tools/update_buildinfo.sh | 23 +++++++++++++---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 4e796ed2..67ff4ece 100644 --- a/Makefile +++ b/Makefile @@ -274,7 +274,7 @@ endif # TARGET # ifndef TARGET -all: toolchain sdk_pruned pre_build .subdirs +all: toolchain sdk_pruned pre_build buildinfo .subdirs else all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS) endif @@ -412,6 +412,11 @@ pre_build: @-rm -f $(APP_DIR)/modules/server-ca.crt.h endif +.PHONY: buildinfo + +buildinfo: + tools/update_buildinfo.sh + ifdef TARGET $(OBJODIR)/%.o: %.c @mkdir -p $(dir $@); diff --git a/app/include/user_version.h b/app/include/user_version.h index 254967d5..51221395 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -2,7 +2,7 @@ #define __USER_VERSION_H__ #include "version.h" /* ESP firmware header */ -#include "/tmp/buildinfo.h" +#include #define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR #define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index b4a08813..993c0f7d 100644 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +USER_MODULES_H=app/include/user_modules.h +USER_CONFIG_H=app/include/user_config.h + BUILD_DATE="$(date "+%Y-%m-%d %H:%M")" COMMIT_ID="$(git rev-parse HEAD)" BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -r 's/[\/\\]+/_/g')" @@ -7,14 +10,14 @@ RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed ' RELEASE_DTS=0$(git show -s --format=%cd --date=format:"%Y%m%d%H%M" HEAD) # figure out whether SSL is enabled in user_config.h -if grep -Eq "^#define CLIENT_SSL_ENABLE" ../app/include/user_config.h; then +if grep -Eq "^#define CLIENT_SSL_ENABLE" $USER_CONFIG_H; then SSL="true" else SSL="false" fi # figure out whether LFS configuration in user_config.h -LFS=$(grep "^#define LUA_FLASH_STORE" ../app/include/user_config.h | tr -d '\r' | cut -d ' ' -f 3-) +LFS=$(grep "^#define LUA_FLASH_STORE" $USER_CONFIG_H | tr -d '\r' | cut -d ' ' -f 3-) if [ -z "$LFS" ]; then LFS="disabled" else @@ -22,13 +25,13 @@ else fi # figure out whether Int build is enabled in user_config.h -if grep -Eq "^#define LUA_NUMBER_INTEGRAL" ../app/include/user_config.h; then +if grep -Eq "^#define LUA_NUMBER_INTEGRAL" $USER_CONFIG_H; then BUILD_TYPE=integer else BUILD_TYPE=float fi -MODULES=$(awk '/^[ \t]*#define LUA_USE_MODULES/{modules=modules sep tolower(substr($2,17));sep=","}END{if(length(modules)==0)modules="-";print modules}' ../app/include/user_modules.h | tr -d '\r') +MODULES=$(awk '/^[ \t]*#define LUA_USE_MODULES/{modules=modules sep tolower(substr($2,17));sep=","}END{if(length(modules)==0)modules="-";print modules}' $USER_MODULES_H | tr -d '\r') # create temp buildinfo TEMPFILE=/tmp/buildinfo.h @@ -40,7 +43,8 @@ EndOfMessage echo "#define BUILDINFO_BRANCH \""$BRANCH"\"" >> $TEMPFILE echo "#define BUILDINFO_COMMIT_ID \""$COMMIT_ID"\"" >> $TEMPFILE echo "#define BUILDINFO_RELEASE \""$RELEASE"\"" >> $TEMPFILE -echo "#define BUILDINFO_RELEASE_DTS "$RELEASE_DTS"" >> $TEMPFILE +echo "#define BUILDINFO_RELEASE_DTS "$RELEASE_DTS >> $TEMPFILE +echo "#define BUILDINFO_RELEASE_DTS_STR \""$RELEASE_DTS"\"" >> $TEMPFILE echo "#define BUILDINFO_SSL "$SSL >> $TEMPFILE echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE @@ -53,7 +57,7 @@ cat >> $TEMPFILE << EndOfMessage2 "\tbranch: '" BUILDINFO_BRANCH "'\n" \\ "\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\ "\trelease: '" BUILDINFO_RELEASE "'\n" \\ - "\trelease DTS: '" BUILDINFO_RELEASE_DTS "'\n" \\ + "\trelease DTS: '" BUILDINFO_RELEASE_DTS_STR "'\n" \\ "\tSSL: '" BUILDINFO_SSL_STR "'\n" \\ "\tBuild type: '" BUILDINFO_BUILD_TYPE "'\n" \\ "\tLFS: '" BUILDINFO_LFS "'\n" \\ @@ -61,8 +65,7 @@ cat >> $TEMPFILE << EndOfMessage2 EndOfMessage2 - - -#echo "#define NODE_VERSION_LONG \"\\n\\tbranch: '"$BRANCH"'\\n\\tcommit: '"$COMMIT_ID"'\\n\\tSSL: '"$SSL"'\\n\\tBuild type: '"$BUILD_TYPE"'\\n\\tLFS: '"$LFS"'\\n\\tmodules: '"$MODULES"'\\n\"" >> $TEMPFILE - echo "#endif /* __BUILDINFO_H__ */" >> $TEMPFILE + +diff -q $TEMPFILE app/include/buildinfo.h || cp $TEMPFILE app/include/buildinfo.h +rm $TEMPFILE \ No newline at end of file