From 9b7971e801002a18e58db495ca0a4bf669c124ea Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Mon, 18 Jan 2021 16:00:57 +0800 Subject: add dist-ide support for all bsp --- tools/eclipse.py | 83 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 23 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 154bffb754..988a8fe7d3 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -9,23 +9,21 @@ # 2019-04-15 armink fix project update error # -import os -import sys import glob - -from utils import * -from utils import _make_path_relative -from utils import xml_indent - import xml.etree.ElementTree as etree from xml.etree.ElementTree import SubElement +import studio from building import * +from utils import * +from utils import _make_path_relative +from utils import xml_indent -MODULE_VER_NUM = 5 +MODULE_VER_NUM = 6 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] + def OSPath(path): import platform @@ -60,9 +58,12 @@ def CollectPaths(paths): all_paths = list(set(all_paths)) return sorted(all_paths) + ''' Collect all of files under paths ''' + + def CollectFiles(paths, pattern): files = [] for path in paths: @@ -75,6 +76,7 @@ def CollectFiles(paths, pattern): return sorted(files) + def CollectAllFilesinPath(path, pattern): files = [] @@ -93,11 +95,14 @@ def CollectAllFilesinPath(path, pattern): files = files + CollectAllFilesinPath(os.path.join(path, item), pattern) return files + ''' Exclude files from infiles ''' + + def ExcludeFiles(infiles, files): - in_files = set([OSPath(file) for file in infiles]) + in_files = set([OSPath(file) for file in infiles]) exl_files = set([OSPath(file) for file in files]) exl_files = in_files - exl_files @@ -136,9 +141,10 @@ def ConverToRttEclipsePathFormat(path): def IsRttEclipsePathFormat(path): if path.startswith(rtt_path_prefix): return True - else : + else: return False + # all libs added by scons should be ends with five whitespace as a flag rtt_lib_flag = 5 * " " @@ -152,12 +158,12 @@ def IsRttEclipseLibFormat(path): return True else: return False - - + + def IsCppProject(): return GetDepend('RT_USING_CPLUSPLUS') - + def HandleToolOption(tools, env, project, reset): is_cpp_prj = IsCppProject() BSP_ROOT = os.path.abspath(env['BSP_ROOT']) @@ -358,7 +364,7 @@ def UpdateProjectStructure(env, prj_name): out = open('.project', 'w') out.write('\n') xml_indent(root) - out.write(etree.tostring(root, encoding = 'utf-8')) + out.write(etree.tostring(root, encoding='utf-8')) out.close() return @@ -384,8 +390,8 @@ def GenExcluding(env, project): check_path = [] exclude_paths = [] # analyze the primary folder which relative to BSP_ROOT and in all_paths - for path in all_paths : - if path.startswith(bsp_root) : + for path in all_paths: + if path.startswith(bsp_root): folders = RelativeProjectPath(env, path).split('\\') if folders[0] != '.' and '\\' + folders[0] not in check_path: check_path += ['\\' + folders[0]] @@ -420,16 +426,16 @@ def GenExcluding(env, project): env['ExPaths'] = exclude_paths env['ExFiles'] = exclude_files - return exclude_paths + exclude_files + return exclude_paths + exclude_files def RelativeProjectPath(env, path): project_root = os.path.abspath(env['BSP_ROOT']) rtt_root = os.path.abspath(env['RTT_ROOT']) - + if path.startswith(project_root): return _make_path_relative(project_root, path) - + if path.startswith(rtt_root): return 'rt-thread/' + _make_path_relative(rtt_root, path) @@ -447,9 +453,9 @@ def HandleExcludingOption(entry, sourceEntries, excluding): value = '' for item in old_excluding: - if item.startswith('//') : + if item.startswith('//'): old_excluding.remove(item) - else : + else: if value == '': value = item else: @@ -498,13 +504,44 @@ def UpdateCproject(env, project, excluding, reset, prj_name): out.close() -def TargetEclipse(env, reset = False, prj_name = None): +def TargetEclipse(env, reset=False, prj_name=None): global source_pattern print('Update eclipse setting...') + # generate cproject file if not os.path.exists('.cproject'): - print('no eclipse CDT project found!') + if studio.gen_cproject_file(os.path.abspath(".cproject")) is False: + print('Fail!') + return + + # generate project file + if not os.path.exists('.project'): + if studio.gen_project_file(os.path.abspath(".project")) is False: + print('Fail!') + return + + # generate projcfg.ini file + if not os.path.exists('.settings/projcfg.ini'): + if os.path.exists("template.uvprojx"): + file = os.path.abspath("template.uvprojx") + else: + file = os.path.abspath("template.uvproj") + chip_name = studio.get_mcu_info(file) + if studio.gen_projcfg_ini_file(chip_name, prj_name, os.path.abspath(".settings/projcfg.ini")) is False: + print('Fail!') + return + + # enable lowwer .s file compiled in eclipse cdt + if not os.path.exists('.settings/org.eclipse.core.runtime.prefs'): + if studio.gen_org_eclipse_core_runtime_prefs( + os.path.abspath(".settings/org.eclipse.core.runtime.prefs")) is False: + print('Fail!') + return + + # add clean2 target to fix issues when files too many + if studio.gen_makefile_targets(os.path.abspath("makefile.targets")) is False: + print('Fail!') return project = ProjectInfo(env) -- cgit v1.3.1