1# RT-Thread building script for bridge
2
3import os
4import re
5from building import *
6
7Import('rtconfig')
8
9cwd   = GetCurrentDir()
10group = []
11list  = os.listdir(cwd)
12bsp_path = Dir('#').abspath
13
14if not os.path.exists(bsp_path + "/link.lds"):
15    Env['LINKFLAGS'] = Env['LINKFLAGS'].replace('link.lds', cwd + "/link.lds")
16    Preprocessing("link.lds.S", ".lds", CPPPATH=[bsp_path])
17
18# fix the linker with crtx.o
19Env['LINKFLAGS'] += ' -nostartfiles'
20
21# add common code files
22group = group + SConscript(os.path.join('common', 'SConscript'))
23
24# cpu porting code files
25if rtconfig.CPU != 'common':
26    group = group + SConscript(os.path.join(rtconfig.CPU, 'SConscript'))
27
28def del_gnu99():
29    for g in Projects:
30        if g["name"] == "Kernel":
31            flags = re.sub(r'\s+', ' ', re.sub(r'\s*-std=gnu99\s*', ' ', g["LOCAL_CFLAGS"])).strip()
32            flags = re.sub(r'(?<!\s)(-Wunused)', r' \1', flags)
33            g["LOCAL_CFLAGS"] = flags
34
35RegisterPreBuildingAction(del_gnu99)
36Return('group')
37