-
Notifications
You must be signed in to change notification settings - Fork 8
/
pre_build.py
31 lines (24 loc) · 890 Bytes
/
pre_build.py
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
Import("env")
import subprocess
version = "undefined"
revision = "rev_NO_GIT"
boardName = "blecker"
try:
revision = (
subprocess.check_output(["git", "rev-list", "--count", "HEAD"])
.strip()
.decode("utf-8")
)
except:
print ("No Git installed. Version number will be skipped in a filename")
defFile = open("src/definitions.h")
for line in defFile:
if line.startswith("#define MAJOR_VERSION"):
version = line.replace("#define MAJOR_VERSION ", "")
version = version.strip()
if line.startswith("#define BOARD_NAME"):
boardName = line.replace("#define BOARD_NAME ", "").replace("\"","").replace(' ', '').replace('\t', '').replace('\n\n', '\n').replace('\n', '')
boardname = version.strip()
defFile.close()
program_file_name = boardName + "_v" + version + "-" + revision
env.Replace(PROGNAME=program_file_name)