feat: added commit hash

This commit is contained in:
Yurii
2026-02-16 10:06:26 +03:00
parent af1a9b59c4
commit 11747dd8bd
11 changed files with 32 additions and 1 deletions

View File

@@ -96,7 +96,8 @@ custom_component_remove = espressif/esp_hosted
espressif/esp-zboss-lib
espressif/esp-zigbee-lib
chmorgan/esp-libhelix-mp3
extra_scripts = post:tools/esp32.py
extra_scripts = pre:tools/add_build_commit.py
post:tools/esp32.py
post:tools/build.py
build_type = ${env.build_type}
build_flags = ${env.build_flags}

View File

@@ -552,6 +552,7 @@ protected:
auto docBuild = doc[FPSTR(S_BUILD)].to<JsonObject>();
docBuild[FPSTR(S_VERSION)] = BUILD_VERSION;
docBuild[FPSTR(S_COMMIT)] = BUILD_COMMIT;
docBuild[FPSTR(S_DATE)] = __DATE__ " " __TIME__;
docBuild[FPSTR(S_ENV)] = BUILD_ENV;
docBuild[FPSTR(S_CORE)] = ESP.getCoreVersion();
@@ -592,6 +593,7 @@ protected:
auto docBuild = doc[FPSTR(S_BUILD)].to<JsonObject>();
docBuild[FPSTR(S_VERSION)] = BUILD_VERSION;
docBuild[FPSTR(S_COMMIT)] = BUILD_COMMIT;
docBuild[FPSTR(S_DATE)] = __DATE__ " " __TIME__;
docBuild[FPSTR(S_ENV)] = BUILD_ENV;
docBuild[FPSTR(S_CORE)] = ESP.getCoreVersion();

View File

@@ -30,6 +30,10 @@
#define BUILD_VERSION "0.0.0"
#endif
#ifndef BUILD_COMMIT
#define BUILD_COMMIT "undefined"
#endif
#ifndef BUILD_ENV
#define BUILD_ENV "undefined"
#endif

View File

@@ -56,6 +56,7 @@ const char S_CHANNEL[] PROGMEM = "channel";
const char S_CH2_ALWAYS_ENABLED[] PROGMEM = "ch2AlwaysEnabled";
const char S_CHIP[] PROGMEM = "chip";
const char S_CODE[] PROGMEM = "code";
const char S_COMMIT[] PROGMEM = "commit";
const char S_CONNECTED[] PROGMEM = "connected";
const char S_CONTINUES[] PROGMEM = "continues";
const char S_COOLING[] PROGMEM = "cooling";

View File

@@ -44,6 +44,7 @@
"build": {
"title": "Build",
"version": "固件版本",
"commit": "Commit",
"date": "日期",
"core": "内核版本",
"sdk": "SDK"

View File

@@ -44,6 +44,7 @@
"build": {
"title": "Build",
"version": "Version",
"commit": "Commit",
"date": "Date",
"core": "Core",
"sdk": "SDK"

View File

@@ -44,6 +44,7 @@
"build": {
"title": "Build",
"version": "Versione",
"commit": "Commit",
"date": "Data",
"core": "Core",
"sdk": "SDK"

View File

@@ -40,6 +40,7 @@
"build": {
"title": "Build",
"version": "Versie",
"commit": "Commit",
"date": "Datum",
"core": "Core",
"sdk": "SDK"

View File

@@ -44,6 +44,7 @@
"build": {
"title": "Билд",
"version": "Версия",
"commit": "Коммит",
"date": "Дата",
"core": "Ядро",
"sdk": "SDK"

View File

@@ -104,6 +104,7 @@
<th scope="row" data-i18n>index.system.build.title</th>
<td>
Env: <b id="build-env"></b><br />
<span data-i18n>index.system.build.commit</span>: <b id="build-commit"></b><br />
<span data-i18n>index.system.build.date</span>: <b id="build-date"></b><br />
<span data-i18n>index.system.build.core</span>: <b id="build-core"></b><br />
<span data-i18n>index.system.build.sdk</span>: <b id="build-sdk"></b>
@@ -206,6 +207,7 @@
setBusy('#main-busy', '#main-table', false);
setValue('#build-version', result.build.version);
setValue('#build-commit', result.build.commit);
setValue('#build-date', result.build.date);
setValue('#build-env', result.build.env);
setValue('#build-core', result.build.core);

16
tools/add_build_commit.py Normal file
View File

@@ -0,0 +1,16 @@
import subprocess
Import("env")
try:
commit_hash = "undefined"
result = subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"]
)
commit_hash = result.decode("utf-8").strip()
env.Append(
CPPDEFINES=[
("BUILD_COMMIT", '\\"{}\\"'.format(commit_hash))
]
)
except Exception as error:
print("Failed to get commit hash: {}".format(error))