Build Counter to define C++ macro?

Is there any simple way with platformio to have an incremental build counter?

E.g. pio writes an automatically incremented number to an include file, e.g. named buildnumber.h

e.g.

#define BUILD_NUMBER 12

    so I can include it in my main file to set a unique version number?

e.g. (example is for [Homie](https://github.com/marvinroger/homie) firmware that is upgradable via [OTA](https://homie-esp8266.readme.io/v2.0.0/docs/ota-configuration-updates))

    #include "buildnumber.h"
    #define FW_VERSION "0.2."
    const char *__FLAGGED_FW_VERSION = "\x6a\x3f\x3e\x0e\xe1" FW_VERSION BUILD_NUMBER "\xb0\x30\x48\xd4\x1a";

You can do it with python here: http://docs.platformio.org/en/latest/projectconf.html?highlight=post#extra-script
But maybe it makes more sense here: Git - Book

1 Like