From 30c793fdb99376197a569d28ec74d76cfc6d6638 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 20 Aug 2023 13:26:39 -0400 Subject: [PATCH] [tools] add GetGCCLikePLATFORM GCC like means the toolchains which are compatible with GCC --- bsp/renesas/ra6m3-hmi-board/SConscript | 3 ++- bsp/renesas/ra6m3-hmi-board/ra/SConscript | 3 ++- bsp/renesas/ra6m3-hmi-board/ra_cfg/SConscript | 3 ++- bsp/renesas/ra6m3-hmi-board/ra_gen/SConscript | 3 ++- components/drivers/spi/SConscript | 3 ++- components/libc/cplusplus/SConscript | 4 ++-- tools/gcc.py | 4 ++++ 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bsp/renesas/ra6m3-hmi-board/SConscript b/bsp/renesas/ra6m3-hmi-board/SConscript index 8620251606..ba761a6dc6 100644 --- a/bsp/renesas/ra6m3-hmi-board/SConscript +++ b/bsp/renesas/ra6m3-hmi-board/SConscript @@ -3,6 +3,7 @@ import os Import('RTT_ROOT') Import('rtconfig') from building import * +from gcc import * cwd = GetCurrentDir() src = [] @@ -12,7 +13,7 @@ list = os.listdir(cwd) if rtconfig.PLATFORM in ['iccarm']: print("\nThe current project does not support IAR build\n") Return('group') -elif rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']: +elif rtconfig.PLATFORM in GetGCCLikePLATFORM(): if GetOption('target') != 'mdk5': CPPPATH = [cwd] src = Glob('./src/*.c') diff --git a/bsp/renesas/ra6m3-hmi-board/ra/SConscript b/bsp/renesas/ra6m3-hmi-board/ra/SConscript index cf3df4cedf..52e96ac900 100644 --- a/bsp/renesas/ra6m3-hmi-board/ra/SConscript +++ b/bsp/renesas/ra6m3-hmi-board/ra/SConscript @@ -1,6 +1,7 @@ Import('RTT_ROOT') Import('rtconfig') from building import * +from gcc import * cwd = GetCurrentDir() src = [] @@ -10,7 +11,7 @@ CPPPATH = [] if rtconfig.PLATFORM in ['iccarm']: print("\nThe current project does not support IAR build\n") Return('group') -elif rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']: +elif rtconfig.PLATFORM in GetGCCLikePLATFORM(): if GetOption('target') != 'mdk5': src += Glob(cwd + '/fsp/src/bsp/mcu/all/*.c') src += [cwd + '/fsp/src/bsp/cmsis/Device/RENESAS/Source/system.c'] diff --git a/bsp/renesas/ra6m3-hmi-board/ra_cfg/SConscript b/bsp/renesas/ra6m3-hmi-board/ra_cfg/SConscript index 9521924a3e..ff52ceb4fe 100644 --- a/bsp/renesas/ra6m3-hmi-board/ra_cfg/SConscript +++ b/bsp/renesas/ra6m3-hmi-board/ra_cfg/SConscript @@ -1,6 +1,7 @@ Import('RTT_ROOT') Import('rtconfig') from building import * +from gcc import * cwd = GetCurrentDir() src = [] @@ -10,7 +11,7 @@ CPPPATH = [] if rtconfig.PLATFORM in ['iccarm']: print("\nThe current project does not support IAR build\n") Return('group') -elif rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']: +elif rtconfig.PLATFORM in GetGCCLikePLATFORM(): if GetOption('target') != 'mdk5': src = Glob('*.c') CPPPATH = [cwd+'/fsp_cfg', cwd + '/fsp_cfg/bsp'] diff --git a/bsp/renesas/ra6m3-hmi-board/ra_gen/SConscript b/bsp/renesas/ra6m3-hmi-board/ra_gen/SConscript index 87a3c39d18..6a52bcd615 100644 --- a/bsp/renesas/ra6m3-hmi-board/ra_gen/SConscript +++ b/bsp/renesas/ra6m3-hmi-board/ra_gen/SConscript @@ -1,6 +1,7 @@ Import('RTT_ROOT') Import('rtconfig') from building import * +from gcc import * cwd = GetCurrentDir() src = [] @@ -10,7 +11,7 @@ CPPPATH = [] if rtconfig.PLATFORM in ['iccarm']: print("\nThe current project does not support IAR build\n") Return('group') -elif rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']: +elif rtconfig.PLATFORM in GetGCCLikePLATFORM(): if GetOption('target') != 'mdk5': src = Glob('*.c') CPPPATH = [cwd, ] diff --git a/components/drivers/spi/SConscript b/components/drivers/spi/SConscript index e84ed7bb06..cea447fab4 100644 --- a/components/drivers/spi/SConscript +++ b/components/drivers/spi/SConscript @@ -1,4 +1,5 @@ from building import * +from gcc import * import rtconfig cwd = GetCurrentDir() @@ -29,7 +30,7 @@ if GetDepend('RT_USING_SFUD'): if GetDepend('RT_SFUD_USING_SFDP'): src_device += ['sfud/src/sfud_sfdp.c'] - if rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']: + if rtconfig.PLATFORM in GetGCCLikePLATFORM(): LOCAL_CFLAGS += ' -std=c99' elif rtconfig.PLATFORM in ['armcc']: LOCAL_CFLAGS += ' --c99' diff --git a/components/libc/cplusplus/SConscript b/components/libc/cplusplus/SConscript index 2f280892f4..8b3a2f6f86 100644 --- a/components/libc/cplusplus/SConscript +++ b/components/libc/cplusplus/SConscript @@ -1,4 +1,5 @@ from building import * +from gcc import * import os Import('rtconfig') @@ -7,8 +8,7 @@ src = ['cxx_crt_init.c', 'cxx_crt.cpp'] CPPPATH = [cwd] CXXFLAGS = '' - -if rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm'] and not GetDepend('RT_USING_CPP_EXCEPTIONS'): +if rtconfig.PLATFORM in GetGCCLikePLATFORM() and not GetDepend('RT_USING_CPP_EXCEPTIONS'): CXXFLAGS += ' -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections' # reduce resource consumptions group = DefineGroup('CPP', src, depend=['RT_USING_CPLUSPLUS'], CPPPATH=CPPPATH, CXXFLAGS=CXXFLAGS) diff --git a/tools/gcc.py b/tools/gcc.py index 390fd2868e..a3e0344200 100644 --- a/tools/gcc.py +++ b/tools/gcc.py @@ -66,6 +66,10 @@ def CheckHeader(rtconfig, filename): return False +# GCC like means the toolchains which are compatible with GCC +def GetGCCLikePLATFORM(): + return ['gcc', 'armclang', 'llvm-arm'] + def GetNewLibVersion(rtconfig): version = None root = GetGCCRoot(rtconfig)