Merge pull request #3766 from margguo/fixbug/keep_user_lib_configuration

fixbug:keep user's lib configuration while running --target=eclipse
This commit is contained in:
Bernard Xiong 2020-07-27 17:40:00 +08:00 committed by GitHub
commit 7f84ac875e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 7 deletions

View File

@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement
from building import * from building import *
MODULE_VER_NUM = 4 MODULE_VER_NUM = 5
source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm']
@ -139,6 +139,20 @@ def IsRttEclipsePathFormat(path):
else : else :
return False return False
# all libs added by scons should be ends with five whitespace as a flag
rtt_lib_flag = 5 * " "
def ConverToRttEclipseLibFormat(lib):
return str(lib) + str(rtt_lib_flag)
def IsRttEclipseLibFormat(path):
if path.endswith(rtt_lib_flag):
return True
else:
return False
def IsCppProject(): def IsCppProject():
return GetDepend('RT_USING_CPLUSPLUS') return GetDepend('RT_USING_CPLUSPLUS')
@ -189,7 +203,7 @@ def HandleToolOption(tools, env, project, reset):
linker_script_option = option linker_script_option = option
elif option.get('id').find('linker.nostart') != -1: elif option.get('id').find('linker.nostart') != -1:
linker_nostart_option = option linker_nostart_option = option
elif option.get('id').find('linker.libs') != -1 and env.has_key('LIBS'): elif option.get('id').find('linker.libs') != -1:
linker_libs_option = option linker_libs_option = option
elif option.get('id').find('linker.paths') != -1 and env.has_key('LIBPATH'): elif option.get('id').find('linker.paths') != -1 and env.has_key('LIBPATH'):
linker_paths_option = option linker_paths_option = option
@ -288,16 +302,22 @@ def HandleToolOption(tools, env, project, reset):
else: else:
option.set('value', 'false') option.set('value', 'false')
# update libs # update libs
if linker_libs_option is not None : if linker_libs_option is not None:
option = linker_libs_option option = linker_libs_option
# remove old libs # remove old libs
for item in option.findall('listOptionValue'): for item in option.findall('listOptionValue'):
option.remove(item) if IsRttEclipseLibFormat(item.get("value")):
option.remove(item)
# add new libs # add new libs
for lib in env['LIBS']: if env.has_key('LIBS'):
SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': lib}) for lib in env['LIBS']:
formatedLib = ConverToRttEclipseLibFormat(lib)
SubElement(option, 'listOptionValue', {
'builtIn': 'false', 'value': formatedLib})
# update lib paths # update lib paths
if linker_paths_option is not None : if linker_paths_option is not None:
option = linker_paths_option option = linker_paths_option
# remove old lib paths # remove old lib paths
for item in option.findall('listOptionValue'): for item in option.findall('listOptionValue'):