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 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 ++++++++++---- tools/studio.py | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 399 insertions(+), 23 deletions(-) create mode 100644 tools/studio.py (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) diff --git a/tools/studio.py b/tools/studio.py new file mode 100644 index 0000000000..0a23d6488b --- /dev/null +++ b/tools/studio.py @@ -0,0 +1,339 @@ +import os +import re +from string import Template + +import rtconfig + +cproject_temp = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""" + +project_temp = """ + + __project_name_flag__ + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.rt-thread.studio.rttnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + +""" + +projcfg_ini_temp = """#RT-Thread Studio Project Configuration +#Sat Jan 16 15:18:32 CST 2021 +project_type=rtt +chip_name=${chip_name} +cpu_name=None +target_freq= +clock_source= +dvendor_name= +rx_pin_name= +rtt_path= +source_freq= +csp_path= +sub_series_name= +selected_rtt_version=latest +cfg_version=v3.0 +tool_chain=gcc +uart_name= +tx_pin_name= +rtt_nano_path= +output_project_path= +hardware_adapter=J-Link +project_name=${project_name}""" + +eclipse_core_runtime_temp = """content-types/enabled=true +content-types/org.eclipse.cdt.core.asmSource/file-extensions=s +eclipse.preferences.version=1""" + +makefile_targets_temp = """clean2: +\t-$(RM) $(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS) +\t-$(RM) $(OBJS) *.elf +\t-@echo ' ' + +*.elf: $(wildcard ../linkscripts/*/*.lds) $(wildcard ../linkscripts/*/*/*.lds)""" + + +def get_mcu_info(uvproj_file_path): + if os.path.exists(uvproj_file_path): + with open(uvproj_file_path, mode='r') as f: + data = f.read() + result = re.search("(.*)", data) + if result: + return result.group(1) + else: + return "" + else: + return "" + + +def gen_makefile_targets(output_file_path): + try: + w_str = makefile_targets_temp + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + print(e) + return False + + +def gen_org_eclipse_core_runtime_prefs(output_file_path): + try: + w_str = eclipse_core_runtime_temp + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + print(e) + return False + + +def gen_cproject_file(output_file_path): + CFLAGS = rtconfig.CFLAGS + AFLAGS = rtconfig.AFLAGS + LFLAGS = rtconfig.LFLAGS + if 'CXXFLAGS' in dir(rtconfig): + CXXFLAGS = rtconfig.CXXFLAGS + else: + CXXFLAGS = "" + + if "-T" in LFLAGS: + items = str(LFLAGS).split() + t_index = items.index("-T") + items[t_index] = "" + items[t_index + 1] = "" + LFLAGS = " ".join(items) + + try: + w_str = cproject_temp + if "a_misc_flag" in w_str: + w_str = w_str.replace("a_misc_flag", AFLAGS) + if "c_misc_flag" in w_str: + w_str = w_str.replace("c_misc_flag", CFLAGS) + if "cpp_misc_flag" in w_str: + w_str = w_str.replace("cpp_misc_flag", CXXFLAGS) + if "c_link_misc_flag" in w_str: + w_str = w_str.replace("c_link_misc_flag", LFLAGS) + if "cpp_link_misc_flag" in w_str: + w_str = w_str.replace("cpp_link_misc_flag", LFLAGS) + + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + return False + + +def gen_project_file(output_file_path): + try: + w_str = project_temp + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + return False + + +def gen_projcfg_ini_file(chip_name, project_name, output_file_path): + try: + projcfg_file_tmp = Template(projcfg_ini_temp) + w_str = projcfg_file_tmp.substitute(project_name=project_name, + chip_name=(chip_name)) + + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + return False -- cgit v1.3.1 From c32a2b3c63645006eb0c40b263f8a9a97aa76983 Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Mon, 18 Jan 2021 16:31:39 +0800 Subject: rename studio.py to rt_studio.py --- tools/eclipse.py | 14 +-- tools/rt_studio.py | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/studio.py | 339 ----------------------------------------------------- 3 files changed, 346 insertions(+), 346 deletions(-) create mode 100644 tools/rt_studio.py delete mode 100644 tools/studio.py (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index 988a8fe7d3..b9d34782a1 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -13,7 +13,7 @@ import glob import xml.etree.ElementTree as etree from xml.etree.ElementTree import SubElement -import studio +import rt_studio from building import * from utils import * from utils import _make_path_relative @@ -511,13 +511,13 @@ def TargetEclipse(env, reset=False, prj_name=None): # generate cproject file if not os.path.exists('.cproject'): - if studio.gen_cproject_file(os.path.abspath(".cproject")) is False: + if rt_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: + if rt_studio.gen_project_file(os.path.abspath(".project")) is False: print('Fail!') return @@ -527,20 +527,20 @@ def TargetEclipse(env, reset=False, prj_name=None): 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: + chip_name = rt_studio.get_mcu_info(file) + if rt_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( + if rt_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: + if rt_studio.gen_makefile_targets(os.path.abspath("makefile.targets")) is False: print('Fail!') return diff --git a/tools/rt_studio.py b/tools/rt_studio.py new file mode 100644 index 0000000000..0a23d6488b --- /dev/null +++ b/tools/rt_studio.py @@ -0,0 +1,339 @@ +import os +import re +from string import Template + +import rtconfig + +cproject_temp = """ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""" + +project_temp = """ + + __project_name_flag__ + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.rt-thread.studio.rttnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + +""" + +projcfg_ini_temp = """#RT-Thread Studio Project Configuration +#Sat Jan 16 15:18:32 CST 2021 +project_type=rtt +chip_name=${chip_name} +cpu_name=None +target_freq= +clock_source= +dvendor_name= +rx_pin_name= +rtt_path= +source_freq= +csp_path= +sub_series_name= +selected_rtt_version=latest +cfg_version=v3.0 +tool_chain=gcc +uart_name= +tx_pin_name= +rtt_nano_path= +output_project_path= +hardware_adapter=J-Link +project_name=${project_name}""" + +eclipse_core_runtime_temp = """content-types/enabled=true +content-types/org.eclipse.cdt.core.asmSource/file-extensions=s +eclipse.preferences.version=1""" + +makefile_targets_temp = """clean2: +\t-$(RM) $(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS) +\t-$(RM) $(OBJS) *.elf +\t-@echo ' ' + +*.elf: $(wildcard ../linkscripts/*/*.lds) $(wildcard ../linkscripts/*/*/*.lds)""" + + +def get_mcu_info(uvproj_file_path): + if os.path.exists(uvproj_file_path): + with open(uvproj_file_path, mode='r') as f: + data = f.read() + result = re.search("(.*)", data) + if result: + return result.group(1) + else: + return "" + else: + return "" + + +def gen_makefile_targets(output_file_path): + try: + w_str = makefile_targets_temp + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + print(e) + return False + + +def gen_org_eclipse_core_runtime_prefs(output_file_path): + try: + w_str = eclipse_core_runtime_temp + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + print(e) + return False + + +def gen_cproject_file(output_file_path): + CFLAGS = rtconfig.CFLAGS + AFLAGS = rtconfig.AFLAGS + LFLAGS = rtconfig.LFLAGS + if 'CXXFLAGS' in dir(rtconfig): + CXXFLAGS = rtconfig.CXXFLAGS + else: + CXXFLAGS = "" + + if "-T" in LFLAGS: + items = str(LFLAGS).split() + t_index = items.index("-T") + items[t_index] = "" + items[t_index + 1] = "" + LFLAGS = " ".join(items) + + try: + w_str = cproject_temp + if "a_misc_flag" in w_str: + w_str = w_str.replace("a_misc_flag", AFLAGS) + if "c_misc_flag" in w_str: + w_str = w_str.replace("c_misc_flag", CFLAGS) + if "cpp_misc_flag" in w_str: + w_str = w_str.replace("cpp_misc_flag", CXXFLAGS) + if "c_link_misc_flag" in w_str: + w_str = w_str.replace("c_link_misc_flag", LFLAGS) + if "cpp_link_misc_flag" in w_str: + w_str = w_str.replace("cpp_link_misc_flag", LFLAGS) + + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + return False + + +def gen_project_file(output_file_path): + try: + w_str = project_temp + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + return False + + +def gen_projcfg_ini_file(chip_name, project_name, output_file_path): + try: + projcfg_file_tmp = Template(projcfg_ini_temp) + w_str = projcfg_file_tmp.substitute(project_name=project_name, + chip_name=(chip_name)) + + dir_name = os.path.dirname(output_file_path) + if not os.path.exists(dir_name): + os.makedirs(dir_name) + with open(output_file_path, 'w') as f: + f.write(w_str) + return True + except Exception as e: + return False diff --git a/tools/studio.py b/tools/studio.py deleted file mode 100644 index 0a23d6488b..0000000000 --- a/tools/studio.py +++ /dev/null @@ -1,339 +0,0 @@ -import os -import re -from string import Template - -import rtconfig - -cproject_temp = """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -""" - -project_temp = """ - - __project_name_flag__ - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.rt-thread.studio.rttnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - -""" - -projcfg_ini_temp = """#RT-Thread Studio Project Configuration -#Sat Jan 16 15:18:32 CST 2021 -project_type=rtt -chip_name=${chip_name} -cpu_name=None -target_freq= -clock_source= -dvendor_name= -rx_pin_name= -rtt_path= -source_freq= -csp_path= -sub_series_name= -selected_rtt_version=latest -cfg_version=v3.0 -tool_chain=gcc -uart_name= -tx_pin_name= -rtt_nano_path= -output_project_path= -hardware_adapter=J-Link -project_name=${project_name}""" - -eclipse_core_runtime_temp = """content-types/enabled=true -content-types/org.eclipse.cdt.core.asmSource/file-extensions=s -eclipse.preferences.version=1""" - -makefile_targets_temp = """clean2: -\t-$(RM) $(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(SECONDARY_FLASH)$(SECONDARY_SIZE)$(ASM_DEPS)$(S_UPPER_DEPS)$(C_DEPS)$(CPP_DEPS) -\t-$(RM) $(OBJS) *.elf -\t-@echo ' ' - -*.elf: $(wildcard ../linkscripts/*/*.lds) $(wildcard ../linkscripts/*/*/*.lds)""" - - -def get_mcu_info(uvproj_file_path): - if os.path.exists(uvproj_file_path): - with open(uvproj_file_path, mode='r') as f: - data = f.read() - result = re.search("(.*)", data) - if result: - return result.group(1) - else: - return "" - else: - return "" - - -def gen_makefile_targets(output_file_path): - try: - w_str = makefile_targets_temp - dir_name = os.path.dirname(output_file_path) - if not os.path.exists(dir_name): - os.makedirs(dir_name) - with open(output_file_path, 'w') as f: - f.write(w_str) - return True - except Exception as e: - print(e) - return False - - -def gen_org_eclipse_core_runtime_prefs(output_file_path): - try: - w_str = eclipse_core_runtime_temp - dir_name = os.path.dirname(output_file_path) - if not os.path.exists(dir_name): - os.makedirs(dir_name) - with open(output_file_path, 'w') as f: - f.write(w_str) - return True - except Exception as e: - print(e) - return False - - -def gen_cproject_file(output_file_path): - CFLAGS = rtconfig.CFLAGS - AFLAGS = rtconfig.AFLAGS - LFLAGS = rtconfig.LFLAGS - if 'CXXFLAGS' in dir(rtconfig): - CXXFLAGS = rtconfig.CXXFLAGS - else: - CXXFLAGS = "" - - if "-T" in LFLAGS: - items = str(LFLAGS).split() - t_index = items.index("-T") - items[t_index] = "" - items[t_index + 1] = "" - LFLAGS = " ".join(items) - - try: - w_str = cproject_temp - if "a_misc_flag" in w_str: - w_str = w_str.replace("a_misc_flag", AFLAGS) - if "c_misc_flag" in w_str: - w_str = w_str.replace("c_misc_flag", CFLAGS) - if "cpp_misc_flag" in w_str: - w_str = w_str.replace("cpp_misc_flag", CXXFLAGS) - if "c_link_misc_flag" in w_str: - w_str = w_str.replace("c_link_misc_flag", LFLAGS) - if "cpp_link_misc_flag" in w_str: - w_str = w_str.replace("cpp_link_misc_flag", LFLAGS) - - dir_name = os.path.dirname(output_file_path) - if not os.path.exists(dir_name): - os.makedirs(dir_name) - with open(output_file_path, 'w') as f: - f.write(w_str) - return True - except Exception as e: - return False - - -def gen_project_file(output_file_path): - try: - w_str = project_temp - dir_name = os.path.dirname(output_file_path) - if not os.path.exists(dir_name): - os.makedirs(dir_name) - with open(output_file_path, 'w') as f: - f.write(w_str) - return True - except Exception as e: - return False - - -def gen_projcfg_ini_file(chip_name, project_name, output_file_path): - try: - projcfg_file_tmp = Template(projcfg_ini_temp) - w_str = projcfg_file_tmp.substitute(project_name=project_name, - chip_name=(chip_name)) - - dir_name = os.path.dirname(output_file_path) - if not os.path.exists(dir_name): - os.makedirs(dir_name) - with open(output_file_path, 'w') as f: - f.write(w_str) - return True - except Exception as e: - return False -- cgit v1.3.1 From a77e99f7c226f0ad8bfc057fbcbe838b069e56e3 Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Mon, 25 Jan 2021 11:33:00 +0800 Subject: fixbug:keep makefile.targets while it has existed --- tools/eclipse.py | 18 ++++++++++++------ tools/rt_studio.py | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index b9d34782a1..0d8d465cbc 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -523,10 +523,15 @@ def TargetEclipse(env, reset=False, prj_name=None): # generate projcfg.ini file if not os.path.exists('.settings/projcfg.ini'): - if os.path.exists("template.uvprojx"): - file = os.path.abspath("template.uvprojx") + # if search files with uvprojx or uvproj suffix + items = os.listdir(".") + if len(items) > 0: + for item in items: + if item.endswith(".uvprojx") or item.endswith(".uvproj"): + file = item + break else: - file = os.path.abspath("template.uvproj") + file = "" chip_name = rt_studio.get_mcu_info(file) if rt_studio.gen_projcfg_ini_file(chip_name, prj_name, os.path.abspath(".settings/projcfg.ini")) is False: print('Fail!') @@ -540,9 +545,10 @@ def TargetEclipse(env, reset=False, prj_name=None): return # add clean2 target to fix issues when files too many - if rt_studio.gen_makefile_targets(os.path.abspath("makefile.targets")) is False: - print('Fail!') - return + if not os.path.exists('makefile.targets'): + if rt_studio.gen_makefile_targets(os.path.abspath("makefile.targets")) is False: + print('Fail!') + return project = ProjectInfo(env) diff --git a/tools/rt_studio.py b/tools/rt_studio.py index 0a23d6488b..8b34479509 100644 --- a/tools/rt_studio.py +++ b/tools/rt_studio.py @@ -238,9 +238,9 @@ def get_mcu_info(uvproj_file_path): if result: return result.group(1) else: - return "" + return "unknown" else: - return "" + return "unknown" def gen_makefile_targets(output_file_path): -- cgit v1.3.1 From c38e2bc6ec85310ec4ba63c0d637f9ada474824c Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Mon, 25 Jan 2021 11:42:10 +0800 Subject: update uvprojx file path to abspath --- 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 0d8d465cbc..c1cd3c6623 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -528,7 +528,7 @@ def TargetEclipse(env, reset=False, prj_name=None): if len(items) > 0: for item in items: if item.endswith(".uvprojx") or item.endswith(".uvproj"): - file = item + file = os.path.abspath(item) break else: file = "" -- cgit v1.3.1 From 9dbbae70e93ee291b9e922440d553af66724e99b Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Wed, 27 Jan 2021 15:54:37 +0800 Subject: add rt_studio.py version infomation --- tools/eclipse.py | 3 +-- tools/rt_studio.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'tools/eclipse.py') diff --git a/tools/eclipse.py b/tools/eclipse.py index c1cd3c6623..4f3cda92b8 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -524,14 +524,13 @@ def TargetEclipse(env, reset=False, prj_name=None): # generate projcfg.ini file if not os.path.exists('.settings/projcfg.ini'): # if search files with uvprojx or uvproj suffix + file = "" items = os.listdir(".") if len(items) > 0: for item in items: if item.endswith(".uvprojx") or item.endswith(".uvproj"): file = os.path.abspath(item) break - else: - file = "" chip_name = rt_studio.get_mcu_info(file) if rt_studio.gen_projcfg_ini_file(chip_name, prj_name, os.path.abspath(".settings/projcfg.ini")) is False: print('Fail!') diff --git a/tools/rt_studio.py b/tools/rt_studio.py index c60d9fc1c9..99eca3f69b 100644 --- a/tools/rt_studio.py +++ b/tools/rt_studio.py @@ -5,6 +5,9 @@ from string import Template import rtconfig import shutil +# version +MODULE_VER_NUM = 6 + cproject_temp = """ -- cgit v1.3.1