include buildinfo generation in makefile
This commit is contained in:
parent
4b279939b6
commit
e0273185db
7
Makefile
7
Makefile
|
@ -274,7 +274,7 @@ endif # TARGET
|
||||||
#
|
#
|
||||||
|
|
||||||
ifndef TARGET
|
ifndef TARGET
|
||||||
all: toolchain sdk_pruned pre_build .subdirs
|
all: toolchain sdk_pruned pre_build buildinfo .subdirs
|
||||||
else
|
else
|
||||||
all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
|
all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
|
||||||
endif
|
endif
|
||||||
|
@ -412,6 +412,11 @@ pre_build:
|
||||||
@-rm -f $(APP_DIR)/modules/server-ca.crt.h
|
@-rm -f $(APP_DIR)/modules/server-ca.crt.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
.PHONY: buildinfo
|
||||||
|
|
||||||
|
buildinfo:
|
||||||
|
tools/update_buildinfo.sh
|
||||||
|
|
||||||
ifdef TARGET
|
ifdef TARGET
|
||||||
$(OBJODIR)/%.o: %.c
|
$(OBJODIR)/%.o: %.c
|
||||||
@mkdir -p $(dir $@);
|
@mkdir -p $(dir $@);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define __USER_VERSION_H__
|
#define __USER_VERSION_H__
|
||||||
|
|
||||||
#include "version.h" /* ESP firmware header */
|
#include "version.h" /* ESP firmware header */
|
||||||
#include "/tmp/buildinfo.h"
|
#include <buildinfo.h>
|
||||||
|
|
||||||
#define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR
|
#define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR
|
||||||
#define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR
|
#define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/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")"
|
BUILD_DATE="$(date "+%Y-%m-%d %H:%M")"
|
||||||
COMMIT_ID="$(git rev-parse HEAD)"
|
COMMIT_ID="$(git rev-parse HEAD)"
|
||||||
BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -r 's/[\/\\]+/_/g')"
|
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)
|
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
|
# 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"
|
SSL="true"
|
||||||
else
|
else
|
||||||
SSL="false"
|
SSL="false"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# figure out whether LFS configuration in user_config.h
|
# 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
|
if [ -z "$LFS" ]; then
|
||||||
LFS="disabled"
|
LFS="disabled"
|
||||||
else
|
else
|
||||||
|
@ -22,13 +25,13 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# figure out whether Int build is enabled in user_config.h
|
# 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
|
BUILD_TYPE=integer
|
||||||
else
|
else
|
||||||
BUILD_TYPE=float
|
BUILD_TYPE=float
|
||||||
fi
|
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
|
# create temp buildinfo
|
||||||
TEMPFILE=/tmp/buildinfo.h
|
TEMPFILE=/tmp/buildinfo.h
|
||||||
|
@ -40,7 +43,8 @@ EndOfMessage
|
||||||
echo "#define BUILDINFO_BRANCH \""$BRANCH"\"" >> $TEMPFILE
|
echo "#define BUILDINFO_BRANCH \""$BRANCH"\"" >> $TEMPFILE
|
||||||
echo "#define BUILDINFO_COMMIT_ID \""$COMMIT_ID"\"" >> $TEMPFILE
|
echo "#define BUILDINFO_COMMIT_ID \""$COMMIT_ID"\"" >> $TEMPFILE
|
||||||
echo "#define BUILDINFO_RELEASE \""$RELEASE"\"" >> $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 "$SSL >> $TEMPFILE
|
||||||
echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE
|
echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE
|
||||||
echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE
|
echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE
|
||||||
|
@ -53,7 +57,7 @@ cat >> $TEMPFILE << EndOfMessage2
|
||||||
"\tbranch: '" BUILDINFO_BRANCH "'\n" \\
|
"\tbranch: '" BUILDINFO_BRANCH "'\n" \\
|
||||||
"\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\
|
"\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\
|
||||||
"\trelease: '" BUILDINFO_RELEASE "'\n" \\
|
"\trelease: '" BUILDINFO_RELEASE "'\n" \\
|
||||||
"\trelease DTS: '" BUILDINFO_RELEASE_DTS "'\n" \\
|
"\trelease DTS: '" BUILDINFO_RELEASE_DTS_STR "'\n" \\
|
||||||
"\tSSL: '" BUILDINFO_SSL_STR "'\n" \\
|
"\tSSL: '" BUILDINFO_SSL_STR "'\n" \\
|
||||||
"\tBuild type: '" BUILDINFO_BUILD_TYPE "'\n" \\
|
"\tBuild type: '" BUILDINFO_BUILD_TYPE "'\n" \\
|
||||||
"\tLFS: '" BUILDINFO_LFS "'\n" \\
|
"\tLFS: '" BUILDINFO_LFS "'\n" \\
|
||||||
|
@ -61,8 +65,7 @@ cat >> $TEMPFILE << EndOfMessage2
|
||||||
|
|
||||||
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
|
echo "#endif /* __BUILDINFO_H__ */" >> $TEMPFILE
|
||||||
|
|
||||||
|
diff -q $TEMPFILE app/include/buildinfo.h || cp $TEMPFILE app/include/buildinfo.h
|
||||||
|
rm $TEMPFILE
|
Loading…
Reference in New Issue