Skip to content

Commit 7f84ac8

Browse files
authored
Merge pull request #3766 from margguo/fixbug/keep_user_lib_configuration
fixbug:keep user's lib configuration while running --target=eclipse
2 parents 688a9f7 + aa411a2 commit 7f84ac8

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

tools/eclipse.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from building import *
2424

25-
MODULE_VER_NUM = 4
25+
MODULE_VER_NUM = 5
2626

2727
source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm']
2828

@@ -138,6 +138,20 @@ def IsRttEclipsePathFormat(path):
138138
return True
139139
else :
140140
return False
141+
142+
# all libs added by scons should be ends with five whitespace as a flag
143+
rtt_lib_flag = 5 * " "
144+
145+
146+
def ConverToRttEclipseLibFormat(lib):
147+
return str(lib) + str(rtt_lib_flag)
148+
149+
150+
def IsRttEclipseLibFormat(path):
151+
if path.endswith(rtt_lib_flag):
152+
return True
153+
else:
154+
return False
141155

142156

143157
def IsCppProject():
@@ -189,7 +203,7 @@ def HandleToolOption(tools, env, project, reset):
189203
linker_script_option = option
190204
elif option.get('id').find('linker.nostart') != -1:
191205
linker_nostart_option = option
192-
elif option.get('id').find('linker.libs') != -1 and env.has_key('LIBS'):
206+
elif option.get('id').find('linker.libs') != -1:
193207
linker_libs_option = option
194208
elif option.get('id').find('linker.paths') != -1 and env.has_key('LIBPATH'):
195209
linker_paths_option = option
@@ -288,16 +302,22 @@ def HandleToolOption(tools, env, project, reset):
288302
else:
289303
option.set('value', 'false')
290304
# update libs
291-
if linker_libs_option is not None :
305+
if linker_libs_option is not None:
292306
option = linker_libs_option
293307
# remove old libs
294308
for item in option.findall('listOptionValue'):
295-
option.remove(item)
309+
if IsRttEclipseLibFormat(item.get("value")):
310+
option.remove(item)
311+
296312
# add new libs
297-
for lib in env['LIBS']:
298-
SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': lib})
313+
if env.has_key('LIBS'):
314+
for lib in env['LIBS']:
315+
formatedLib = ConverToRttEclipseLibFormat(lib)
316+
SubElement(option, 'listOptionValue', {
317+
'builtIn': 'false', 'value': formatedLib})
318+
299319
# update lib paths
300-
if linker_paths_option is not None :
320+
if linker_paths_option is not None:
301321
option = linker_paths_option
302322
# remove old lib paths
303323
for item in option.findall('listOptionValue'):

0 commit comments

Comments
 (0)