1import os 2from building import * 3from gcc import * 4Import('rtconfig') 5 6group = [] 7 8newlib_version = GetNewLibVersion(rtconfig) 9 10if newlib_version and not GetDepend('RT_USING_EXTERNAL_LIBC'): 11 print('Newlib version: ' + newlib_version) 12 13 cwd = GetCurrentDir() 14 src = Glob('*.c') 15 16 CPPPATH = [cwd] 17 CPPDEFINES = ['RT_USING_NEWLIBC', 'RT_USING_LIBC', '_POSIX_C_SOURCE=1'] # identify this is Newlib, and only enable POSIX.1-1990 18 LIBS = ['c', 'm'] # link libc and libm 19 AddDepend(['RT_USING_NEWLIBC', 'RT_USING_LIBC']) 20 21 group = group + DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) 22 23 list = os.listdir(cwd) 24 for d in list: 25 path = os.path.join(cwd, d) 26 if os.path.isfile(os.path.join(path, 'SConscript')): 27 group = group + SConscript(os.path.join(d, 'SConscript')) 28 29Return('group') 30