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
|
||||
platformio_override.ini
|
||||
node_modules
|
||||
src/build_timestamp_value.h
|
||||
|
|
|
@ -61,6 +61,7 @@ board_build.partitions = partitions_singleapp.csv
|
|||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder, time
|
||||
upload_speed = 1500000
|
||||
extra_scripts = update_ts.py
|
||||
|
||||
[esp32]
|
||||
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
|
||||
doc["ver"] = String(VERSION);
|
||||
#else
|
||||
doc["ver"] = ESP.getSketchMD5();
|
||||
doc["ver"] = ESP.getSketchMD5() + "-" + getBuildTimestamp();
|
||||
#endif
|
||||
|
||||
if (!BleFingerprintCollection::countIds.isEmpty())
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "globals.h"
|
||||
#include "mqtt.h"
|
||||
#include "string_utils.h"
|
||||
#include "build_timestamp.h"
|
||||
#ifdef M5STICK
|
||||
#include <AXP192.h>
|
||||
#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