[libc] support external third pary libc software package (#7425)

This commit is contained in:
Man, Jianting (Meco) 2023-04-30 00:19:57 -04:00 committed by GitHub
parent 74719aafc8
commit d580042145
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 31 deletions

View File

@ -44,7 +44,6 @@ jobs:
- "asm9260t" - "asm9260t"
- "allwinner_tina" - "allwinner_tina"
- "ft32/ft32f072xb-starter" - "ft32/ft32f072xb-starter"
- "tkm32F499"
- "mini2440" - "mini2440"
- "mm32/mm32f3270-100ask-pitaya" - "mm32/mm32f3270-100ask-pitaya"
- "sam7x" - "sam7x"

View File

@ -1,5 +1,8 @@
menu "C/C++ and POSIX layer" menu "C/C++ and POSIX layer"
config RT_USING_EXTERNAL_LIBC
bool
config RT_LIBC_DEFAULT_TIMEZONE config RT_LIBC_DEFAULT_TIMEZONE
int "Set the default time zone (UTC+)" int "Set the default time zone (UTC+)"
range -12 12 range -12 12

View File

@ -5,10 +5,10 @@ Import('rtconfig')
group = [] group = []
libc_name, libc_version = GetGCCLibcNameVersion(rtconfig) musllibc_version = GetMuslVersion(rtconfig)
if libc_name == 'musl': if musllibc_version:
print('Musl version: ' + libc_version) print('Musl version: ' + musllibc_version)
cwd = GetCurrentDir() cwd = GetCurrentDir()
src = Glob('*.c') src = Glob('*.c')

View File

@ -5,10 +5,10 @@ Import('rtconfig')
group = [] group = []
libc_name, libc_version = GetGCCLibcNameVersion(rtconfig) newlib_version = GetNewLibVersion(rtconfig)
if libc_name == 'newlib': if newlib_version and not GetDepend('RT_USING_EXTERNAL_LIBC'):
print('Newlib version: ' + libc_version) print('Newlib version: ' + newlib_version)
cwd = GetCurrentDir() cwd = GetCurrentDir()
src = Glob('*.c') src = Glob('*.c')

View File

@ -67,7 +67,7 @@ def CheckHeader(rtconfig, filename):
return False return False
def GetNewLibVersion(rtconfig): def GetNewLibVersion(rtconfig):
version = 'unknown' version = None
root = GetGCCRoot(rtconfig) root = GetGCCRoot(rtconfig)
if CheckHeader(rtconfig, '_newlib_version.h'): # get version from _newlib_version.h file if CheckHeader(rtconfig, '_newlib_version.h'): # get version from _newlib_version.h file
f = open(os.path.join(root, 'include', '_newlib_version.h'), 'r') f = open(os.path.join(root, 'include', '_newlib_version.h'), 'r')
@ -85,33 +85,13 @@ def GetNewLibVersion(rtconfig):
f.close() f.close()
return version 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 # FIXME: there is no musl version or musl macros can be found officially
def GetMuslVersion(rtconfig): def GetMuslVersion(rtconfig):
version = 'unknown' version = None
# root = GetGCCRoot(rtconfig) if 'musl' in rtconfig.PREFIX:
# print(root) version = 'unknown'
return version 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): def GCCResult(rtconfig, str):
import subprocess import subprocess