From 8bdf993bfc38f9b652a7af60cb071c708ad7dea6 Mon Sep 17 00:00:00 2001 From: bernard Date: Fri, 13 Oct 2017 12:44:54 +0800 Subject: [PATCH] [libc] Build correct SConscript file. --- components/libc/KConfig | 24 +++++++++++++--- components/libc/SConscript | 28 ++++++------------- components/libc/compilers/SConscript | 15 ++++++++++ components/libc/compilers/armlibc/SConscript | 11 +++++--- components/libc/compilers/dlib/SConscript | 6 ++-- components/libc/compilers/minilibc/SConscript | 10 ++++--- components/libc/compilers/newlib/SConscript | 9 ++++-- components/libc/libdl/SConscript | 9 ++++-- components/libc/pthreads/SConscript | 3 +- 9 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 components/libc/compilers/SConscript diff --git a/components/libc/KConfig b/components/libc/KConfig index 155cb0d700..c245069e30 100644 --- a/components/libc/KConfig +++ b/components/libc/KConfig @@ -1,11 +1,27 @@ menu "libc" config RT_USING_LIBC - bool "Enable libc APIs from toolchain" - default y + bool "Enable libc APIs from toolchain" + default y config RT_USING_PTHREADS - bool "Enable pthreads APIs" - default y + bool "Enable pthreads APIs" + default n + +if RT_USING_LIBC + config RT_USING_POSIX_STDIN + bool "Enable stdin" + select RT_USING_DFS + select RT_USING_DFS_DEVFS + default y + + config RT_USING_POSIX_MMAP + bool "Enable mmap() api" + default n + + config RT_USING_POSIX_TERMIOS + bool "Enable termios feature" + default n +endif endmenu diff --git a/components/libc/SConscript b/components/libc/SConscript index aa86bdee86..4c815c49b8 100644 --- a/components/libc/SConscript +++ b/components/libc/SConscript @@ -1,27 +1,15 @@ -# for libc component -import os -Import('rtconfig') +# RT-Thread building script for bridge +import os from building import * +cwd = GetCurrentDir() objs = [] -cwd = GetCurrentDir() - -if GetDepend('RT_USING_LIBC'): - if os.path.isfile(os.path.join(cwd, 'newlib/SConscript')) and rtconfig.PLATFORM == 'gcc': - objs = objs + SConscript('newlib/SConscript') - elif os.path.isfile(os.path.join(cwd, 'armlibc/SConscript')) and rtconfig.PLATFORM == 'armcc': - objs = objs + SConscript('armlibc/SConscript') - elif os.path.isfile(os.path.join(cwd, 'dlib/SConscript')) and rtconfig.PLATFORM == 'iar': - objs = objs + SConscript('dlib/SConscript') -else: - if os.path.isfile(os.path.join(cwd, 'minilibc/SConscript')) and rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim': - objs = objs + SConscript('minilibc/SConscript') - -if GetDepend('RT_USING_LIBC') and GetDepend('RT_USING_PTHREADS'): - objs = objs + SConscript('pthreads/SConscript') +list = os.listdir(cwd) -if GetDepend('RT_USING_MODULE') and GetDepend('RT_USING_LIBDL'): - objs = objs + SConscript('libdl/SConscript') +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) Return('objs') diff --git a/components/libc/compilers/SConscript b/components/libc/compilers/SConscript new file mode 100644 index 0000000000..4c815c49b8 --- /dev/null +++ b/components/libc/compilers/SConscript @@ -0,0 +1,15 @@ +# RT-Thread building script for bridge + +import os +from building import * + +cwd = GetCurrentDir() +objs = [] +list = os.listdir(cwd) + +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + objs = objs + SConscript(os.path.join(d, 'SConscript')) + +Return('objs') diff --git a/components/libc/compilers/armlibc/SConscript b/components/libc/compilers/armlibc/SConscript index 29f342a1c1..8968abaa82 100644 --- a/components/libc/compilers/armlibc/SConscript +++ b/components/libc/compilers/armlibc/SConscript @@ -1,12 +1,15 @@ from building import * +Import('rtconfig') -src = Glob('*.c') -cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +cwd = GetCurrentDir() +group = [] CPPPATH = [cwd] CPPDEFINES = ['RT_USING_ARM_LIBC'] -group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], - CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) +if rtconfig.PLATFORM == 'armcc': + group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], + CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/dlib/SConscript b/components/libc/compilers/dlib/SConscript index 44be106e03..8ae7484894 100644 --- a/components/libc/compilers/dlib/SConscript +++ b/components/libc/compilers/dlib/SConscript @@ -1,8 +1,8 @@ from building import * -import rtconfig +Import('rtconfig') -src = Glob('*.c') -cwd = GetCurrentDir() +src = Glob('*.c') +cwd = GetCurrentDir() group = [] CPPPATH = [cwd] diff --git a/components/libc/compilers/minilibc/SConscript b/components/libc/compilers/minilibc/SConscript index b0c82a7125..da68881349 100644 --- a/components/libc/compilers/minilibc/SConscript +++ b/components/libc/compilers/minilibc/SConscript @@ -1,13 +1,15 @@ -Import('RTT_ROOT') from building import * +Import('rtconfig') -src = Glob('*.c') +src = Glob('*.c') + Glob('*.cpp') cwd = GetCurrentDir() +group = [] CPPPATH = [cwd] CPPDEFINES = ['RT_USING_MINILIBC'] -group = DefineGroup('libc', src, depend = ['RT_USING_MINILIBC'], - CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) +if rtconfig.PLATFORM == 'gcc' and not GetDepend('RT_USING_LIBC'): + group = DefineGroup('libc', src, depend = [''], + CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/newlib/SConscript b/components/libc/compilers/newlib/SConscript index 574c2a8d1f..06e5faad09 100644 --- a/components/libc/compilers/newlib/SConscript +++ b/components/libc/compilers/newlib/SConscript @@ -1,7 +1,9 @@ from building import * +Import('rtconfig') -src = Glob('*.c') +src = Glob('*.c') cwd = GetCurrentDir() +group = [] CPPPATH = [cwd] CPPDEFINES = ['RT_USING_NEWLIB'] @@ -12,7 +14,8 @@ CPPDEFINES = ['RT_USING_NEWLIB'] # been referenced. So setting this won't result in bigger text size. LIBS = ['c', 'm'] -group = DefineGroup('newlib', src, depend = ['RT_USING_LIBC'], - CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) +if rtconfig.PLATFORM == 'gcc': + group = DefineGroup('newlib', src, depend = ['RT_USING_LIBC'], + CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) Return('group') diff --git a/components/libc/libdl/SConscript b/components/libc/libdl/SConscript index f7f588858a..493dd4b256 100644 --- a/components/libc/libdl/SConscript +++ b/components/libc/libdl/SConscript @@ -1,9 +1,14 @@ from building import * +Import('rtconfig') -src = Glob('*.c') +src = Glob('*.c') + Glob('*.cpp') cwd = GetCurrentDir() +group = [] CPPPATH = [cwd] -group = DefineGroup('libdl', src, depend = ['RT_USING_MODULE', 'RT_USING_LIBDL'], CPPPATH = CPPPATH) +if rtconfig.PLATFORM == 'gcc': + group = DefineGroup('libc', src, + depend = ['RT_USING_MODULE', 'RT_USING_LIBDL'], + CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/pthreads/SConscript b/components/libc/pthreads/SConscript index 9023e12c13..1b7b75bfd1 100644 --- a/components/libc/pthreads/SConscript +++ b/components/libc/pthreads/SConscript @@ -4,6 +4,7 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH) +group = DefineGroup('pthreads', src, + depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH) Return('group') -- GitLab