[Tools] Modify buliding.py and gcc.py for work with python 3.
This commit is contained in:
parent
ddd7343b0c
commit
3a63c0af56
|
@ -83,13 +83,13 @@ class Win32Spawn:
|
||||||
try:
|
try:
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print 'Error removing file: %s' % e
|
print ('Error removing file: ' + e)
|
||||||
return -1
|
return -1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
newargs = string.join(args[1:], ' ')
|
newargs = ' '.join(args[1:])
|
||||||
cmdline = cmd + " " + newargs
|
cmdline = cmd + " " + newargs
|
||||||
|
|
||||||
# Make sure the env is constructed by strings
|
# Make sure the env is constructed by strings
|
||||||
|
@ -104,8 +104,8 @@ class Win32Spawn:
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(cmdline, env=_e, shell=False)
|
proc = subprocess.Popen(cmdline, env=_e, shell=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print 'Error in calling:\n%s' % cmdline
|
print ('Error in calling:\n' + cmdline)
|
||||||
print 'Exception: %s: %s' % (e, os.strerror(e.errno))
|
print ('Exception: ' + e + ': ' + os.strerror(e.errno))
|
||||||
return e.errno
|
return e.errno
|
||||||
finally:
|
finally:
|
||||||
os.environ['PATH'] = old_path
|
os.environ['PATH'] = old_path
|
||||||
|
@ -124,7 +124,7 @@ def GenCconfigFile(env, BuildOptions):
|
||||||
|
|
||||||
# try again
|
# try again
|
||||||
if os.path.isfile('cconfig.h'):
|
if os.path.isfile('cconfig.h'):
|
||||||
f = file('cconfig.h', 'r')
|
f = open('cconfig.h', 'r')
|
||||||
if f:
|
if f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
f.close();
|
f.close();
|
||||||
|
@ -225,7 +225,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
# --target will change the toolchain settings which clang-analyzer is
|
# --target will change the toolchain settings which clang-analyzer is
|
||||||
# depend on
|
# depend on
|
||||||
if GetOption('clang-analyzer'):
|
if GetOption('clang-analyzer'):
|
||||||
print '--clang-analyzer cannot be used with --target'
|
print ('--clang-analyzer cannot be used with --target')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
SetOption('no_exec', 1)
|
SetOption('no_exec', 1)
|
||||||
|
@ -235,8 +235,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
os.environ['RTT_CC'] = rtconfig.CROSS_TOOL
|
os.environ['RTT_CC'] = rtconfig.CROSS_TOOL
|
||||||
reload(rtconfig)
|
reload(rtconfig)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print 'Unknow target: %s. Avaible targets: %s' % \
|
print ('Unknow target: '+ tgt_name+'. Avaible targets: ' +', '.join(tgt_dict.keys()))
|
||||||
(tgt_name, ', '.join(tgt_dict.keys()))
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif (GetDepend('RT_USING_NEWLIB') == False and GetDepend('RT_USING_NOLIBC') == False) \
|
elif (GetDepend('RT_USING_NEWLIB') == False and GetDepend('RT_USING_NOLIBC') == False) \
|
||||||
and rtconfig.PLATFORM == 'gcc':
|
and rtconfig.PLATFORM == 'gcc':
|
||||||
|
@ -287,7 +286,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
|
|
||||||
# parse rtconfig.h to get used component
|
# parse rtconfig.h to get used component
|
||||||
PreProcessor = PatchedPreProcessor()
|
PreProcessor = PatchedPreProcessor()
|
||||||
f = file('rtconfig.h', 'r')
|
f = open('rtconfig.h', 'r')
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
PreProcessor.process_contents(contents)
|
PreProcessor.process_contents(contents)
|
||||||
|
@ -438,7 +437,7 @@ def GetConfigValue(name):
|
||||||
def GetDepend(depend):
|
def GetDepend(depend):
|
||||||
building = True
|
building = True
|
||||||
if type(depend) == type('str'):
|
if type(depend) == type('str'):
|
||||||
if not BuildOptions.has_key(depend) or BuildOptions[depend] == 0:
|
if not depend in BuildOptions or BuildOptions[depend] == 0:
|
||||||
building = False
|
building = False
|
||||||
elif BuildOptions[depend] != '':
|
elif BuildOptions[depend] != '':
|
||||||
return BuildOptions[depend]
|
return BuildOptions[depend]
|
||||||
|
@ -448,7 +447,7 @@ def GetDepend(depend):
|
||||||
# for list type depend
|
# for list type depend
|
||||||
for item in depend:
|
for item in depend:
|
||||||
if item != '':
|
if item != '':
|
||||||
if not BuildOptions.has_key(item) or BuildOptions[item] == 0:
|
if not item in BuildOptions or BuildOptions[item] == 0:
|
||||||
building = False
|
building = False
|
||||||
|
|
||||||
return building
|
return building
|
||||||
|
@ -471,7 +470,7 @@ def LocalOptions(config_filename):
|
||||||
def GetLocalDepend(options, depend):
|
def GetLocalDepend(options, depend):
|
||||||
building = True
|
building = True
|
||||||
if type(depend) == type('str'):
|
if type(depend) == type('str'):
|
||||||
if not options.has_key(depend) or options[depend] == 0:
|
if not depend in options or options[depend] == 0:
|
||||||
building = False
|
building = False
|
||||||
elif options[depend] != '':
|
elif options[depend] != '':
|
||||||
return options[depend]
|
return options[depend]
|
||||||
|
@ -481,7 +480,7 @@ def GetLocalDepend(options, depend):
|
||||||
# for list type depend
|
# for list type depend
|
||||||
for item in depend:
|
for item in depend:
|
||||||
if item != '':
|
if item != '':
|
||||||
if not options.has_key(item) or options[item] == 0:
|
if not item in options or options[item] == 0:
|
||||||
building = False
|
building = False
|
||||||
|
|
||||||
return building
|
return building
|
||||||
|
@ -491,61 +490,61 @@ def AddDepend(option):
|
||||||
|
|
||||||
def MergeGroup(src_group, group):
|
def MergeGroup(src_group, group):
|
||||||
src_group['src'] = src_group['src'] + group['src']
|
src_group['src'] = src_group['src'] + group['src']
|
||||||
if group.has_key('CCFLAGS'):
|
if 'CCFLAGS' in group:
|
||||||
if src_group.has_key('CCFLAGS'):
|
if 'CCFLAGS' in src_group:
|
||||||
src_group['CCFLAGS'] = src_group['CCFLAGS'] + group['CCFLAGS']
|
src_group['CCFLAGS'] = src_group['CCFLAGS'] + group['CCFLAGS']
|
||||||
else:
|
else:
|
||||||
src_group['CCFLAGS'] = group['CCFLAGS']
|
src_group['CCFLAGS'] = group['CCFLAGS']
|
||||||
if group.has_key('CPPPATH'):
|
if 'CPPPATH' in group:
|
||||||
if src_group.has_key('CPPPATH'):
|
if 'CPPPATH' in src_group:
|
||||||
src_group['CPPPATH'] = src_group['CPPPATH'] + group['CPPPATH']
|
src_group['CPPPATH'] = src_group['CPPPATH'] + group['CPPPATH']
|
||||||
else:
|
else:
|
||||||
src_group['CPPPATH'] = group['CPPPATH']
|
src_group['CPPPATH'] = group['CPPPATH']
|
||||||
if group.has_key('CPPDEFINES'):
|
if 'CPPDEFINES' in group:
|
||||||
if src_group.has_key('CPPDEFINES'):
|
if 'CPPDEFINES' in src_group:
|
||||||
src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
|
src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
|
||||||
else:
|
else:
|
||||||
src_group['CPPDEFINES'] = group['CPPDEFINES']
|
src_group['CPPDEFINES'] = group['CPPDEFINES']
|
||||||
if group.has_key('ASFLAGS'):
|
if 'ASFLAGS' in group:
|
||||||
if src_group.has_key('ASFLAGS'):
|
if 'ASFLAGS' in src_group:
|
||||||
src_group['ASFLAGS'] = src_group['ASFLAGS'] + group['ASFLAGS']
|
src_group['ASFLAGS'] = src_group['ASFLAGS'] + group['ASFLAGS']
|
||||||
else:
|
else:
|
||||||
src_group['ASFLAGS'] = group['ASFLAGS']
|
src_group['ASFLAGS'] = group['ASFLAGS']
|
||||||
|
|
||||||
# for local CCFLAGS/CPPPATH/CPPDEFINES
|
# for local CCFLAGS/CPPPATH/CPPDEFINES
|
||||||
if group.has_key('LOCAL_CCFLAGS'):
|
if 'LOCAL_CCFLAGS' in group:
|
||||||
if src_group.has_key('LOCAL_CCFLAGS'):
|
if 'LOCAL_CCFLAGS' in src_group:
|
||||||
src_group['LOCAL_CCFLAGS'] = src_group['LOCAL_CCFLAGS'] + group['LOCAL_CCFLAGS']
|
src_group['LOCAL_CCFLAGS'] = src_group['LOCAL_CCFLAGS'] + group['LOCAL_CCFLAGS']
|
||||||
else:
|
else:
|
||||||
src_group['LOCAL_CCFLAGS'] = group['LOCAL_CCFLAGS']
|
src_group['LOCAL_CCFLAGS'] = group['LOCAL_CCFLAGS']
|
||||||
if group.has_key('LOCAL_CPPPATH'):
|
if 'LOCAL_CPPPATH' in group:
|
||||||
if src_group.has_key('LOCAL_CPPPATH'):
|
if 'LOCAL_CPPPATH' in src_group:
|
||||||
src_group['LOCAL_CPPPATH'] = src_group['LOCAL_CPPPATH'] + group['LOCAL_CPPPATH']
|
src_group['LOCAL_CPPPATH'] = src_group['LOCAL_CPPPATH'] + group['LOCAL_CPPPATH']
|
||||||
else:
|
else:
|
||||||
src_group['LOCAL_CPPPATH'] = group['LOCAL_CPPPATH']
|
src_group['LOCAL_CPPPATH'] = group['LOCAL_CPPPATH']
|
||||||
if group.has_key('LOCAL_CPPDEFINES'):
|
if 'LOCAL_CPPDEFINES' in group:
|
||||||
if src_group.has_key('LOCAL_CPPDEFINES'):
|
if 'LOCAL_CPPDEFINES' in src_group:
|
||||||
src_group['LOCAL_CPPDEFINES'] = src_group['LOCAL_CPPDEFINES'] + group['LOCAL_CPPDEFINES']
|
src_group['LOCAL_CPPDEFINES'] = src_group['LOCAL_CPPDEFINES'] + group['LOCAL_CPPDEFINES']
|
||||||
else:
|
else:
|
||||||
src_group['LOCAL_CPPDEFINES'] = group['LOCAL_CPPDEFINES']
|
src_group['LOCAL_CPPDEFINES'] = group['LOCAL_CPPDEFINES']
|
||||||
|
|
||||||
if group.has_key('LINKFLAGS'):
|
if 'LINKFLAGS' in group:
|
||||||
if src_group.has_key('LINKFLAGS'):
|
if 'LINKFLAGS' in src_group:
|
||||||
src_group['LINKFLAGS'] = src_group['LINKFLAGS'] + group['LINKFLAGS']
|
src_group['LINKFLAGS'] = src_group['LINKFLAGS'] + group['LINKFLAGS']
|
||||||
else:
|
else:
|
||||||
src_group['LINKFLAGS'] = group['LINKFLAGS']
|
src_group['LINKFLAGS'] = group['LINKFLAGS']
|
||||||
if group.has_key('LIBS'):
|
if 'LIBS' in group:
|
||||||
if src_group.has_key('LIBS'):
|
if 'LIBS' in src_group:
|
||||||
src_group['LIBS'] = src_group['LIBS'] + group['LIBS']
|
src_group['LIBS'] = src_group['LIBS'] + group['LIBS']
|
||||||
else:
|
else:
|
||||||
src_group['LIBS'] = group['LIBS']
|
src_group['LIBS'] = group['LIBS']
|
||||||
if group.has_key('LIBPATH'):
|
if 'LIBPATH' in group:
|
||||||
if src_group.has_key('LIBPATH'):
|
if 'LIBPATH' in src_group:
|
||||||
src_group['LIBPATH'] = src_group['LIBPATH'] + group['LIBPATH']
|
src_group['LIBPATH'] = src_group['LIBPATH'] + group['LIBPATH']
|
||||||
else:
|
else:
|
||||||
src_group['LIBPATH'] = group['LIBPATH']
|
src_group['LIBPATH'] = group['LIBPATH']
|
||||||
if group.has_key('LOCAL_ASFLAGS'):
|
if 'LOCAL_ASFLAGS' in group:
|
||||||
if src_group.has_key('LOCAL_ASFLAGS'):
|
if 'LOCAL_ASFLAGS' in src_group:
|
||||||
src_group['LOCAL_ASFLAGS'] = src_group['LOCAL_ASFLAGS'] + group['LOCAL_ASFLAGS']
|
src_group['LOCAL_ASFLAGS'] = src_group['LOCAL_ASFLAGS'] + group['LOCAL_ASFLAGS']
|
||||||
else:
|
else:
|
||||||
src_group['LOCAL_ASFLAGS'] = group['LOCAL_ASFLAGS']
|
src_group['LOCAL_ASFLAGS'] = group['LOCAL_ASFLAGS']
|
||||||
|
@ -571,32 +570,32 @@ def DefineGroup(name, src, depend, **parameters):
|
||||||
else:
|
else:
|
||||||
group['src'] = src
|
group['src'] = src
|
||||||
|
|
||||||
if group.has_key('CCFLAGS'):
|
if 'CCFLAGS' in group:
|
||||||
Env.AppendUnique(CCFLAGS = group['CCFLAGS'])
|
Env.AppendUnique(CCFLAGS = group['CCFLAGS'])
|
||||||
if group.has_key('CPPPATH'):
|
if 'CPPPATH' in group:
|
||||||
Env.AppendUnique(CPPPATH = group['CPPPATH'])
|
Env.AppendUnique(CPPPATH = group['CPPPATH'])
|
||||||
if group.has_key('CPPDEFINES'):
|
if 'CPPDEFINES' in group:
|
||||||
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES'])
|
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES'])
|
||||||
if group.has_key('LINKFLAGS'):
|
if 'LINKFLAGS' in group:
|
||||||
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS'])
|
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS'])
|
||||||
if group.has_key('ASFLAGS'):
|
if 'ASFLAGS' in group:
|
||||||
Env.AppendUnique(ASFLAGS = group['ASFLAGS'])
|
Env.AppendUnique(ASFLAGS = group['ASFLAGS'])
|
||||||
|
|
||||||
# check whether to clean up library
|
# check whether to clean up library
|
||||||
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
|
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
|
||||||
if group['src'] != []:
|
if group['src'] != []:
|
||||||
print 'Remove library:', GroupLibFullName(name, Env)
|
print ('Remove library:'+ GroupLibFullName(name, Env))
|
||||||
fn = os.path.join(group['path'], GroupLibFullName(name, Env))
|
fn = os.path.join(group['path'], GroupLibFullName(name, Env))
|
||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
os.unlink(fn)
|
os.unlink(fn)
|
||||||
|
|
||||||
if group.has_key('LIBS'):
|
if 'LIBS' in group:
|
||||||
Env.AppendUnique(LIBS = group['LIBS'])
|
Env.AppendUnique(LIBS = group['LIBS'])
|
||||||
if group.has_key('LIBPATH'):
|
if 'LIBPATH' in group:
|
||||||
Env.AppendUnique(LIBPATH = group['LIBPATH'])
|
Env.AppendUnique(LIBPATH = group['LIBPATH'])
|
||||||
|
|
||||||
# check whether to build group library
|
# check whether to build group library
|
||||||
if group.has_key('LIBRARY'):
|
if 'LIBRARY' in group:
|
||||||
objs = Env.Library(name, group['src'])
|
objs = Env.Library(name, group['src'])
|
||||||
else:
|
else:
|
||||||
# only add source
|
# only add source
|
||||||
|
@ -650,7 +649,7 @@ def BuildLibInstallAction(target, source, env):
|
||||||
if Group['name'] == lib_name:
|
if Group['name'] == lib_name:
|
||||||
lib_name = GroupLibFullName(Group['name'], env)
|
lib_name = GroupLibFullName(Group['name'], env)
|
||||||
dst_name = os.path.join(Group['path'], lib_name)
|
dst_name = os.path.join(Group['path'], lib_name)
|
||||||
print 'Copy %s => %s' % (lib_name, dst_name)
|
print ('Copy '+lib_name+' => ' +dst_name)
|
||||||
do_copy_file(lib_name, dst_name)
|
do_copy_file(lib_name, dst_name)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -668,7 +667,7 @@ def DoBuilding(target, objects):
|
||||||
|
|
||||||
# handle local group
|
# handle local group
|
||||||
def local_group(group, objects):
|
def local_group(group, objects):
|
||||||
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES') or group.has_key('LOCAL_ASFLAGS'):
|
if 'LOCAL_CCFLAGS' in group or 'LOCAL_CPPPATH' in group or 'LOCAL_CPPDEFINES' in group or 'LOCAL_ASFLAGS' in group:
|
||||||
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
|
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
|
||||||
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
|
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
|
||||||
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
|
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
|
||||||
|
@ -705,7 +704,7 @@ def DoBuilding(target, objects):
|
||||||
else:
|
else:
|
||||||
# remove source files with local flags setting
|
# remove source files with local flags setting
|
||||||
for group in Projects:
|
for group in Projects:
|
||||||
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
|
if 'LOCAL_CCFLAGS' in group or 'LOCAL_CPPPATH' in group or 'LOCAL_CPPDEFINES' in group:
|
||||||
for source in group['src']:
|
for source in group['src']:
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
|
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
|
||||||
|
@ -738,7 +737,7 @@ def GenTargetProject(program = None):
|
||||||
if template:
|
if template:
|
||||||
MDK5Project('project.uvprojx', Projects)
|
MDK5Project('project.uvprojx', Projects)
|
||||||
else:
|
else:
|
||||||
print 'No template project file found.'
|
print ('No template project file found.')
|
||||||
|
|
||||||
if GetOption('target') == 'mdk4':
|
if GetOption('target') == 'mdk4':
|
||||||
from keil import MDK4Project
|
from keil import MDK4Project
|
||||||
|
@ -807,7 +806,7 @@ def EndBuilding(target, program = None):
|
||||||
|
|
||||||
if not GetOption('help') and not GetOption('target'):
|
if not GetOption('help') and not GetOption('target'):
|
||||||
if not os.path.exists(rtconfig.EXEC_PATH):
|
if not os.path.exists(rtconfig.EXEC_PATH):
|
||||||
print "Error: the toolchain path (%s) is not exist, please check 'EXEC_PATH' in path or rtconfig.py." % rtconfig.EXEC_PATH
|
print ("Error: the toolchain path ("+rtconfig.EXEC_PATH+") is not exist, please check 'EXEC_PATH' in path or rtconfig.py.")
|
||||||
need_exit = True
|
need_exit = True
|
||||||
|
|
||||||
if need_exit:
|
if need_exit:
|
||||||
|
@ -873,7 +872,7 @@ def GetVersion():
|
||||||
version = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_VERSION']))
|
version = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_VERSION']))
|
||||||
subversion = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_SUBVERSION']))
|
subversion = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_SUBVERSION']))
|
||||||
|
|
||||||
if def_ns.has_key('RT_REVISION'):
|
if 'RT_REVISION' in def_ns:
|
||||||
revision = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_REVISION']))
|
revision = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_REVISION']))
|
||||||
return '%d.%d.%d' % (version, subversion, revision)
|
return '%d.%d.%d' % (version, subversion, revision)
|
||||||
|
|
||||||
|
|
33
tools/gcc.py
33
tools/gcc.py
|
@ -50,18 +50,19 @@ def GetNewLibVersion(rtconfig):
|
||||||
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 = file(os.path.join(root, 'include', '_newlib_version.h'))
|
f = open(os.path.join(root, 'include', '_newlib_version.h'), 'r')
|
||||||
if f:
|
if f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.find('_NEWLIB_VERSION') != -1 and line.find('"') != -1:
|
if line.find('_NEWLIB_VERSION') != -1 and line.find('"') != -1:
|
||||||
version = re.search(r'\"([^"]+)\"', line).groups()[0]
|
version = re.search(r'\"([^"]+)\"', line).groups()[0]
|
||||||
|
f.close()
|
||||||
elif CheckHeader(rtconfig, 'newlib.h'): # get version from newlib.h
|
elif CheckHeader(rtconfig, 'newlib.h'): # get version from newlib.h
|
||||||
f = file(os.path.join(root, 'include', 'newlib.h'))
|
f = open(os.path.join(root, 'include', 'newlib.h'), 'r')
|
||||||
if f:
|
if f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.find('_NEWLIB_VERSION') != -1 and line.find('"') != -1:
|
if line.find('_NEWLIB_VERSION') != -1 and line.find('"') != -1:
|
||||||
version = re.search(r'\"([^"]+)\"', line).groups()[0]
|
version = re.search(r'\"([^"]+)\"', line).groups()[0]
|
||||||
|
f.close()
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def GCCResult(rtconfig, str):
|
def GCCResult(rtconfig, str):
|
||||||
|
@ -77,7 +78,7 @@ def GCCResult(rtconfig, str):
|
||||||
gcc_cmd = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
|
gcc_cmd = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
|
||||||
|
|
||||||
# use temp file to get more information
|
# use temp file to get more information
|
||||||
f = file('__tmp.c', 'w')
|
f = open('__tmp.c', 'w')
|
||||||
if f:
|
if f:
|
||||||
f.write(str)
|
f.write(str)
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -103,27 +104,27 @@ def GCCResult(rtconfig, str):
|
||||||
stdc = '1989'
|
stdc = '1989'
|
||||||
posix_thread = 0
|
posix_thread = 0
|
||||||
|
|
||||||
for line in stdout.split('\n'):
|
for line in stdout.split(b'\n'):
|
||||||
if re.search('fd_set', line):
|
if re.search(b'fd_set', line):
|
||||||
have_fdset = 1
|
have_fdset = 1
|
||||||
|
|
||||||
# check for sigal
|
# check for sigal
|
||||||
if re.search('struct[ \t]+sigaction', line):
|
if re.search(b'struct[ \t]+sigaction', line):
|
||||||
have_sigaction = 1
|
have_sigaction = 1
|
||||||
if re.search('struct[ \t]+sigevent', line):
|
if re.search(b'struct[ \t]+sigevent', line):
|
||||||
have_sigevent = 1
|
have_sigevent = 1
|
||||||
if re.search('siginfo_t', line):
|
if re.search(b'siginfo_t', line):
|
||||||
have_siginfo = 1
|
have_siginfo = 1
|
||||||
if re.search('union[ \t]+sigval', line):
|
if re.search(b'union[ \t]+sigval', line):
|
||||||
have_sigval = 1
|
have_sigval = 1
|
||||||
|
|
||||||
if re.search('char\* version', line):
|
if re.search(b'char\* version', line):
|
||||||
version = re.search(r'\"([^"]+)\"', line).groups()[0]
|
version = re.search(br'\"([^"]+)\"', line).groups()[0]
|
||||||
|
|
||||||
if re.findall('iso_c_visible = [\d]+', line):
|
if re.findall(b'iso_c_visible = [\d]+', line):
|
||||||
stdc = re.findall('[\d]+', line)[0]
|
stdc = re.findall('[\d]+', line)[0]
|
||||||
|
|
||||||
if re.findall('pthread_create', line):
|
if re.findall(b'pthread_create', line):
|
||||||
posix_thread = 1
|
posix_thread = 1
|
||||||
|
|
||||||
if have_fdset:
|
if have_fdset:
|
||||||
|
@ -147,7 +148,7 @@ def GCCResult(rtconfig, str):
|
||||||
result += '#define LIBC_POSIX_THREADS 1\n'
|
result += '#define LIBC_POSIX_THREADS 1\n'
|
||||||
|
|
||||||
os.remove('__tmp.c')
|
os.remove('__tmp.c')
|
||||||
|
f.close()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def GenerateGCCConfig(rtconfig):
|
def GenerateGCCConfig(rtconfig):
|
||||||
|
@ -187,7 +188,7 @@ def GenerateGCCConfig(rtconfig):
|
||||||
cc_header += GCCResult(rtconfig, str)
|
cc_header += GCCResult(rtconfig, str)
|
||||||
cc_header += '\n#endif\n'
|
cc_header += '\n#endif\n'
|
||||||
|
|
||||||
cc_file = file('cconfig.h', 'w')
|
cc_file = open('cconfig.h', 'w')
|
||||||
if cc_file:
|
if cc_file:
|
||||||
cc_file.write(cc_header)
|
cc_file.write(cc_header)
|
||||||
cc_file.close()
|
cc_file.close()
|
||||||
|
|
Loading…
Reference in New Issue