Add build timestamp to the version number (#1145)
I've found this rather useful when repeatedly deploying updated firmware images to a large number of nodes. The patch carefully avoids full rebuilds of any "real" source files by putting the timestamp into a separate .cpp file. It also works around PlatformIO's build cache that would happily permanently cache the timestamp file if we were using __DATE__. The Python script isn't entirely necessary because we could just simply touch the timestamp file via extra_scripts to force a rebuild. But we'd need _some_ kind of script anyway and this way we can format the timestamp more easily than is possible with C++.
This commit is contained in:
parent
11e3e3dc63
commit
e4bbb1d11c
|
@ -14,3 +14,4 @@ CMakeLists.txt
|
||||||
CMakeListsPrivate.txt
|
CMakeListsPrivate.txt
|
||||||
platformio_override.ini
|
platformio_override.ini
|
||||||
node_modules
|
node_modules
|
||||||
|
src/build_timestamp_value.h
|
||||||
|
|
|
@ -61,6 +61,7 @@ board_build.partitions = partitions_singleapp.csv
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
monitor_filters = esp32_exception_decoder, time
|
monitor_filters = esp32_exception_decoder, time
|
||||||
upload_speed = 1500000
|
upload_speed = 1500000
|
||||||
|
extra_scripts = update_ts.py
|
||||||
|
|
||||||
[esp32]
|
[esp32]
|
||||||
extends = common
|
extends = common
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "build_timestamp.h"
|
||||||
|
#include "build_timestamp_value.h"
|
||||||
|
|
||||||
|
const char *getBuildTimestamp() {
|
||||||
|
return BUILD_TIMESTAMP;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
const char *getBuildTimestamp();
|
|
@ -91,7 +91,7 @@ bool sendTelemetry(unsigned int totalSeen, unsigned int totalFpSeen, unsigned in
|
||||||
#ifdef VERSION
|
#ifdef VERSION
|
||||||
doc["ver"] = String(VERSION);
|
doc["ver"] = String(VERSION);
|
||||||
#else
|
#else
|
||||||
doc["ver"] = ESP.getSketchMD5();
|
doc["ver"] = ESP.getSketchMD5() + "-" + getBuildTimestamp();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!BleFingerprintCollection::countIds.isEmpty())
|
if (!BleFingerprintCollection::countIds.isEmpty())
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
|
#include "build_timestamp.h"
|
||||||
#ifdef M5STICK
|
#ifdef M5STICK
|
||||||
#include <AXP192.h>
|
#include <AXP192.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
with open("src/build_timestamp_value.h", "w") as fp:
|
||||||
|
timestamp = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
|
||||||
|
fp.write(f'#define BUILD_TIMESTAMP "{timestamp}"')
|
Loading…
Reference in New Issue