Skip to content

Commit 802c768

Browse files
committed
[LIBC] Use RT_USING_LIBC instead of libs option for each compiler
1 parent 3729264 commit 802c768

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

components/libc/SConscript

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# for libc component
22
import os
3-
Import('RTT_ROOT')
3+
Import('rtconfig')
4+
5+
from building import *
46

57
objs = []
6-
list = os.listdir(os.path.join(RTT_ROOT, 'components', 'libc'))
78

8-
for d in list:
9-
path = os.path.join(RTT_ROOT, 'components', 'libc', d)
10-
if os.path.isfile(os.path.join(path, 'SConscript')):
11-
objs = objs + SConscript(os.path.join(d, 'SConscript'))
9+
if GetDepend('RT_USING_LIBC'):
10+
if rtconfig.PLATFORM == 'gcc':
11+
objs = objs + SConscript('newlib/SConscript')
12+
elif rtconfig.PLATFORM == 'armcc':
13+
objs = objs + SConscript('armlibc/SConscript')
14+
else:
15+
if rtconfig.PLATFORM == 'gcc':
16+
objs = objs + SConscript('minilibc/SConscript')
1217

1318
Return('objs')

components/libc/armlibc/SConscript

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
Import('rtconfig')
21
from building import *
32

4-
if GetDepend('RT_USING_ARM_LIBC') and rtconfig.CROSS_TOOL != 'keil':
5-
print '================ERROR=============================='
6-
print 'Please use ARM CC compiler if using ARM C library'
7-
print '==================================================='
8-
exit(0)
9-
10-
cwd = GetCurrentDir()
113
src = Glob('*.c')
4+
cwd = GetCurrentDir()
5+
126
CPPPATH = [cwd]
7+
CPPDEFINES = ['RT_USING_ARM_LIBC']
138

14-
group = DefineGroup('libc', src, depend = ['RT_USING_ARM_LIBC'], CPPPATH = CPPPATH)
9+
group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'],
10+
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
1511

1612
Return('group')

components/libc/minilibc/SConscript

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Import('RTT_ROOT')
22
from building import *
33

44
src = Glob('*.c')
5-
CPPPATH = [RTT_ROOT + '/components/libc/minilibc']
5+
cwd = GetCurrentDir()
6+
7+
CPPPATH = [cwd]
68
CPPDEFINES = ['RT_USING_MINILIBC']
7-
group = DefineGroup('minilibc', src,
8-
depend = ['RT_USING_MINILIBC'],
9-
CPPPATH = CPPPATH,
10-
CPPDEFINES = CPPDEFINES
11-
)
9+
10+
group = DefineGroup('libc', src, depend = ['RT_USING_MINILIBC'],
11+
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
1212

1313
Return('group')

components/libc/newlib/SConscript

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
Import('rtconfig')
21
from building import *
32

4-
if GetDepend('RT_USING_NEWLIB') and rtconfig.CROSS_TOOL != 'gcc':
5-
print '================ERROR============================'
6-
print 'Please use GNU GCC compiler if using newlib'
7-
print '================================================='
8-
exit(0)
9-
3+
src = Glob('*.c')
104
cwd = GetCurrentDir()
11-
src = Glob('*.c')
5+
126
CPPPATH = [cwd]
7+
CPPDEFINES = ['RT_USING_NEWLIB']
138

149
# link with libc and libm:
1510
# libm is a frequently used lib. Newlib is compiled with -ffunction-sections in
1611
# recent GCC tool chains. The linker would just link in the functions that have
1712
# been referenced. So setting this won't result in bigger text size.
1813
LIBS = ['c', 'm']
1914

20-
group = DefineGroup('newlib', src, depend = ['RT_USING_NEWLIB'],
21-
CPPPATH = CPPPATH, LIBS = LIBS)
15+
group = DefineGroup('newlib', src, depend = ['RT_USING_LIBC'],
16+
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
2217

2318
Return('group')

0 commit comments

Comments
 (0)