-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathconfigure-build.py
118 lines (102 loc) · 3.81 KB
/
configure-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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import os
import sys
import re
import xml.etree.ElementTree as ET
Import("env")
platform = env.PioPlatform()
board = env.BoardConfig()
# read IAR project file
def export_iar_project():
files = []
def get_files_from_group(group):
return [x.text.replace('$PROJ_DIR$\\..\\', '.\\').replace('\\', '/') for x in group.findall('file/name')]
def get_group(group, files):
for type_tag in group.findall('group'):
f = get_files_from_group(type_tag)
files += [x for x in f if (x.endswith('.cpp') or x.endswith('.c'))]
get_group(type_tag, files)
root = ET.parse(os.path.join(env['PROJECT_DIR'], 'EWARM/mkstft35.ewp')).getroot()
get_group(root, files)
with open(os.path.join(env['PROJECT_DIR'], 'source-files.txt'), 'wt') as fp:
for f in files:
fp.write(f + "\n")
exit(1)
# export_iar_project()
def load_source_files():
files = ''
with open('./source-files.txt', 'rt') as fp:
files = ' '.join(["+<"+x.strip()+">" for x in fp.readlines()])
src_filter = ' '.join(env.GetProjectOption('src_filter'))
src_filter += files
proj = env.GetProjectConfig()
proj.set("env:" + env['PIOENV'], 'src_filter', src_filter)
env.Replace(SRC_FILTER=src_filter)
load_source_files()
env.Append(CPPPATH=[
os.path.join(env['PROJECT_DIR'], 'Inc'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'STM32F4xx_HAL_Driver', 'Inc'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'CMSIS', 'Device', 'ST', 'STM32F4xx', 'Include'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'CMSIS', 'Include'),
os.path.join(env['PROJECT_DIR'], 'Middlewares', 'Third_Party', 'FatFs', 'src'),
os.path.join(env['PROJECT_DIR'], 'Middlewares', 'ST', 'STM32_USB_Host_Library', 'Class', 'MSC', 'Inc'),
os.path.join(env['PROJECT_DIR'], 'Middlewares', 'Third_Party', 'FatFs', 'src', 'drivers'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'STM32F4xx_MKS_Driver', 'Inc'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'STM32F4xx_MKS_Driver', 'Src'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'libstmf4', 'include'),
os.path.join(env['PROJECT_DIR'], 'User', 'others'),
os.path.join(env['PROJECT_DIR'], 'User', 'ui'),
os.path.join(env['PROJECT_DIR'], 'Drivers', 'libstmf4'),
os.path.join(env['PROJECT_DIR'], 'User', 'uart_model'),
os.path.join(env['PROJECT_DIR'], 'User', 'others', 'Multi_language'),
os.path.join(env['PROJECT_DIR'], 'Middlewares', 'GUI'),
os.path.join(env['PROJECT_DIR'], 'User', 'others', 'QRENCODE'),
os.path.join(env['PROJECT_DIR'], 'Middlewares', 'Config'),
os.path.join(env['PROJECT_DIR'], 'Middlewares', 'ST', 'STM32_USB_Host_Library', 'Core', 'Inc'),
])
env.Append(
CFLAGS=['-mcpu=cortex-m4',
'-mthumb',
'-ffunction-sections',
'-fdata-sections',
'-nostdlib',
'-std=gnu11',
"-fmerge-constants",
# '-funwind-tables',
# '-fasynchronous-unwind-tables',
"--param",
"max-inline-insns-single=500",
"-mfpu=fpv4-sp-d16", "-mfloat-abi=hard",
"--specs=nano.specs",
],
ASFLAGS=[
"-x", "assembler-with-cpp",
'-mcpu=cortex-m4',
'-mthumb',
"-mfpu=fpv4-sp-d16", "-mfloat-abi=hard",
"--specs=nano.specs",
],
CXXFLAGS=[
"-fpermissive",
"-Wno-register",
"-std=gnu++11",
"-fno-rtti",
"-fno-exceptions",
"-fno-threadsafe-statics",
"-fno-use-cxa-atexit",
],
LINKFLAGS=[
"-mthumb",
"-mcpu=cortex-m4",
"-mfpu=fpv4-sp-d16", "-mfloat-abi=hard",
"--specs=nano.specs",
"-Wl,--check-sections",
"-Wl,--unresolved-symbols=report-all",
"-Wl,--warn-common",
"-Wl,--warn-section-align",
"-Wl,--warn-unresolved-symbols",
],
LIBS=["arm_cortexM4lf_math", "GUI"],
LIBPATH=[os.path.join(env['PROJECT_DIR'], 'Src', 'pio', 'libs')]
)
env.Append(CXXFLAGS=env['CFLAGS'])
env.Prepend(LINKFLAGS=['-T', "Src/pio/ldscript.ld"])