From d5800421459bec6cea97d5fc505ffa9b0c16b8e1 Mon Sep 17 00:00:00 2001 From: "Man, Jianting (Meco)" <920369182@qq.com> Date: Sun, 30 Apr 2023 00:19:57 -0400 Subject: [PATCH] [libc] support external third pary libc software package (#7425) --- .github/workflows/action.yml | 1 - components/libc/Kconfig | 3 +++ components/libc/compilers/musl/SConscript | 6 ++--- components/libc/compilers/newlib/SConscript | 6 ++--- tools/gcc.py | 28 +++------------------ 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 4d999cbc20..2608af5399 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -44,7 +44,6 @@ jobs: - "asm9260t" - "allwinner_tina" - "ft32/ft32f072xb-starter" - - "tkm32F499" - "mini2440" - "mm32/mm32f3270-100ask-pitaya" - "sam7x" diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 3cdaba4bcf..ea6763007e 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -1,5 +1,8 @@ menu "C/C++ and POSIX layer" +config RT_USING_EXTERNAL_LIBC + bool + config RT_LIBC_DEFAULT_TIMEZONE int "Set the default time zone (UTC+)" range -12 12 diff --git a/components/libc/compilers/musl/SConscript b/components/libc/compilers/musl/SConscript index 9bc5696157..8c5d0448ae 100644 --- a/components/libc/compilers/musl/SConscript +++ b/components/libc/compilers/musl/SConscript @@ -5,10 +5,10 @@ Import('rtconfig') group = [] -libc_name, libc_version = GetGCCLibcNameVersion(rtconfig) +musllibc_version = GetMuslVersion(rtconfig) -if libc_name == 'musl': - print('Musl version: ' + libc_version) +if musllibc_version: + print('Musl version: ' + musllibc_version) cwd = GetCurrentDir() src = Glob('*.c') diff --git a/components/libc/compilers/newlib/SConscript b/components/libc/compilers/newlib/SConscript index 14d3f737f5..518fee8775 100644 --- a/components/libc/compilers/newlib/SConscript +++ b/components/libc/compilers/newlib/SConscript @@ -5,10 +5,10 @@ Import('rtconfig') group = [] -libc_name, libc_version = GetGCCLibcNameVersion(rtconfig) +newlib_version = GetNewLibVersion(rtconfig) -if libc_name == 'newlib': - print('Newlib version: ' + libc_version) +if newlib_version and not GetDepend('RT_USING_EXTERNAL_LIBC'): + print('Newlib version: ' + newlib_version) cwd = GetCurrentDir() src = Glob('*.c') diff --git a/tools/gcc.py b/tools/gcc.py index 905845f825..c82a1e9271 100644 --- a/tools/gcc.py +++ b/tools/gcc.py @@ -67,7 +67,7 @@ def CheckHeader(rtconfig, filename): return False def GetNewLibVersion(rtconfig): - version = 'unknown' + version = None root = GetGCCRoot(rtconfig) if CheckHeader(rtconfig, '_newlib_version.h'): # get version from _newlib_version.h file f = open(os.path.join(root, 'include', '_newlib_version.h'), 'r') @@ -85,33 +85,13 @@ def GetNewLibVersion(rtconfig): f.close() return version -# FIXME: it's not very good -def CheckMUSLLibc(rtconfig): - if 'musl' in rtconfig.PREFIX: - return True - return False - # FIXME: there is no musl version or musl macros can be found officially def GetMuslVersion(rtconfig): - version = 'unknown' - # root = GetGCCRoot(rtconfig) - # print(root) + version = None + if 'musl' in rtconfig.PREFIX: + version = 'unknown' return version -# return libc name and version -def GetGCCLibcNameVersion(rtconfig): - if rtconfig.PLATFORM != 'gcc': - return ('unknown', 'unknown') - - newlib_version = GetNewLibVersion(rtconfig) - if newlib_version != 'unknown': - return ('newlib', newlib_version) # libc: newlib, version: newlib_version - elif CheckMUSLLibc(rtconfig) == True: - GetMuslVersion(rtconfig) - return ('musl', 'unknown') #libc: musl, version: unknown - else: - return ('unknown', 'unknown') # libc: unknown, version: unknown - def GCCResult(rtconfig, str): import subprocess