Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
21c35a1a
Commit
21c35a1a
authored
Jun 27, 2019
by
Gregor
Browse files
Create buildinfo.h and return new Values in node.info
parent
6d9c5a49
Changes
4
Show whitespace changes
Inline
Side-by-side
.gitignore
View file @
21c35a1a
...
@@ -15,3 +15,4 @@ tools/toolchains/
...
@@ -15,3 +15,4 @@ tools/toolchains/
.project
.project
.settings/
.settings/
.vscode
.vscode
buildinfo.h
app/include/user_version.h
View file @
21c35a1a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +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"
#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
...
@@ -11,7 +12,7 @@
...
@@ -11,7 +12,7 @@
#define NODE_VERSION_STR(x) #x
#define NODE_VERSION_STR(x) #x
#define NODE_VERSION_XSTR(x) NODE_VERSION_STR(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
#ifndef BUILD_DATE
#define BUILD_DATE "unspecified"
#define BUILD_DATE "unspecified"
...
...
app/modules/node.c
View file @
21c35a1a
...
@@ -128,7 +128,13 @@ static int node_info( lua_State* L )
...
@@ -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_size_byte
()
/
1024
);
// flash size in KB
lua_pushinteger
(
L
,
flash_rom_get_mode
());
lua_pushinteger
(
L
,
flash_rom_get_mode
());
lua_pushinteger
(
L
,
flash_rom_get_speed
());
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()
// Lua: chipid()
...
...
tools/update_buildinfo.sh
0 → 100644
View file @
21c35a1a
#!/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
\\
"
\t
branch: '" BUILDINFO_BRANCH "'
\n
"
\\
"
\t
commit: '" BUILDINFO_COMMIT_ID "'
\n
"
\\
"
\t
SSL: '" BUILDINFO_SSL_STR "'
\n
"
\\
"
\t
Build type: '" BUILDINFO_BUILD_TYPE "'
\n
"
\\
"
\t
LFS: '" BUILDINFO_LFS "'
\n
"
\\
"
\t
modules: '" 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment