feat: Add mod build environment with version + git hash
Add `env:mod` PlatformIO environment that sets CROSSPOINT_VERSION to
"{version}-mod+{git_hash}" via a pre-build script. Usage: `pio run -e mod -t upload`
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,6 +55,14 @@ build_flags =
|
|||||||
${base.build_flags}
|
${base.build_flags}
|
||||||
-DCROSSPOINT_VERSION=\"${crosspoint.version}-dev\"
|
-DCROSSPOINT_VERSION=\"${crosspoint.version}-dev\"
|
||||||
|
|
||||||
|
[env:mod]
|
||||||
|
extends = base
|
||||||
|
extra_scripts =
|
||||||
|
${base.extra_scripts}
|
||||||
|
pre:scripts/inject_mod_version.py
|
||||||
|
build_flags =
|
||||||
|
${base.build_flags}
|
||||||
|
|
||||||
[env:gh_release]
|
[env:gh_release]
|
||||||
extends = base
|
extends = base
|
||||||
build_flags =
|
build_flags =
|
||||||
|
|||||||
15
scripts/inject_mod_version.py
Normal file
15
scripts/inject_mod_version.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Import("env")
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
config = env.GetProjectConfig()
|
||||||
|
version = config.get("crosspoint", "version")
|
||||||
|
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "rev-parse", "--short", "HEAD"],
|
||||||
|
capture_output=True, text=True
|
||||||
|
)
|
||||||
|
git_hash = result.stdout.strip()
|
||||||
|
|
||||||
|
env.Append(
|
||||||
|
BUILD_FLAGS=[f'-DCROSSPOINT_VERSION=\\"{version}-mod+{git_hash}\\"']
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user