From 21c35a1a973e6b39fba0f2a406df1e1f36e8fc6c Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 27 Jun 2019 16:44:25 +0200 Subject: [PATCH 01/21] Create buildinfo.h and return new Values in node.info --- .gitignore | 1 + app/include/user_version.h | 3 +- app/modules/node.c | 8 ++++- tools/update_buildinfo.sh | 64 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tools/update_buildinfo.sh diff --git a/.gitignore b/.gitignore index abca1f17..83360907 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ tools/toolchains/ .project .settings/ .vscode +buildinfo.h diff --git a/app/include/user_version.h b/app/include/user_version.h index f8ba27db..254967d5 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -2,6 +2,7 @@ #define __USER_VERSION_H__ #include "version.h" /* ESP firmware header */ +#include "/tmp/buildinfo.h" #define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR #define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR @@ -11,7 +12,7 @@ #define NODE_VERSION_STR(x) #x #define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x) -#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) +#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) "\n" NODE_VERSION_LONG #ifndef BUILD_DATE #define BUILD_DATE "unspecified" diff --git a/app/modules/node.c b/app/modules/node.c index a44f3fa4..a7cdd719 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -128,7 +128,13 @@ static int node_info( lua_State* L ) lua_pushinteger(L, flash_rom_get_size_byte() / 1024); // flash size in KB lua_pushinteger(L, flash_rom_get_mode()); lua_pushinteger(L, flash_rom_get_speed()); - return 8; + lua_pushstring(L, BUILDINFO_BRANCH); + lua_pushstring(L, BUILDINFO_COMMIT_ID); + lua_pushboolean(L, BUILDINFO_SSL); + lua_pushstring(L, BUILDINFO_LFS); + lua_pushstring(L, BUILDINFO_MODULES); + lua_pushstring(L, BUILDINFO_BUILD_TYPE); + return 14; } // Lua: chipid() diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh new file mode 100644 index 00000000..081fc543 --- /dev/null +++ b/tools/update_buildinfo.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +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')" +RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" + +# figure out whether SSL is enabled in user_config.h +if grep -Eq "^#define CLIENT_SSL_ENABLE" ../app/include/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-) +if [ -z "$LFS" ]; then + LFS="disabled" +else + LFS="Size: ${LFS}" + 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 + 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') + +# create temp buildinfo +TEMPFILE=/tmp/buildinfo.h +cat > $TEMPFILE << EndOfMessage +#ifndef __BUILDINFO_H__ +#define __BUILDINFO_H__ +EndOfMessage + +echo "#define BUILDINFO_BRANCH \""$BRANCH"\"" >> $TEMPFILE +echo "#define BUILDINFO_COMMIT_ID \""$COMMIT_ID"\"" >> $TEMPFILE +echo "#define BUILDINFO_RELEASE \""$RELEASE"\"" >> $TEMPFILE +echo "#define BUILDINFO_SSL "$SSL >> $TEMPFILE +echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE +echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE +echo "#define BUILDINFO_LFS \""$LFS"\"" >> $TEMPFILE +echo "#define BUILDINFO_MODULES \""$MODULES"\"" >> $TEMPFILE + +cat >> $TEMPFILE << EndOfMessage2 + +#define NODE_VERSION_LONG \\ + "\tbranch: '" BUILDINFO_BRANCH "'\n" \\ + "\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\ + "\tSSL: '" BUILDINFO_SSL_STR "'\n" \\ + "\tBuild type: '" BUILDINFO_BUILD_TYPE "'\n" \\ + "\tLFS: '" BUILDINFO_LFS "'\n" \\ + "\tmodules: '" BUILDINFO_MODULES "'\n" + +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 From 4b279939b6d9308c7343ee9fadf9d1a1f51b7328 Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 4 Jul 2019 20:26:15 +0200 Subject: [PATCH 02/21] Add release info --- app/modules/node.c | 5 ++++- tools/update_buildinfo.sh | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/modules/node.c b/app/modules/node.c index a7cdd719..b50fc0db 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -130,11 +130,14 @@ static int node_info( lua_State* L ) lua_pushinteger(L, flash_rom_get_speed()); lua_pushstring(L, BUILDINFO_BRANCH); lua_pushstring(L, BUILDINFO_COMMIT_ID); + lua_pushstring(L, BUILDINFO_RELEASE); + lua_pushnumber(L, BUILDINFO_RELEASE_DTS); lua_pushboolean(L, BUILDINFO_SSL); lua_pushstring(L, BUILDINFO_LFS); lua_pushstring(L, BUILDINFO_MODULES); lua_pushstring(L, BUILDINFO_BUILD_TYPE); - return 14; + + return 16; } // Lua: chipid() diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 081fc543..b4a08813 100644 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -4,6 +4,7 @@ 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')" RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" +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 @@ -39,6 +40,7 @@ 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_SSL "$SSL >> $TEMPFILE echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE @@ -50,6 +52,8 @@ cat >> $TEMPFILE << EndOfMessage2 #define NODE_VERSION_LONG \\ "\tbranch: '" BUILDINFO_BRANCH "'\n" \\ "\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\ + "\trelease: '" BUILDINFO_RELEASE "'\n" \\ + "\trelease DTS: '" BUILDINFO_RELEASE_DTS "'\n" \\ "\tSSL: '" BUILDINFO_SSL_STR "'\n" \\ "\tBuild type: '" BUILDINFO_BUILD_TYPE "'\n" \\ "\tLFS: '" BUILDINFO_LFS "'\n" \\ From e0273185db3c6392692f1eba3877e8f2999196bd Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 11 Jul 2019 22:49:26 +0200 Subject: [PATCH 03/21] 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 From e6c2f4cb5512bf9b69c1b820f3a3f5f59f4236e1 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 19:23:02 +0200 Subject: [PATCH 04/21] Include environment variable USER_PROLOG in user config default --- tools/update_buildinfo.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 993c0f7d..ba846d4b 100644 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -40,6 +40,11 @@ cat > $TEMPFILE << EndOfMessage #define __BUILDINFO_H__ EndOfMessage +if [ -n "$USER_PROLOG" ]; then + USER_PROLOG_LINE="$USER_PROLOG"\\n +fi + +echo "#define USER_PROLOG \""$USER_PROLOG"\"" >> $TEMPFILE echo "#define BUILDINFO_BRANCH \""$BRANCH"\"" >> $TEMPFILE echo "#define BUILDINFO_COMMIT_ID \""$COMMIT_ID"\"" >> $TEMPFILE echo "#define BUILDINFO_RELEASE \""$RELEASE"\"" >> $TEMPFILE @@ -52,8 +57,8 @@ echo "#define BUILDINFO_LFS \""$LFS"\"" >> $TEMPFILE echo "#define BUILDINFO_MODULES \""$MODULES"\"" >> $TEMPFILE cat >> $TEMPFILE << EndOfMessage2 - #define NODE_VERSION_LONG \\ + "$USER_PROLOG_LINE" \\ "\tbranch: '" BUILDINFO_BRANCH "'\n" \\ "\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\ "\trelease: '" BUILDINFO_RELEASE "'\n" \\ From ad90e8dd5101ebff8ee5213691ef85d6177865d0 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 20:59:59 +0200 Subject: [PATCH 05/21] tweal the startup message a bit --- app/include/user_version.h | 2 +- tools/update_buildinfo.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/include/user_version.h b/app/include/user_version.h index 51221395..20048c67 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -12,7 +12,7 @@ #define NODE_VERSION_STR(x) #x #define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x) -#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) "\n" NODE_VERSION_LONG +# define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) " " NODE_VERSION_LONG #ifndef BUILD_DATE #define BUILD_DATE "unspecified" diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index ba846d4b..dad660a1 100644 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -59,14 +59,14 @@ echo "#define BUILDINFO_MODULES \""$MODULES"\"" >> $TEMPFILE cat >> $TEMPFILE << EndOfMessage2 #define NODE_VERSION_LONG \\ "$USER_PROLOG_LINE" \\ - "\tbranch: '" BUILDINFO_BRANCH "'\n" \\ - "\tcommit: '" BUILDINFO_COMMIT_ID "'\n" \\ - "\trelease: '" BUILDINFO_RELEASE "'\n" \\ - "\trelease DTS: '" BUILDINFO_RELEASE_DTS_STR "'\n" \\ - "\tSSL: '" BUILDINFO_SSL_STR "'\n" \\ - "\tBuild type: '" BUILDINFO_BUILD_TYPE "'\n" \\ - "\tLFS: '" BUILDINFO_LFS "'\n" \\ - "\tmodules: '" BUILDINFO_MODULES "'\n" + "\tbranch: " BUILDINFO_BRANCH "\n" \\ + "\tcommit: " BUILDINFO_COMMIT_ID "\n" \\ + "\trelease: " BUILDINFO_RELEASE "\n" \\ + "\trelease DTS: " BUILDINFO_RELEASE_DTS_STR "\n" \\ + "\tSSL: " BUILDINFO_SSL_STR "\n" \\ + "\tBuild type: " BUILDINFO_BUILD_TYPE "\n" \\ + "\tLFS: " BUILDINFO_LFS "\n" \\ + "\tmodules: " BUILDINFO_MODULES "\n" EndOfMessage2 From bc4b177086d355f8c19c1300c7b7991d164ed4c5 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 21:36:44 +0200 Subject: [PATCH 06/21] Fix small issues and add execute bit for unix --- tools/update_buildinfo.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index dad660a1..426b11f8 100644 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -11,18 +11,18 @@ 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" $USER_CONFIG_H; then - SSL="true" - else - SSL="false" - fi + SSL="true" +else + SSL="false" +fi # figure out whether LFS configuration in user_config.h LFS=$(grep "^#define LUA_FLASH_STORE" $USER_CONFIG_H | tr -d '\r' | cut -d ' ' -f 3-) if [ -z "$LFS" ]; then - LFS="disabled" + LFS="disabled" else - LFS="Size: ${LFS}" - fi + LFS="Size: ${LFS}" +fi # figure out whether Int build is enabled in user_config.h if grep -Eq "^#define LUA_NUMBER_INTEGRAL" $USER_CONFIG_H; then @@ -58,19 +58,19 @@ echo "#define BUILDINFO_MODULES \""$MODULES"\"" >> $TEMPFILE cat >> $TEMPFILE << EndOfMessage2 #define NODE_VERSION_LONG \\ - "$USER_PROLOG_LINE" \\ - "\tbranch: " BUILDINFO_BRANCH "\n" \\ - "\tcommit: " BUILDINFO_COMMIT_ID "\n" \\ - "\trelease: " BUILDINFO_RELEASE "\n" \\ - "\trelease DTS: " BUILDINFO_RELEASE_DTS_STR "\n" \\ - "\tSSL: " BUILDINFO_SSL_STR "\n" \\ - "\tBuild type: " BUILDINFO_BUILD_TYPE "\n" \\ - "\tLFS: " BUILDINFO_LFS "\n" \\ - "\tmodules: " BUILDINFO_MODULES "\n" - + "$USER_PROLOG_LINE" \\ + "\tbranch: " BUILDINFO_BRANCH "\n" \\ + "\tcommit: " BUILDINFO_COMMIT_ID "\n" \\ + "\trelease: " BUILDINFO_RELEASE "\n" \\ + "\trelease DTS: " BUILDINFO_RELEASE_DTS_STR "\n" \\ + "\tSSL: " BUILDINFO_SSL_STR "\n" \\ + "\tBuild type: " BUILDINFO_BUILD_TYPE "\n" \\ + "\tLFS: " BUILDINFO_LFS "\n" \\ + "\tmodules: " BUILDINFO_MODULES "\n" + EndOfMessage2 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 +rm $TEMPFILE From 2d80042f91c21ca7cc99cd1a3811a6a774abdcb4 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 21:40:11 +0200 Subject: [PATCH 07/21] update file permission --- app/include/user_config.h | 4 ++-- app/include/user_modules.h | 36 +++++++++++++++++------------------ app/lwip/core/dhcp.c | 11 +++++++++++ lua_modules/bh1750/bh1750.lua | 26 ++++++++++++------------- tools/update_buildinfo.sh | 0 5 files changed, 44 insertions(+), 33 deletions(-) mode change 100644 => 100755 tools/update_buildinfo.sh diff --git a/app/include/user_config.h b/app/include/user_config.h index 4866e6a9..283ef9d4 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -46,7 +46,7 @@ // LUA_FLASH_STORE defines the default partition size if the NodeMCU partition // tool is not used. -//#define LUA_FLASH_STORE 0x10000 +#define LUA_FLASH_STORE 0x40000 // By default Lua executes the file init.lua at start up. The following // define allows you to replace this with an alternative startup. Warning: @@ -135,7 +135,7 @@ #define WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE // Enable use of the WiFi.monitor sub-module -//#define LUA_USE_MODULES_WIFI_MONITOR +#define LUA_USE_MODULES_WIFI_MONITOR // Whilst the DNS client details can be configured through the WiFi API, diff --git a/app/include/user_modules.h b/app/include/user_modules.h index 0b28dbe7..600add85 100644 --- a/app/include/user_modules.h +++ b/app/include/user_modules.h @@ -18,11 +18,11 @@ //#define LUA_USE_MODULES_BME280 //#define LUA_USE_MODULES_BME680 //#define LUA_USE_MODULES_COAP -//#define LUA_USE_MODULES_COLOR_UTILS +#define LUA_USE_MODULES_COLOR_UTILS //#define LUA_USE_MODULES_CRON -//#define LUA_USE_MODULES_CRYPTO +#define LUA_USE_MODULES_CRYPTO #define LUA_USE_MODULES_DHT -//#define LUA_USE_MODULES_ENCODER +#define LUA_USE_MODULES_ENCODER //#define LUA_USE_MODULES_ENDUSER_SETUP // USE_DNS in dhcpserver.h needs to be enabled for this module to work. #define LUA_USE_MODULES_FILE //#define LUA_USE_MODULES_GDBSTUB @@ -30,35 +30,35 @@ //#define LUA_USE_MODULES_GPIO_PULSE //#define LUA_USE_MODULES_HDC1080 //#define LUA_USE_MODULES_HMC5883L -//#define LUA_USE_MODULES_HTTP +#define LUA_USE_MODULES_HTTP //#define LUA_USE_MODULES_HX711 #define LUA_USE_MODULES_I2C -//#define LUA_USE_MODULES_L3G4200D +#define LUA_USE_MODULES_L3G4200D //#define LUA_USE_MODULES_MCP4725 -//#define LUA_USE_MODULES_MDNS -#define LUA_USE_MODULES_MQTT +#define LUA_USE_MODULES_MDNS +//#define LUA_USE_MODULES_MQTT #define LUA_USE_MODULES_NET #define LUA_USE_MODULES_NODE #define LUA_USE_MODULES_OW //#define LUA_USE_MODULES_PCM //#define LUA_USE_MODULES_PERF -//#define LUA_USE_MODULES_PIPE -//#define LUA_USE_MODULES_PWM +#define LUA_USE_MODULES_PIPE +#define LUA_USE_MODULES_PWM //#define LUA_USE_MODULES_PWM2 //#define LUA_USE_MODULES_RC //#define LUA_USE_MODULES_RFSWITCH //#define LUA_USE_MODULES_ROTARY -//#define LUA_USE_MODULES_RTCFIFO -//#define LUA_USE_MODULES_RTCMEM -//#define LUA_USE_MODULES_RTCTIME +#define LUA_USE_MODULES_RTCFIFO +#define LUA_USE_MODULES_RTCMEM +#define LUA_USE_MODULES_RTCTIME //#define LUA_USE_MODULES_SI7021 //#define LUA_USE_MODULES_SIGMA_DELTA -//#define LUA_USE_MODULES_SJSON -//#define LUA_USE_MODULES_SNTP +#define LUA_USE_MODULES_SJSON +#define LUA_USE_MODULES_SNTP //#define LUA_USE_MODULES_SOMFY #define LUA_USE_MODULES_SPI //#define LUA_USE_MODULES_SQLITE3 -//#define LUA_USE_MODULES_STRUCT +#define LUA_USE_MODULES_STRUCT //#define LUA_USE_MODULES_SWITEC //#define LUA_USE_MODULES_TCS34725 //#define LUA_USE_MODULES_TM1829 @@ -70,11 +70,11 @@ //#define LUA_USE_MODULES_UCG //#define LUA_USE_MODULES_WEBSOCKET #define LUA_USE_MODULES_WIFI -//#define LUA_USE_MODULES_WIFI_MONITOR +#define LUA_USE_MODULES_WIFI_MONITOR //#define LUA_USE_MODULES_WPS //#define LUA_USE_MODULES_WS2801 -//#define LUA_USE_MODULES_WS2812 -//#define LUA_USE_MODULES_WS2812_EFFECTS +#define LUA_USE_MODULES_WS2812 +#define LUA_USE_MODULES_WS2812_EFFECTS //#define LUA_USE_MODULES_XPT2046 //debug modules diff --git a/app/lwip/core/dhcp.c b/app/lwip/core/dhcp.c index 88ac82a6..526bebc7 100644 --- a/app/lwip/core/dhcp.c +++ b/app/lwip/core/dhcp.c @@ -593,6 +593,17 @@ dhcp_handle_ack(struct netif *netif) n++; } #endif /* LWIP_DNS */ +/* + if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_NTP)) { + ip4_addr_set_u32(&dhcp->offered_ntp_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_NTP))); + char buf[64]; + c_sprintf(buf, "%d.%d.%d.%d", IP2STR(&dhcp->offered_ntp_addr)); + platform_print_deprecation_note("found NTP ip", buf); + } + else + { + platform_print_deprecation_note("found NO NTP ip", "never"); + }*/ } /** Set a statically allocated struct dhcp to work with. diff --git a/lua_modules/bh1750/bh1750.lua b/lua_modules/bh1750/bh1750.lua index 5a06611e..175f87e7 100644 --- a/lua_modules/bh1750/bh1750.lua +++ b/lua_modules/bh1750/bh1750.lua @@ -9,19 +9,19 @@ local moduleName = ... local M = {} _G[moduleName] = M - --I2C slave address of GY-30 - local GY_30_address = 0x23 - -- i2c interface ID - local id = 0 - --LUX - local l - --CMD - local CMD = 0x10 - local init = false - --Make it more faster - local i2c = i2c - function M.init(sda, scl) - i2c.setup(id, sda, scl, i2c.SLOW) +--I2C slave address of GY-30 +local GY_30_address = 0x23 +-- i2c interface ID +local id = 0 +--LUX +local l +--CMD +local CMD = 0x10 +local init = false +--Make it more faster +local i2c = i2c +function M.init(sda, scl) + i2c.setup(id, sda, scl, i2c.SLOW) --print("i2c ok..") init = true end diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh old mode 100644 new mode 100755 From 299b24893296298159e9615d71d14994abff503b Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 21:52:33 +0200 Subject: [PATCH 08/21] Cover for failed RELEASE_DTS calculation --- tools/update_buildinfo.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 426b11f8..117ff0f1 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -7,7 +7,10 @@ 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')" RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" -RELEASE_DTS=0$(git show -s --format=%cd --date=format:"%Y%m%d%H%M" HEAD) +RELEASE_DTS=$(git show -s --format=%cd --date=format:"%Y%m%d%H%M" HEAD) +if [ -z "$RELEASE_DTS"]; then + RELEASE_DTS=0 +fi # figure out whether SSL is enabled in user_config.h if grep -Eq "^#define CLIENT_SSL_ENABLE" $USER_CONFIG_H; then From 6f1e366946efbe20c6866b83c7a69fb58628a3f3 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 21:55:44 +0200 Subject: [PATCH 09/21] Revert "update file permission" This reverts commit af9b123bc1c0603859caf9fcd6fcfdeeeb08dbce. --- app/include/user_config.h | 4 ++-- app/include/user_modules.h | 36 +++++++++++++++++------------------ app/lwip/core/dhcp.c | 11 ----------- lua_modules/bh1750/bh1750.lua | 26 ++++++++++++------------- tools/update_buildinfo.sh | 0 5 files changed, 33 insertions(+), 44 deletions(-) mode change 100755 => 100644 tools/update_buildinfo.sh diff --git a/app/include/user_config.h b/app/include/user_config.h index 283ef9d4..4866e6a9 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -46,7 +46,7 @@ // LUA_FLASH_STORE defines the default partition size if the NodeMCU partition // tool is not used. -#define LUA_FLASH_STORE 0x40000 +//#define LUA_FLASH_STORE 0x10000 // By default Lua executes the file init.lua at start up. The following // define allows you to replace this with an alternative startup. Warning: @@ -135,7 +135,7 @@ #define WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE // Enable use of the WiFi.monitor sub-module -#define LUA_USE_MODULES_WIFI_MONITOR +//#define LUA_USE_MODULES_WIFI_MONITOR // Whilst the DNS client details can be configured through the WiFi API, diff --git a/app/include/user_modules.h b/app/include/user_modules.h index 600add85..0b28dbe7 100644 --- a/app/include/user_modules.h +++ b/app/include/user_modules.h @@ -18,11 +18,11 @@ //#define LUA_USE_MODULES_BME280 //#define LUA_USE_MODULES_BME680 //#define LUA_USE_MODULES_COAP -#define LUA_USE_MODULES_COLOR_UTILS +//#define LUA_USE_MODULES_COLOR_UTILS //#define LUA_USE_MODULES_CRON -#define LUA_USE_MODULES_CRYPTO +//#define LUA_USE_MODULES_CRYPTO #define LUA_USE_MODULES_DHT -#define LUA_USE_MODULES_ENCODER +//#define LUA_USE_MODULES_ENCODER //#define LUA_USE_MODULES_ENDUSER_SETUP // USE_DNS in dhcpserver.h needs to be enabled for this module to work. #define LUA_USE_MODULES_FILE //#define LUA_USE_MODULES_GDBSTUB @@ -30,35 +30,35 @@ //#define LUA_USE_MODULES_GPIO_PULSE //#define LUA_USE_MODULES_HDC1080 //#define LUA_USE_MODULES_HMC5883L -#define LUA_USE_MODULES_HTTP +//#define LUA_USE_MODULES_HTTP //#define LUA_USE_MODULES_HX711 #define LUA_USE_MODULES_I2C -#define LUA_USE_MODULES_L3G4200D +//#define LUA_USE_MODULES_L3G4200D //#define LUA_USE_MODULES_MCP4725 -#define LUA_USE_MODULES_MDNS -//#define LUA_USE_MODULES_MQTT +//#define LUA_USE_MODULES_MDNS +#define LUA_USE_MODULES_MQTT #define LUA_USE_MODULES_NET #define LUA_USE_MODULES_NODE #define LUA_USE_MODULES_OW //#define LUA_USE_MODULES_PCM //#define LUA_USE_MODULES_PERF -#define LUA_USE_MODULES_PIPE -#define LUA_USE_MODULES_PWM +//#define LUA_USE_MODULES_PIPE +//#define LUA_USE_MODULES_PWM //#define LUA_USE_MODULES_PWM2 //#define LUA_USE_MODULES_RC //#define LUA_USE_MODULES_RFSWITCH //#define LUA_USE_MODULES_ROTARY -#define LUA_USE_MODULES_RTCFIFO -#define LUA_USE_MODULES_RTCMEM -#define LUA_USE_MODULES_RTCTIME +//#define LUA_USE_MODULES_RTCFIFO +//#define LUA_USE_MODULES_RTCMEM +//#define LUA_USE_MODULES_RTCTIME //#define LUA_USE_MODULES_SI7021 //#define LUA_USE_MODULES_SIGMA_DELTA -#define LUA_USE_MODULES_SJSON -#define LUA_USE_MODULES_SNTP +//#define LUA_USE_MODULES_SJSON +//#define LUA_USE_MODULES_SNTP //#define LUA_USE_MODULES_SOMFY #define LUA_USE_MODULES_SPI //#define LUA_USE_MODULES_SQLITE3 -#define LUA_USE_MODULES_STRUCT +//#define LUA_USE_MODULES_STRUCT //#define LUA_USE_MODULES_SWITEC //#define LUA_USE_MODULES_TCS34725 //#define LUA_USE_MODULES_TM1829 @@ -70,11 +70,11 @@ //#define LUA_USE_MODULES_UCG //#define LUA_USE_MODULES_WEBSOCKET #define LUA_USE_MODULES_WIFI -#define LUA_USE_MODULES_WIFI_MONITOR +//#define LUA_USE_MODULES_WIFI_MONITOR //#define LUA_USE_MODULES_WPS //#define LUA_USE_MODULES_WS2801 -#define LUA_USE_MODULES_WS2812 -#define LUA_USE_MODULES_WS2812_EFFECTS +//#define LUA_USE_MODULES_WS2812 +//#define LUA_USE_MODULES_WS2812_EFFECTS //#define LUA_USE_MODULES_XPT2046 //debug modules diff --git a/app/lwip/core/dhcp.c b/app/lwip/core/dhcp.c index 526bebc7..88ac82a6 100644 --- a/app/lwip/core/dhcp.c +++ b/app/lwip/core/dhcp.c @@ -593,17 +593,6 @@ dhcp_handle_ack(struct netif *netif) n++; } #endif /* LWIP_DNS */ -/* - if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_NTP)) { - ip4_addr_set_u32(&dhcp->offered_ntp_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_NTP))); - char buf[64]; - c_sprintf(buf, "%d.%d.%d.%d", IP2STR(&dhcp->offered_ntp_addr)); - platform_print_deprecation_note("found NTP ip", buf); - } - else - { - platform_print_deprecation_note("found NO NTP ip", "never"); - }*/ } /** Set a statically allocated struct dhcp to work with. diff --git a/lua_modules/bh1750/bh1750.lua b/lua_modules/bh1750/bh1750.lua index 175f87e7..5a06611e 100644 --- a/lua_modules/bh1750/bh1750.lua +++ b/lua_modules/bh1750/bh1750.lua @@ -9,19 +9,19 @@ local moduleName = ... local M = {} _G[moduleName] = M ---I2C slave address of GY-30 -local GY_30_address = 0x23 --- i2c interface ID -local id = 0 ---LUX -local l ---CMD -local CMD = 0x10 -local init = false ---Make it more faster -local i2c = i2c -function M.init(sda, scl) - i2c.setup(id, sda, scl, i2c.SLOW) + --I2C slave address of GY-30 + local GY_30_address = 0x23 + -- i2c interface ID + local id = 0 + --LUX + local l + --CMD + local CMD = 0x10 + local init = false + --Make it more faster + local i2c = i2c + function M.init(sda, scl) + i2c.setup(id, sda, scl, i2c.SLOW) --print("i2c ok..") init = true end diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh old mode 100755 new mode 100644 From 6a78546707760d98475a6ecc0985ad234a3cfc2d Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 21:57:16 +0200 Subject: [PATCH 10/21] update file permission --- tools/update_buildinfo.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/update_buildinfo.sh diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh old mode 100644 new mode 100755 From 063988f12a21eaeb55912b54aa8a23866731c4bf Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 12 Jul 2019 22:39:04 +0200 Subject: [PATCH 11/21] Change DTS to string since it is too big as number --- app/include/user_version.h | 2 ++ app/modules/node.c | 2 +- tools/update_buildinfo.sh | 8 ++------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/include/user_version.h b/app/include/user_version.h index 20048c67..33817c5c 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -13,6 +13,8 @@ #define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x) # define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) " " NODE_VERSION_LONG +// Leave the space after # in the line above. It busts replacement of NODE_VERSION in the docker build which is not needed anymore with this PR. +// Can be removed when the script is adapted #ifndef BUILD_DATE #define BUILD_DATE "unspecified" diff --git a/app/modules/node.c b/app/modules/node.c index b50fc0db..af39f2c6 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -131,7 +131,7 @@ static int node_info( lua_State* L ) lua_pushstring(L, BUILDINFO_BRANCH); lua_pushstring(L, BUILDINFO_COMMIT_ID); lua_pushstring(L, BUILDINFO_RELEASE); - lua_pushnumber(L, BUILDINFO_RELEASE_DTS); + lua_pushstring(L, BUILDINFO_RELEASE_DTS); lua_pushboolean(L, BUILDINFO_SSL); lua_pushstring(L, BUILDINFO_LFS); lua_pushstring(L, BUILDINFO_MODULES); diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 117ff0f1..9e8a553a 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -8,9 +8,6 @@ COMMIT_ID="$(git rev-parse HEAD)" BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -r 's/[\/\\]+/_/g')" RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" RELEASE_DTS=$(git show -s --format=%cd --date=format:"%Y%m%d%H%M" HEAD) -if [ -z "$RELEASE_DTS"]; then - RELEASE_DTS=0 -fi # figure out whether SSL is enabled in user_config.h if grep -Eq "^#define CLIENT_SSL_ENABLE" $USER_CONFIG_H; then @@ -51,8 +48,7 @@ echo "#define USER_PROLOG \""$USER_PROLOG"\"" >> $TEMPFILE 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_STR \""$RELEASE_DTS"\"" >> $TEMPFILE +echo "#define BUILDINFO_RELEASE_DTS \""$RELEASE_DTS"\"" >> $TEMPFILE echo "#define BUILDINFO_SSL "$SSL >> $TEMPFILE echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE @@ -65,7 +61,7 @@ cat >> $TEMPFILE << EndOfMessage2 "\tbranch: " BUILDINFO_BRANCH "\n" \\ "\tcommit: " BUILDINFO_COMMIT_ID "\n" \\ "\trelease: " BUILDINFO_RELEASE "\n" \\ - "\trelease DTS: " BUILDINFO_RELEASE_DTS_STR "\n" \\ + "\trelease DTS: " BUILDINFO_RELEASE_DTS "\n" \\ "\tSSL: " BUILDINFO_SSL_STR "\n" \\ "\tBuild type: " BUILDINFO_BUILD_TYPE "\n" \\ "\tLFS: " BUILDINFO_LFS "\n" \\ From 1c94629ea78544898ae4692bcf3eccb30cfcb8aa Mon Sep 17 00:00:00 2001 From: Gregor Date: Sat, 13 Jul 2019 22:46:58 +0200 Subject: [PATCH 12/21] Added documantation --- docs/modules/node.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/modules/node.md b/docs/modules/node.md index deaa007e..daea47b8 100644 --- a/docs/modules/node.md +++ b/docs/modules/node.md @@ -272,7 +272,7 @@ system heap size left in bytes (number) ## node.info() -Returns NodeMCU version, chipid, flashid, flash size, flash mode, flash speed, and Lua File Store (LFS) usage statics. +Returns NodeMCU version, chipid, flashid, flash size, flash mode, flash speed, branch, git commit_id, release, release_dts, ssl, lfs info, modules and the build_type. #### Syntax `node.info()` @@ -289,6 +289,15 @@ none - `flashsize` (number) - `flashmode` (number) - `flashspeed` (number) + - `branch` (string) + - `git commit_id` (string) + - `release` (string) Release name +additional commits e.g. "2.0.0-master_20170202 +403" + - `release_dts` (string) in an ordering format. e.g. "201908111200" + - `ssl` (boolean) + - `lfs info` (string) "disabled" or "Size: {whatever is in user_config.h}" + - `modules` (string) comma separated list + - `build_type` (string) `integer` or `float` + #### Example ```lua From 13f22e1f8ea6d40d93919039528572b4343750bc Mon Sep 17 00:00:00 2001 From: Gregor Date: Sat, 13 Jul 2019 23:02:29 +0200 Subject: [PATCH 13/21] Also adapt documentation for building --- docs/build.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/build.md b/docs/build.md index 206f9dd9..dc1ddabc 100644 --- a/docs/build.md +++ b/docs/build.md @@ -93,12 +93,14 @@ make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL .... ``` ### Tag Your Build -Identify your firmware builds by editing `app/include/user_version.h` +Identify your firmware builds by setting the environment variable `USER_PROLOG`. +You may also edit `app/include/user_version.h`. The variable `USER_PROLOG` will be included in `NODE_VERSION_LONG`. ```c -#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) +#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) " " NODE_VERSION_LONG + #ifndef BUILD_DATE -#define BUILD_DATE "YYYYMMDD" +#define BUILD_DATE "unspecified" #endif ``` From 1d976e54f2a68b934dd435344b40a8edc6ef671f Mon Sep 17 00:00:00 2001 From: Gregor Date: Sat, 13 Jul 2019 23:26:49 +0200 Subject: [PATCH 14/21] inprove USER_PROLOG handling --- tools/update_buildinfo.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 9e8a553a..d07c51dd 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -40,10 +40,6 @@ cat > $TEMPFILE << EndOfMessage #define __BUILDINFO_H__ EndOfMessage -if [ -n "$USER_PROLOG" ]; then - USER_PROLOG_LINE="$USER_PROLOG"\\n -fi - echo "#define USER_PROLOG \""$USER_PROLOG"\"" >> $TEMPFILE echo "#define BUILDINFO_BRANCH \""$BRANCH"\"" >> $TEMPFILE echo "#define BUILDINFO_COMMIT_ID \""$COMMIT_ID"\"" >> $TEMPFILE @@ -57,7 +53,7 @@ echo "#define BUILDINFO_MODULES \""$MODULES"\"" >> $TEMPFILE cat >> $TEMPFILE << EndOfMessage2 #define NODE_VERSION_LONG \\ - "$USER_PROLOG_LINE" \\ + "$USER_PROLOG \n" \\ "\tbranch: " BUILDINFO_BRANCH "\n" \\ "\tcommit: " BUILDINFO_COMMIT_ID "\n" \\ "\trelease: " BUILDINFO_RELEASE "\n" \\ From dd1f8752839495337c4aa56e34cd0789c8126a22 Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 19 Jul 2019 08:53:14 +0200 Subject: [PATCH 15/21] Fix typos and small enhancement of docu --- docs/modules/node.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/modules/node.md b/docs/modules/node.md index daea47b8..ee04db21 100644 --- a/docs/modules/node.md +++ b/docs/modules/node.md @@ -250,13 +250,17 @@ Get the current LFS and SPIFFS partition information. none #### Returns -An array containing entries for `lfs_addr`, `lfs_size`, `spiffs_addr` and `spiffs_size`. The address values are offsets relative to the startof the Flash memory. +An array containing entries for `lfs_addr`, `lfs_size`, `spiffs_addr` and `spiffs_size`. The address values are offsets relative to the start of the Flash memory. #### Example ```lua print("The LFS size is " .. node.getpartitiontable().lfs_size) ``` +#### See also +[`node.setpartitiontable()`](#nodesetpartitiontable) + + ## node.heap() Returns the current available heap size in bytes. Note that due to fragmentation, actual allocations of this size may not be possible. @@ -445,7 +449,7 @@ Sets the current LFS and / or SPIFFS partition information. This function is typically only used once during initial provisioning after first flashing the firmware. It does some consistency checks to validate the specified parameters, and it then reboots the ESP module to load the new partition table. If the LFS or SPIFFS regions have changed then you will need to reload LFS, reformat the SPIFSS and reload its contents. #### Parameters -An array containing one or more of the following enties. The address values are byte offsets relative to the startof the Flash memory. The size values are in bytes. Note that these parameters must be a multiple of 8Kb to align to Flash page boundaries. +An array containing one or more of the following enties. The address values are byte offsets relative to the start of the Flash memory. The size values are in bytes. Note that these parameters must be a multiple of 8Kb to align to Flash page boundaries. - `lfs_addr`. The base address of the LFS region. - `lfs_size`. The size of the LFS region. - `spiffs_addr`. The base address of the SPIFFS region. @@ -459,6 +463,10 @@ Not applicable. The ESP module will be rebooted for a valid new set, or a Lua e node.setpartitiontable{lfs_size = 0x20000, spiffs_addr = 0x120000, spiffs_size = 0x20000} ``` +#### See also +[`node.getpartitiontable()`](#nodegetpartitiontable) + + ## node.sleep() From 5fafa6378c251cd8f03e05bfd7a20bdc67a27bfc Mon Sep 17 00:00:00 2001 From: Gregor Date: Fri, 19 Jul 2019 21:24:22 +0200 Subject: [PATCH 16/21] change to better UI and get information directly from .h file --- .gitignore | 3 ++ app/modules/node.c | 99 ++++++++++++++++++++++++++++++++------- app/user/user_main.c | 2 +- docs/modules/node.md | 67 ++++++++++++++++++-------- tools/update_buildinfo.sh | 54 ++++++++++----------- 5 files changed, 160 insertions(+), 65 deletions(-) diff --git a/.gitignore b/.gitignore index 83360907..736ae691 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ local/ user_config.h server-ca.crt luac.cross +luac.cross.int uz_unzip uz_zip tools/toolchains/ @@ -15,4 +16,6 @@ tools/toolchains/ .project .settings/ .vscode + +#ignore temp file for build infos buildinfo.h diff --git a/app/modules/node.c b/app/modules/node.c index af39f2c6..962e6073 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -120,24 +120,87 @@ static int node_sleep( lua_State* L ) #endif //PMSLEEP_ENABLE static int node_info( lua_State* L ) { - lua_pushinteger(L, NODE_VERSION_MAJOR); - lua_pushinteger(L, NODE_VERSION_MINOR); - lua_pushinteger(L, NODE_VERSION_REVISION); - lua_pushinteger(L, system_get_chip_id()); // chip id - lua_pushinteger(L, spi_flash_get_id()); // flash id - lua_pushinteger(L, flash_rom_get_size_byte() / 1024); // flash size in KB - lua_pushinteger(L, flash_rom_get_mode()); - lua_pushinteger(L, flash_rom_get_speed()); - lua_pushstring(L, BUILDINFO_BRANCH); - lua_pushstring(L, BUILDINFO_COMMIT_ID); - lua_pushstring(L, BUILDINFO_RELEASE); - lua_pushstring(L, BUILDINFO_RELEASE_DTS); - lua_pushboolean(L, BUILDINFO_SSL); - lua_pushstring(L, BUILDINFO_LFS); - lua_pushstring(L, BUILDINFO_MODULES); - lua_pushstring(L, BUILDINFO_BUILD_TYPE); - - return 16; + const char* options[] = {"hw", "sw_version", "build_config", "legacy", NULL}; + int option = luaL_checkoption (L, 1, options[3], options); + + switch (option) { + case 0: { // hw + lua_createtable (L, 0, 5); + int table_index = lua_gettop(L); + lua_pushliteral(L, "chip_id"); + lua_pushinteger(L, system_get_chip_id()); // chip id + lua_settable(L, table_index); + lua_pushliteral(L, "flash_id"); + lua_pushinteger(L, spi_flash_get_id()); // flash id + lua_settable(L, table_index); + lua_pushliteral(L, "flash_size"); + lua_pushinteger(L, flash_rom_get_size_byte() / 1024); // flash size in KB + lua_settable(L, table_index); + lua_pushliteral(L, "flash_mode"); + lua_pushinteger(L, flash_rom_get_mode()); + lua_settable(L, table_index); + lua_pushliteral(L, "flash_speed"); + lua_pushinteger(L, flash_rom_get_speed()); + lua_settable(L, table_index); + return 1; + } + case 1: { // sw_version + lua_createtable (L, 0, 7); + int table_index = lua_gettop(L); + lua_pushliteral(L, "node_version_major"); + lua_pushinteger(L, NODE_VERSION_MAJOR); + lua_settable(L, table_index); + lua_pushliteral(L, "node_version_minor"); + lua_pushinteger(L, NODE_VERSION_MINOR); + lua_settable(L, table_index); + lua_pushliteral(L, "node_version_revision"); + lua_pushinteger(L, NODE_VERSION_REVISION); + lua_settable(L, table_index); + lua_pushliteral(L, "git_branch"); + lua_pushstring(L, BUILDINFO_BRANCH); + lua_settable(L, table_index); + lua_pushliteral(L, "git_commit_id"); + lua_pushstring(L, BUILDINFO_COMMIT_ID); + lua_settable(L, table_index); + lua_pushliteral(L, "git_release"); + lua_pushstring(L, BUILDINFO_RELEASE); + lua_settable(L, table_index); + lua_pushliteral(L, "git_commit_dts"); + lua_pushstring(L, BUILDINFO_RELEASE_DTS); + lua_settable(L, table_index); + return 1; + } + case 2: { // build_config + lua_createtable (L, 0, 4); + int table_index = lua_gettop(L); + lua_pushliteral(L, "ssl"); + lua_pushboolean(L, BUILDINFO_SSL); + lua_settable(L, table_index); + lua_pushliteral(L, "lfs_size"); + lua_pushnumber(L, BUILDINFO_LFS); + lua_settable(L, table_index); + lua_pushliteral(L, "modules"); + lua_pushstring(L, BUILDINFO_MODULES); + lua_settable(L, table_index); + lua_pushliteral(L, "number_type"); + lua_pushstring(L, BUILDINFO_BUILD_TYPE); + lua_settable(L, table_index); + return 1; + } + default: + { + platform_print_deprecation_note("node.info() without parameter", "in the next version"); + lua_pushinteger(L, NODE_VERSION_MAJOR); + lua_pushinteger(L, NODE_VERSION_MINOR); + lua_pushinteger(L, NODE_VERSION_REVISION); + lua_pushinteger(L, system_get_chip_id()); // chip id + lua_pushinteger(L, spi_flash_get_id()); // flash id + lua_pushinteger(L, flash_rom_get_size_byte() / 1024); // flash size in KB + lua_pushinteger(L, flash_rom_get_mode()); + lua_pushinteger(L, flash_rom_get_speed()); + return 8; + } + } } // Lua: chipid() diff --git a/app/user/user_main.c b/app/user/user_main.c index 9afb1fb8..2b9e97b1 100644 --- a/app/user/user_main.c +++ b/app/user/user_main.c @@ -103,7 +103,7 @@ extern void _ResetHandler(void); * the use of a partition table (PT) to control flash allocation. The NodeMCU uses * this PT for overall allocation of its flash resources. The non_OS SDK calls the * user_pre_init() entry to do all of this startup configuration. Note that this - * runs with Icache enabled -- that is the IROM0 partition is already mapped the + * runs with Icache enabled -- that is the IROM0 partition is already mapped to the * address space at 0x40210000 and so that most SDK services are available, such * as system_get_flash_size_map() which returns the valid flash size (including the * 8Mb and 16Mb variants). diff --git a/docs/modules/node.md b/docs/modules/node.md index ee04db21..2a16f751 100644 --- a/docs/modules/node.md +++ b/docs/modules/node.md @@ -276,32 +276,50 @@ system heap size left in bytes (number) ## node.info() -Returns NodeMCU version, chipid, flashid, flash size, flash mode, flash speed, branch, git commit_id, release, release_dts, ssl, lfs info, modules and the build_type. +Returns information about hardware, software version and build configuration. + #### Syntax -`node.info()` +`node.info([kind])` #### Parameters -none +`kind` kind of information (optional, if ommited return legacy information). May be one of `"hw"`, `"sw_version"`, `"build_config"`. #### Returns - - `majorVer` (number) - - `minorVer` (number) - - `devVer` (number) - - `chipid` (number) - - `flashid` (number) - - `flashsize` (number) - - `flashmode` (number) - - `flashspeed` (number) - - `branch` (string) - - `git commit_id` (string) - - `release` (string) Release name +additional commits e.g. "2.0.0-master_20170202 +403" - - `release_dts` (string) in an ordering format. e.g. "201908111200" - - `ssl` (boolean) - - `lfs info` (string) "disabled" or "Size: {whatever is in user_config.h}" - - `modules` (string) comma separated list - - `build_type` (string) `integer` or `float` + if a `kind` is given the return value will be a table containing the following elements: + - for `kind` = `"hw"` + - `chip_id` (number) + - `flash_id` (number) + - `flash_size` (number) + - `flash_mode` (number) QIO = 0, QOUT = 1, DIO = 2, DOUT = 15. + - `flash_speed` (number) + - for `kind` = `"sw_version"` + - `git_branch` (string) + - `git_commit_id` (string) + - `git_release` (string) Release name +additional commits e.g. "2.0.0-master_20170202 +403" + - `git_commit_dts` (string) in an ordering format. e.g. "201908111200" + - `node_verion_major` (number) + - `node_verion_minor` (number) + - `node_verion_revision` (number) + - for `kind` = `"build_config"` + - `ssl` (boolean) + - `lfs_size` (number) as defined at build time + - `modules` (string) comma separated list + - `number_type` (string) `integer` or `float` +!!! attention + +This interface is deprecated and will be removed in one of the next releases. Use the above calls instead. + + - for no `kind` given: --deprecated + - `majorVer` (number) + - `minorVer` (number) + - `devVer` (number) + - `chipid` (number) + - `flashid` (number) + - `flashsize` (number) + - `flashmode` (number) + - `flashspeed` (number) #### Example ```lua @@ -309,6 +327,17 @@ majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = print("NodeMCU "..majorVer.."."..minorVer.."."..devVer) ``` +```lua +for k,v in pairs(node.info("build_config")) do +print (k,v) +end +``` + +```lua +print(node.info("sw_version").git_release) +``` + + ## node.input() Submits a string to the Lua interpreter. Similar to `pcall(loadstring(str))`, but without the single-line limitation. diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index d07c51dd..19aed018 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -9,28 +9,6 @@ BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -r 's/[\/\\]+/_/g')" RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" RELEASE_DTS=$(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" $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" $USER_CONFIG_H | tr -d '\r' | cut -d ' ' -f 3-) -if [ -z "$LFS" ]; then - LFS="disabled" -else - LFS="Size: ${LFS}" -fi - -# figure out whether Int build is enabled in user_config.h -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}' $USER_MODULES_H | tr -d '\r') # create temp buildinfo @@ -38,6 +16,32 @@ TEMPFILE=/tmp/buildinfo.h cat > $TEMPFILE << EndOfMessage #ifndef __BUILDINFO_H__ #define __BUILDINFO_H__ + +#include "user_config.h" + +#define BUILDINFO_STR_HELPER(x) #x +#define BUILDINFO_TO_STR(x) BUILDINFO_STR_HELPER(x) + +#ifdef LUA_FLASH_STORE +#define BUILDINFO_LFS LUA_FLASH_STORE +#else +#define BUILDINFO_LFS 0 +#endif + +#ifdef CLIENT_SSL_ENABLE +#define BUILDINFO_SSL true +#define BUILDINFO_SSL_STR "true" +#else +#define BUILDINFO_SSL false +#define BUILDINFO_SSL_STR "false" +#endif + +#ifdef LUA_NUMBER_INTEGRAL +#define BUILDINFO_BUILD_TYPE "integer" +#else +#define BUILDINFO_BUILD_TYPE "float" +#endif + EndOfMessage echo "#define USER_PROLOG \""$USER_PROLOG"\"" >> $TEMPFILE @@ -45,10 +49,6 @@ 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_SSL "$SSL >> $TEMPFILE -echo "#define BUILDINFO_SSL_STR \""$SSL"\"" >> $TEMPFILE -echo "#define BUILDINFO_BUILD_TYPE \""$BUILD_TYPE"\"" >> $TEMPFILE -echo "#define BUILDINFO_LFS \""$LFS"\"" >> $TEMPFILE echo "#define BUILDINFO_MODULES \""$MODULES"\"" >> $TEMPFILE cat >> $TEMPFILE << EndOfMessage2 @@ -60,7 +60,7 @@ cat >> $TEMPFILE << EndOfMessage2 "\trelease DTS: " BUILDINFO_RELEASE_DTS "\n" \\ "\tSSL: " BUILDINFO_SSL_STR "\n" \\ "\tBuild type: " BUILDINFO_BUILD_TYPE "\n" \\ - "\tLFS: " BUILDINFO_LFS "\n" \\ + "\tLFS: " BUILDINFO_TO_STR(BUILDINFO_LFS) "\n" \\ "\tmodules: " BUILDINFO_MODULES "\n" EndOfMessage2 From 06666a7854729472e9aad13d2ddf4239f9a66fcf Mon Sep 17 00:00:00 2001 From: Gregor Date: Mon, 22 Jul 2019 22:42:06 +0200 Subject: [PATCH 17/21] using lua_setfield now --- app/modules/node.c | 48 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/app/modules/node.c b/app/modules/node.c index 962e6073..167b8b21 100644 --- a/app/modules/node.c +++ b/app/modules/node.c @@ -127,64 +127,48 @@ static int node_info( lua_State* L ) case 0: { // hw lua_createtable (L, 0, 5); int table_index = lua_gettop(L); - lua_pushliteral(L, "chip_id"); lua_pushinteger(L, system_get_chip_id()); // chip id - lua_settable(L, table_index); - lua_pushliteral(L, "flash_id"); + lua_setfield(L, table_index, "chip_id"); lua_pushinteger(L, spi_flash_get_id()); // flash id - lua_settable(L, table_index); - lua_pushliteral(L, "flash_size"); + lua_setfield(L, table_index, "flash_id"); lua_pushinteger(L, flash_rom_get_size_byte() / 1024); // flash size in KB - lua_settable(L, table_index); - lua_pushliteral(L, "flash_mode"); + lua_setfield(L, table_index, "flash_size"); lua_pushinteger(L, flash_rom_get_mode()); - lua_settable(L, table_index); - lua_pushliteral(L, "flash_speed"); + lua_setfield(L, table_index, "flash_mode"); lua_pushinteger(L, flash_rom_get_speed()); - lua_settable(L, table_index); + lua_setfield(L, table_index, "flash_speed"); return 1; } case 1: { // sw_version lua_createtable (L, 0, 7); int table_index = lua_gettop(L); - lua_pushliteral(L, "node_version_major"); lua_pushinteger(L, NODE_VERSION_MAJOR); - lua_settable(L, table_index); - lua_pushliteral(L, "node_version_minor"); + lua_setfield(L, table_index, "node_version_major"); lua_pushinteger(L, NODE_VERSION_MINOR); - lua_settable(L, table_index); - lua_pushliteral(L, "node_version_revision"); + lua_setfield(L, table_index, "node_version_minor"); lua_pushinteger(L, NODE_VERSION_REVISION); - lua_settable(L, table_index); - lua_pushliteral(L, "git_branch"); + lua_setfield(L, table_index, "node_version_revision"); lua_pushstring(L, BUILDINFO_BRANCH); - lua_settable(L, table_index); - lua_pushliteral(L, "git_commit_id"); + lua_setfield(L, table_index, "git_branch"); lua_pushstring(L, BUILDINFO_COMMIT_ID); - lua_settable(L, table_index); - lua_pushliteral(L, "git_release"); + lua_setfield(L, table_index, "git_commit_id"); lua_pushstring(L, BUILDINFO_RELEASE); - lua_settable(L, table_index); - lua_pushliteral(L, "git_commit_dts"); + lua_setfield(L, table_index, "git_release"); lua_pushstring(L, BUILDINFO_RELEASE_DTS); - lua_settable(L, table_index); + lua_setfield(L, table_index, "git_commit_dts"); return 1; } case 2: { // build_config lua_createtable (L, 0, 4); int table_index = lua_gettop(L); - lua_pushliteral(L, "ssl"); lua_pushboolean(L, BUILDINFO_SSL); - lua_settable(L, table_index); - lua_pushliteral(L, "lfs_size"); + lua_setfield(L, table_index, "ssl"); lua_pushnumber(L, BUILDINFO_LFS); - lua_settable(L, table_index); - lua_pushliteral(L, "modules"); + lua_setfield(L, table_index, "lfs_size"); lua_pushstring(L, BUILDINFO_MODULES); - lua_settable(L, table_index); - lua_pushliteral(L, "number_type"); + lua_setfield(L, table_index, "modules"); lua_pushstring(L, BUILDINFO_BUILD_TYPE); - lua_settable(L, table_index); + lua_setfield(L, table_index, "number_type"); return 1; } default: From 9eec82fead4eaf1f37a2ceaf84d1f917f69e7cc1 Mon Sep 17 00:00:00 2001 From: Gregor Date: Mon, 22 Jul 2019 23:43:53 +0200 Subject: [PATCH 18/21] Get DTS in UTC as Marcel proposed. --- tools/update_buildinfo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 19aed018..5b2f1b7c 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -7,7 +7,7 @@ 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')" RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" -RELEASE_DTS=$(git show -s --format=%cd --date=format:"%Y%m%d%H%M" HEAD) +RELEASE_DTS=$(TZ=UTC git show --quiet --date=format-local:"%Y%m%d%H%M" --format="%cd" HEAD) 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') From 0ff3084fe35d120c056cdfac8d4f35088d8c8d86 Mon Sep 17 00:00:00 2001 From: Gregor Date: Sat, 27 Jul 2019 08:27:19 +0200 Subject: [PATCH 19/21] small fixes as outcome of review --- docs/modules/node.md | 14 +++++++------- tools/update_buildinfo.sh | 21 ++++++++------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/docs/modules/node.md b/docs/modules/node.md index 2a16f751..1db31964 100644 --- a/docs/modules/node.md +++ b/docs/modules/node.md @@ -280,20 +280,20 @@ Returns information about hardware, software version and build configuration. #### Syntax -`node.info([kind])` +`node.info([group])` #### Parameters -`kind` kind of information (optional, if ommited return legacy information). May be one of `"hw"`, `"sw_version"`, `"build_config"`. +`group` group of information (optional, if ommited return legacy information). May be one of `"hw"`, `"sw_version"`, `"build_config"`. #### Returns - if a `kind` is given the return value will be a table containing the following elements: - - for `kind` = `"hw"` + if a `group` is given the return value will be a table containing the following elements: + - for `group` = `"hw"` - `chip_id` (number) - `flash_id` (number) - `flash_size` (number) - `flash_mode` (number) QIO = 0, QOUT = 1, DIO = 2, DOUT = 15. - `flash_speed` (number) - - for `kind` = `"sw_version"` + - for `group` = `"sw_version"` - `git_branch` (string) - `git_commit_id` (string) - `git_release` (string) Release name +additional commits e.g. "2.0.0-master_20170202 +403" @@ -301,7 +301,7 @@ Returns information about hardware, software version and build configuration. - `node_verion_major` (number) - `node_verion_minor` (number) - `node_verion_revision` (number) - - for `kind` = `"build_config"` + - for `group` = `"build_config"` - `ssl` (boolean) - `lfs_size` (number) as defined at build time - `modules` (string) comma separated list @@ -311,7 +311,7 @@ Returns information about hardware, software version and build configuration. This interface is deprecated and will be removed in one of the next releases. Use the above calls instead. - - for no `kind` given: --deprecated + - for no `group` given: --deprecated - `majorVer` (number) - `minorVer` (number) - `devVer` (number) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 5b2f1b7c..bb2ee5cb 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -1,9 +1,7 @@ #!/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')" RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" @@ -42,18 +40,15 @@ cat > $TEMPFILE << EndOfMessage #define BUILDINFO_BUILD_TYPE "float" #endif -EndOfMessage +#define USER_PROLOG "$USER_PROLOG" +#define BUILDINFO_BRANCH "$BRANCH" +#define BUILDINFO_COMMIT_ID "$COMMIT_ID" +#define BUILDINFO_RELEASE "$RELEASE" +#define BUILDINFO_RELEASE_DTS "$RELEASE_DTS" +#define BUILDINFO_MODULES "$MODULES" -echo "#define USER_PROLOG \""$USER_PROLOG"\"" >> $TEMPFILE -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_MODULES \""$MODULES"\"" >> $TEMPFILE - -cat >> $TEMPFILE << EndOfMessage2 #define NODE_VERSION_LONG \\ - "$USER_PROLOG \n" \\ + USER_PROLOG "\n" \\ "\tbranch: " BUILDINFO_BRANCH "\n" \\ "\tcommit: " BUILDINFO_COMMIT_ID "\n" \\ "\trelease: " BUILDINFO_RELEASE "\n" \\ @@ -63,7 +58,7 @@ cat >> $TEMPFILE << EndOfMessage2 "\tLFS: " BUILDINFO_TO_STR(BUILDINFO_LFS) "\n" \\ "\tmodules: " BUILDINFO_MODULES "\n" -EndOfMessage2 +EndOfMessage echo "#endif /* __BUILDINFO_H__ */" >> $TEMPFILE From 825e35053f00e0816fb31c85c0fa967c16183369 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Sat, 27 Jul 2019 12:55:34 +0200 Subject: [PATCH 20/21] have common capitalization in startup message --- tools/update_buildinfo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index bb2ee5cb..9113ec57 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -54,7 +54,7 @@ cat > $TEMPFILE << EndOfMessage "\trelease: " BUILDINFO_RELEASE "\n" \\ "\trelease DTS: " BUILDINFO_RELEASE_DTS "\n" \\ "\tSSL: " BUILDINFO_SSL_STR "\n" \\ - "\tBuild type: " BUILDINFO_BUILD_TYPE "\n" \\ + "\tbuild type: " BUILDINFO_BUILD_TYPE "\n" \\ "\tLFS: " BUILDINFO_TO_STR(BUILDINFO_LFS) "\n" \\ "\tmodules: " BUILDINFO_MODULES "\n" From d054d17694f09fe5710cf0adb6f434117c808dd4 Mon Sep 17 00:00:00 2001 From: Gregor Hartmann Date: Sat, 27 Jul 2019 13:09:11 +0200 Subject: [PATCH 21/21] adapt sed calls for macOS --- tools/update_buildinfo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/update_buildinfo.sh b/tools/update_buildinfo.sh index 9113ec57..99a376f9 100755 --- a/tools/update_buildinfo.sh +++ b/tools/update_buildinfo.sh @@ -3,8 +3,8 @@ USER_MODULES_H=app/include/user_modules.h COMMIT_ID="$(git rev-parse HEAD)" -BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -r 's/[\/\\]+/_/g')" -RELEASE="$(git describe --tags --long | sed -r 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" +BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -E 's/[\/\\]+/_/g')" +RELEASE="$(git describe --tags --long | sed -E 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')" RELEASE_DTS=$(TZ=UTC git show --quiet --date=format-local:"%Y%m%d%H%M" --format="%cd" HEAD) 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')