import os Import("env") # Access to global construction environment build_tag = env['PIOENV'] version_tag = os.getenv("FIRMWARE_VERSION", "dev").strip() # CPPDEFINES ensures the macro expands to a valid C string literal instead of a bare identifier. env.Append(CPPDEFINES=[('FIRMWARE_VERSION', f'\\"{version_tag}\\"')]) env.Replace(PROGNAME="firmware_%s_%s" % (build_tag, version_tag)) # include toolchain paths env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True) # override compilation DB path env.Replace(COMPILATIONDB_PATH=os.path.join("$BUILD_DIR", "compile_commands.json"))