mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-04-20 11:02:14 +02:00
updated code logic to pic FW/App version from appversion instead of hard-coding in js/html/cpp files
This commit is contained in:
parent
bb61a1703d
commit
fe4aa83ed2
8 changed files with 78 additions and 155 deletions
32
app_version.py
Normal file
32
app_version.py
Normal file
|
|
@ -0,0 +1,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)
|
||||
])
|
||||
Loading…
Add table
Add a link
Reference in a new issue