summaryrefslogtreecommitdiff
path: root/tools/eclipse.py
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-01-30 12:33:19 +0800
committerGitHub <[email protected]>2021-01-30 12:33:19 +0800
commit97cc8a8f72838deb0273a3e60ae29319edd7e4f7 (patch)
tree240ca2dbffead9d828c59719b447844ab63c5e52 /tools/eclipse.py
parent7405618eafd9d0acd1d6da7ccd014700e9c17768 (diff)
parent45963a16b07857fadec81ff1d7cf6d16deeaddb5 (diff)
Merge pull request #14 from RT-Thread/master
pr
Diffstat (limited to 'tools/eclipse.py')
-rw-r--r--tools/eclipse.py90
1 files changed, 66 insertions, 24 deletions
diff --git a/tools/eclipse.py b/tools/eclipse.py
index 154bffb754..4f3cda92b8 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 rt_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('<?xml version="1.0" encoding="UTF-8"?>\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,14 +504,50 @@ 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!')
- return
+ 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 rt_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 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
+ 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 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 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)