From 21c4e110205c87016f0f95cbea8ddc12e80d66f9 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Wed, 7 Oct 2015 13:33:09 +1100 Subject: [PATCH] Enable dynamic build dates, plus print SDK version. --- .travis.yml | 7 ++++--- app/include/user_version.h | 6 +++++- app/lua/lua.c | 12 ++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5e76c51e..f79c444a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,16 @@ before_install: - sudo apt-get install -y python-serial srecord install: - tar -zxvf tools/esp-open-sdk.tar.gz -- export PATH=$PATH:$PWD/esp-open-sdk/sdk:$PWD/esp-open-sdk/xtensa-lx106-elf/bin +- export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin script: -- make all +- export BUILD_DATE=$(date +%Y%m%d) +- make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all - cd bin/ - file_name_float="nodemcu_float_${TRAVIS_TAG}.bin" - srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 - cd ../ - make clean -- make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL" +- make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$BUILD_DATE'\"'" - cd bin/ - file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin" - srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 diff --git a/app/include/user_version.h b/app/include/user_version.h index 255e0e46..863d4d26 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -7,6 +7,10 @@ #define NODE_VERSION_INTERNAL 0U #define NODE_VERSION "NodeMCU 1.4.0" -#define BUILD_DATE "build 20151006" +#ifndef BUILD_DATE +#define BUILD_DATE "20151006" +#endif + +extern char SDK_VERSION[]; #endif /* __USER_VERSION_H__ */ diff --git a/app/lua/lua.c b/app/lua/lua.c index d7d14f40..d2b2575a 100644 --- a/app/lua/lua.c +++ b/app/lua/lua.c @@ -135,9 +135,13 @@ static int docall (lua_State *L, int narg, int clear) { } -static void print_version (void) { - // l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); - l_message(NULL, "\n" NODE_VERSION " " BUILD_DATE " powered by " LUA_RELEASE); +static void print_version (lua_State *L) { + lua_pushliteral (L, "\n" NODE_VERSION " build " BUILD_DATE " powered by " LUA_RELEASE " on SDK "); + lua_pushstring (L, SDK_VERSION); + lua_concat (L, 2); + const char *msg = lua_tostring (L, -1); + l_message (NULL, msg); + lua_pop (L, 1); } @@ -399,7 +403,7 @@ static int pmain (lua_State *L) { lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ luaL_openlibs(L); /* open libraries */ lua_gc(L, LUA_GCRESTART, 0); - print_version(); + print_version(L); s->status = handle_luainit(L); #if 0 if (s->status != 0) return 0;