forked from cjkas/ESPSomfy-RTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_version.py
More file actions
32 lines (26 loc) · 990 Bytes
/
app_version.py
File metadata and controls
32 lines (26 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
Import("env")
# Define the folder and filename
DATA_FOLDER = "data-src"
FILENAME = "appversion"
# Construct the full path: /your/project/path/data-src/appversion
project_dir = env.get("PROJECT_DIR")
version_file_path = os.path.join(project_dir, DATA_FOLDER, FILENAME)
# Default fallback if something goes wrong
version = "0.0.0"
if os.path.exists(version_file_path):
try:
with open(version_file_path, "r") as f:
version = f.read().strip()
# Clean output for the PlatformIO console
print(f"--- SUCCESS: Found version {version} in {version_file_path} ---")
except Exception as e:
print(f"--- ERROR: could not read version file: {e} ---")
else:
print(f"--- ERROR: File NOT FOUND at {version_file_path} ---")
# Apply to the build environment
# We use escaped quotes so C++ treats it as a string literal "vX.X.X"
full_version_str = f'\\"v{version}\\"'
env.Append(CPPDEFINES=[
("FW_VERSION", full_version_str)
])