forked from pixelit-project/PixelIt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextra_script.py
More file actions
34 lines (26 loc) · 762 Bytes
/
extra_script.py
File metadata and controls
34 lines (26 loc) · 762 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
33
34
import mmap
import os
import re
Import("env")
SOURCECODE = "./src/PixelIt.ino"
# Access to global construction environment
build_tag = env['PIOENV']
# Dump construction environment (for debug purpose)
# print(env.Dump())
# Search Version
version = ""
file1 = open(SOURCECODE, 'r')
Lines = file1.readlines()
count = 0
# Strips the newline character
for line in Lines:
match = re.search(r"^#define\s+VERSION\s+[\"'](.*)[\"'].*$", line)
if match:
version = match.group(1)
file1.close
break
if version == "":
raise Exception(f"No version found in {SOURCECODE}")
# Rename binary according to environnement/board
# ex: firmware_esp32dev.bin or firmware_nodemcuv2.bin
env.Replace(PROGNAME=f"firmware_v{version}_{build_tag}")