I added this to my pre.py custom script:
from datetime import datetime
import getpass
import platform
import subprocess
buildstr = subprocess.check_output(['git', 'describe', '--long', '--dirty', '--tags']).strip() + "-" + getpass.getuser() + "@" + platform.uname()[1] + "-" + datetime.utcnow().strftime('%d/%m/%Y-%H:%M')
print("BUILD VERSION: " + buildstr)
env.Append(CPPDEFINES=[("PIO_BUILD", "\\\"" + buildstr + "\\\"")])
This generates the following on build:
BUILD VERSION: v0.1-1-gc5c911c-dirty-timv@timv-5510-27/04/2019-23:30
which I can include as a string literal in my datalog files with PIO_BUILD
My problem is that this causes PIO to rebuild the entire project, not just compilation units that depend on PIO_BUILD
(only one). This makes the build process quite slow, as there are a number of dependencies.
Is there a fix for this, or a better way to approach it?
Thanks
Tim