-
Notifications
You must be signed in to change notification settings - Fork 19
/
platformio_script.py
50 lines (38 loc) · 1.3 KB
/
platformio_script.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Import("env")
from os.path import basename
import os
import shutil
try:
import configparser
except ImportError:
import ConfigParser as configparser
config = configparser.ConfigParser()
config.read("platformio.ini")
flags = " ".join(env['LINKFLAGS'])
flags = flags.replace("-u _printf_float", "")
flags = flags.replace("-u _scanf_float", "")
newflags = flags.split()
env.Replace(
LINKFLAGS=newflags
)
def after_build(source, target, env):
# f = open('version.txt', 'r')
# val = (f.read()).split(' ', 2)
# print(val)
firmware_path = str(target[0].path)
firmware_name = basename(firmware_path)
if not os.path.exists("./builds"):
os.mkdir("./builds")
configName = env['PIOENV'] #something (SCons?) have changed in Platformio 6.1.16?
sectionName = 'env:' + configName
# breakpoint()
lang = config.get(sectionName, "lang").lower()
dest = 'builds/latest_{0}.bin'.format(lang)
print("Uploading {0} to {1}".format(firmware_name, dest))
shutil.copy(target[0].path, dest)
firmware_path = str(source[0].path)
firmware_name = basename(firmware_path)
dest = 'builds/latest_{0}.elf'.format(lang)
print("Uploading {0} to {1}".format(firmware_name, dest))
shutil.copy(source[0].path, dest)
env.AddPostAction("$BUILD_DIR/firmware.bin", after_build)