From fd3dd9d85b2e3858e188cce5ecb5c938390bd636 Mon Sep 17 00:00:00 2001 From: armink Date: Sun, 16 Feb 2020 18:38:53 +0800 Subject: [tools] add C++ support for eclipse target --- tools/eclipse.py | 96 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 41 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 253db37bea..916041019a 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -20,6 +20,8 @@ from utils import xml_indent import xml.etree.ElementTree as etree from xml.etree.ElementTree import SubElement +MODULE_VER_NUM = 0 + source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] def OSPath(path): @@ -134,57 +136,70 @@ def IsRttEclipsePathFormat(path): return True else : return False - - + + +def IsCppProject(): + with open('.project', mode = 'r') as f: + for line in f.readlines(): + if line.find('org.eclipse.cdt.core.ccnature') != -1: + return True + return False + + def HandleToolOption(tools, env, project, reset): + is_cpp_prj = IsCppProject() BSP_ROOT = os.path.abspath(env['BSP_ROOT']) CPPDEFINES = project['CPPDEFINES'] paths = [ConverToRttEclipsePathFormat(RelativeProjectPath(env, os.path.normpath(i)).replace('\\', '/')) for i in project['CPPPATH']] - compile_include_paths_option = None - compile_include_files_option = None - compile_defs_option = None + compile_include_paths_options = [] + compile_include_files_options = [] + compile_defs_options = [] linker_scriptfile_option = None linker_script_option = None linker_nostart_option = None linker_libs_option = None linker_paths_option = None + linker_newlib_nano_option = None for tool in tools: - if tool.get('id').find('c.compile') != 1: + if tool.get('id').find('compile') != 1: options = tool.findall('option') # find all compile options for option in options: - if option.get('id').find('c.compiler.include.paths') != -1 or option.get('id').find('c.compiler.option.includepaths') != -1: - compile_include_paths_option = option - elif option.get('id').find('c.compiler.include.files') != -1 or option.get('id').find('c.compiler.option.includefiles') != -1 : - compile_include_files_option = option - elif option.get('id').find('c.compiler.defs') != -1 or option.get('id').find('c.compiler.option.definedsymbols') != -1: - compile_defs_option = option - - if tool.get('id').find('c.linker') != -1: + if option.get('id').find('compiler.include.paths') != -1 or option.get('id').find('compiler.option.includepaths') != -1: + compile_include_paths_options += [option] + elif option.get('id').find('compiler.include.files') != -1 or option.get('id').find('compiler.option.includefiles') != -1 : + compile_include_files_options += [option] + elif option.get('id').find('compiler.defs') != -1 or option.get('id').find('compiler.option.definedsymbols') != -1: + compile_defs_options += [option] + + if tool.get('id').find('linker') != -1: options = tool.findall('option') # find all linker options for option in options: - if option.get('id').find('c.linker.scriptfile') != -1: + # the project type and option type must equal + if is_cpp_prj != (option.get('id').find('cpp.linker') != -1): + continue + + if option.get('id').find('linker.scriptfile') != -1: linker_scriptfile_option = option - elif option.get('id').find('c.linker.option.script') != -1: + elif option.get('id').find('linker.option.script') != -1: linker_script_option = option - elif option.get('id').find('c.linker.nostart') != -1: + elif option.get('id').find('linker.nostart') != -1: linker_nostart_option = option - elif option.get('id').find('c.linker.libs') != -1 and env.has_key('LIBS'): + elif option.get('id').find('linker.libs') != -1 and env.has_key('LIBS'): linker_libs_option = option - elif option.get('id').find('c.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 - elif option.get('id').find('c.linker.usenewlibnano') != -1: + elif option.get('id').find('linker.usenewlibnano') != -1: linker_newlib_nano_option = option # change the inclue path - if compile_include_paths_option is not None : - option = compile_include_paths_option + for option in compile_include_paths_options: # find all of paths in this project include_paths = option.findall('listOptionValue') for item in include_paths: @@ -196,8 +211,7 @@ def HandleToolOption(tools, env, project, reset): for item in paths: SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': item}) # change the inclue files (default) or definitions - if compile_include_files_option is not None: - option = compile_include_files_option + for option in compile_include_files_options: # add '_REENT_SMALL' to CPPDEFINES when --specs=nano.specs has select if linker_newlib_nano_option is not None and linker_newlib_nano_option.get('value') == 'true' and '_REENT_SMALL' not in CPPDEFINES: CPPDEFINES += ['_REENT_SMALL'] @@ -227,25 +241,25 @@ def HandleToolOption(tools, env, project, reset): break if find_ok is False: SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': rtt_pre_inc_item}) - elif compile_defs_option is not None : - option = compile_defs_option - defs = option.findall('listOptionValue') - project_defs = [] - for item in defs: - if reset is True: - # clean all old configuration - option.remove(item) + if len(compile_include_files_options) == 0: + for option in compile_defs_options: + defs = option.findall('listOptionValue') + project_defs = [] + for item in defs: + if reset is True: + # clean all old configuration + option.remove(item) + else: + project_defs += [item.get('value')] + if len(project_defs) > 0: + cproject_defs = set(CPPDEFINES) - set(project_defs) else: - project_defs += [item.get('value')] - if len(project_defs) > 0: - cproject_defs = set(CPPDEFINES) - set(project_defs) - else: - cproject_defs = CPPDEFINES + cproject_defs = CPPDEFINES - # print('c.compiler.defs') - cproject_defs = sorted(cproject_defs) - for item in cproject_defs: - SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': item}) + # print('c.compiler.defs') + cproject_defs = sorted(cproject_defs) + for item in cproject_defs: + SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': item}) # update linker script config if linker_scriptfile_option is not None : -- cgit v1.3.1 From 06579a46ed81ef5e6fbe6bf19bff3ff32c7f0bb0 Mon Sep 17 00:00:00 2001 From: armink Date: Mon, 17 Feb 2020 21:51:48 +0800 Subject: [tools] change the cpp eclipse project check function. --- tools/eclipse.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 916041019a..0f001b8bb8 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -20,6 +20,8 @@ from utils import xml_indent import xml.etree.ElementTree as etree from xml.etree.ElementTree import SubElement +from building import * + MODULE_VER_NUM = 0 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] @@ -139,11 +141,7 @@ def IsRttEclipsePathFormat(path): def IsCppProject(): - with open('.project', mode = 'r') as f: - for line in f.readlines(): - if line.find('org.eclipse.cdt.core.ccnature') != -1: - return True - return False + return GetDepend('RT_USING_CPLUSPLUS') def HandleToolOption(tools, env, project, reset): -- cgit v1.3.1 From 544a134f590ac251fef1842a9ea288c513f7c688 Mon Sep 17 00:00:00 2001 From: armink Date: Wed, 26 Feb 2020 14:48:23 +0800 Subject: [tools] Fix the lib paths not found issue. --- tools/eclipse.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 0f001b8bb8..743d471241 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 0 +MODULE_VER_NUM = 1 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] @@ -301,10 +301,12 @@ def HandleToolOption(tools, env, project, reset): option = linker_paths_option # remove old lib paths for item in option.findall('listOptionValue'): - option.remove(item) + if IsRttEclipsePathFormat(item.get('value')): + # clean old configuration + option.remove(item) # add new old lib paths for path in env['LIBPATH']: - SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': path}) + SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': ConverToRttEclipsePathFormat(RelativeProjectPath(env, path).replace('\\', '/'))}) return -- cgit v1.3.1 From c1b35a48a588032ebd4aa093a919294fe2741d42 Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Sun, 22 Mar 2020 09:12:58 +0800 Subject: 修复 scons --target=eclipse 时,部分带值宏出错的问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/eclipse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 743d471241..878cc1bba8 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -228,7 +228,7 @@ def HandleToolOption(tools, env, project, reset): with open('rtconfig_preinc.h', mode = 'w+') as f: f.write(file_header) for cppdef in CPPDEFINES: - f.write("#define " + cppdef + '\n') + f.write("#define " + cppdef.replace('=', ' ') + '\n') f.write(file_tail) # change the c.compiler.include.files files = option.findall('listOptionValue') -- cgit v1.3.1 From 32b4c0f2932d3e5932d5ab5f3f302cc4f8acddcd Mon Sep 17 00:00:00 2001 From: armink Date: Mon, 23 Mar 2020 08:50:08 +0800 Subject: [tools] update eclipse tools version number. --- tools/eclipse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 878cc1bba8..699ecef4d1 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 1 +MODULE_VER_NUM = 2 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] -- cgit v1.3.1 From 53977c1fb4f92b3c5e2420b674d7764eeda187fc Mon Sep 17 00:00:00 2001 From: thread-liu Date: Mon, 11 May 2020 14:10:48 +0800 Subject: [update] tools/eclipse.py --- tools/eclipse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 699ecef4d1..48b38c8f0a 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -109,12 +109,12 @@ def ExcludeFiles(infiles, files): def ExcludePaths(rootpath, paths): ret = [] - files = os.listdir(rootpath) + files = os.listdir(OSPath(rootpath)) for file in files: if file.startswith('.'): continue - fullname = os.path.join(rootpath, file) + fullname = os.path.join(OSPath(rootpath), file) if os.path.isdir(fullname): # print(fullname) -- cgit v1.3.1 From f8992996996b27834aafaf9b3deffb734d4edb49 Mon Sep 17 00:00:00 2001 From: thread-liu Date: Mon, 18 May 2020 17:41:16 +0800 Subject: [update] eclipse.py --- tools/eclipse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 48b38c8f0a..ef546fb15a 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 2 +MODULE_VER_NUM = 3 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] -- cgit v1.3.1 From abfbd9a79a693c574cae303c404d3fa223b51be8 Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Thu, 9 Jul 2020 16:05:09 +0800 Subject: fixbug:eclipse.py do not remove all unused path from list --- tools/eclipse.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index ef546fb15a..fb2e604bdc 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 3 +MODULE_VER_NUM = 4 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] @@ -348,12 +348,13 @@ def GenExcluding(env, project): rtt_root = os.path.abspath(env['RTT_ROOT']) bsp_root = os.path.abspath(env['BSP_ROOT']) coll_dirs = CollectPaths(project['DIRS']) - all_paths = [OSPath(path) for path in coll_dirs] + all_paths_temp = [OSPath(path) for path in coll_dirs] + all_paths = [] - # remove unused path - for path in all_paths: - if not path.startswith(rtt_root) and not path.startswith(bsp_root): - all_paths.remove(path) + # add used path + for path in all_paths_temp: + if path.startswith(rtt_root) or path.startswith(bsp_root): + all_paths.append(path) if bsp_root.startswith(rtt_root): # bsp folder is in the RT-Thread root folder, such as the RT-Thread source code on GitHub -- cgit v1.3.1 From aa411a25ad8a6108dce6477db2299b1ecdef1274 Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Fri, 24 Jul 2020 16:04:02 +0800 Subject: fixbug:keep user's lib configuration while running --target=eclipse --- tools/eclipse.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index fb2e604bdc..154bffb754 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 4 +MODULE_VER_NUM = 5 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] @@ -138,6 +138,20 @@ def IsRttEclipsePathFormat(path): return True else : 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(): @@ -189,7 +203,7 @@ def HandleToolOption(tools, env, project, reset): linker_script_option = option elif option.get('id').find('linker.nostart') != -1: 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 elif option.get('id').find('linker.paths') != -1 and env.has_key('LIBPATH'): linker_paths_option = option @@ -288,16 +302,22 @@ def HandleToolOption(tools, env, project, reset): else: option.set('value', 'false') # update libs - if linker_libs_option is not None : + if linker_libs_option is not None: option = linker_libs_option # remove old libs for item in option.findall('listOptionValue'): - option.remove(item) + if IsRttEclipseLibFormat(item.get("value")): + option.remove(item) + # add new libs - for lib in env['LIBS']: - SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': lib}) + if env.has_key('LIBS'): + for lib in env['LIBS']: + formatedLib = ConverToRttEclipseLibFormat(lib) + SubElement(option, 'listOptionValue', { + 'builtIn': 'false', 'value': formatedLib}) + # update lib paths - if linker_paths_option is not None : + if linker_paths_option is not None: option = linker_paths_option # remove old lib paths for item in option.findall('listOptionValue'): -- cgit v1.3.1