Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
okll00
rt-thread
提交
ab81ff68
R
rt-thread
项目概览
okll00
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ab81ff68
编写于
6月 18, 2019
作者:
armink_ztl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[tools] Add project name set feature to eclipse target.
上级
0c45bb6f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
52 deletion
+53
-52
tools/eclipse.py
tools/eclipse.py
+53
-52
未找到文件。
tools/eclipse.py
浏览文件 @
ab81ff68
...
...
@@ -102,15 +102,15 @@ def ExcludeFiles(infiles, files):
# caluclate the exclude path for project
def
ExcludePaths
(
file
path
,
paths
):
def
ExcludePaths
(
root
path
,
paths
):
ret
=
[]
files
=
os
.
listdir
(
file
path
)
files
=
os
.
listdir
(
root
path
)
for
file
in
files
:
if
file
.
startswith
(
'.'
):
continue
fullname
=
os
.
path
.
join
(
file
path
,
file
)
fullname
=
os
.
path
.
join
(
root
path
,
file
)
if
os
.
path
.
isdir
(
fullname
):
# print(fullname)
...
...
@@ -128,7 +128,7 @@ def ConverToEclipsePathFormat(path):
return
'"${workspace_loc:/${ProjName}/'
+
path
+
'}"'
def
HandleToolOption
(
tools
,
env
,
project
):
def
HandleToolOption
(
tools
,
env
,
project
,
reset
):
BSP_ROOT
=
os
.
path
.
abspath
(
env
[
'BSP_ROOT'
])
CPPDEFINES
=
project
[
'CPPDEFINES'
]
...
...
@@ -143,7 +143,11 @@ def HandleToolOption(tools, env, project):
include_paths
=
option
.
findall
(
'listOptionValue'
)
project_paths
=
[]
for
item
in
include_paths
:
project_paths
+=
[
item
.
get
(
'value'
)]
if
reset
is
True
:
# clean all old configuration
option
.
remove
(
item
)
else
:
project_paths
+=
[
item
.
get
(
'value'
)]
if
len
(
project_paths
)
>
0
:
cproject_paths
=
set
(
paths
)
-
set
(
project_paths
)
...
...
@@ -159,7 +163,11 @@ def HandleToolOption(tools, env, project):
defs
=
option
.
findall
(
'listOptionValue'
)
project_defs
=
[]
for
item
in
defs
:
project_defs
+=
[
item
.
get
(
'value'
)]
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
:
...
...
@@ -194,61 +202,54 @@ def HandleToolOption(tools, env, project):
return
def
UpdateProjectStructure
(
env
):
def
UpdateProjectStructure
(
env
,
prj_name
):
bsp_root
=
env
[
'BSP_ROOT'
]
rtt_root
=
env
[
'RTT_ROOT'
]
if
not
rtt_root
.
startswith
(
bsp_root
):
to_SubElement
=
True
# print('handle virtual root')
project
=
etree
.
parse
(
'.project'
)
root
=
project
.
getroot
()
# always use '/' path separator
rtt_root
=
rtt_root
.
replace
(
'
\\
'
,
'/'
)
if
rtt_root
.
startswith
(
bsp_root
):
linkedResources
=
root
.
find
(
'linkedResources'
)
if
linkedResources
==
None
:
linkedResources
=
SubElement
(
root
,
'linkedResources'
)
# TODO create the virtual folder
links
=
linkedResources
.
findall
(
'link'
)
# delete all RT-Thread folder links
for
link
in
links
:
if
link
.
find
(
'name'
).
text
.
startswith
(
'rt-thread'
):
linkedResources
.
remove
(
link
)
# project = etree.parse('.project')
# root = project.getroot()
#
# linkedResources = root.find('linkedResources')
# if linkedResources == None:
# # add linkedResources
# linkedResources = SubElement(root, 'linkedResources')
# # print('add linkedResources')
# else:
# links = linkedResources.findall('link')
# # search exist 'rt-thread' virtual folder
# for link in links:
# if link.find('name').text == 'rt-thread':
# # handle location
# to_SubElement = False
# location = link.find('location')
# location.text = rtt_root
#
# if to_SubElement:
# # print('to subelement for virtual folder')
# link = SubElement(linkedResources, 'link')
# name = SubElement(link, 'name')
# name.text = 'rt-thread'
# type = SubElement(link, 'type')
# type.text = '2'
# location = SubElement(link, 'location')
# location.text = rtt_root
#
# 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.close()
if
prj_name
:
name
=
root
.
find
(
'name'
)
if
name
==
None
:
name
=
SubElement
(
root
,
'name'
)
name
.
text
=
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
.
close
()
return
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
]
exclude_paths
=
ExcludePaths
(
rtt_root
,
all_paths
)
if
bsp_root
.
startswith
(
rtt_root
):
# bsp folder is in the RT-Thread root folder, such as the RT-Thread source code on GitHub
exclude_paths
=
ExcludePaths
(
rtt_root
,
all_paths
)
elif
rtt_root
.
startswith
(
bsp_root
):
# RT-Thread root folder is in the bsp folder, such as project folder which generate by 'scons --dist' cmd
exclude_paths
=
ExcludePaths
(
bsp_root
,
all_paths
)
else
:
exclude_paths
=
ExcludePaths
(
rtt_root
,
all_paths
)
exclude_paths
+=
ExcludePaths
(
bsp_root
,
all_paths
)
paths
=
exclude_paths
exclude_paths
=
[]
...
...
@@ -292,7 +293,7 @@ def RelativeProjectPath(env, path):
return
path
def
UpdateCproject
(
env
,
project
,
excluding
):
def
UpdateCproject
(
env
,
project
,
excluding
,
reset
):
excluding
=
sorted
(
excluding
)
cproject
=
etree
.
parse
(
'.cproject'
)
...
...
@@ -301,7 +302,7 @@ def UpdateCproject(env, project, excluding):
cconfigurations
=
root
.
findall
(
'storageModule/cconfiguration'
)
for
cconfiguration
in
cconfigurations
:
tools
=
cconfiguration
.
findall
(
'storageModule/configuration/folderInfo/toolChain/tool'
)
HandleToolOption
(
tools
,
env
,
project
)
HandleToolOption
(
tools
,
env
,
project
,
reset
)
sourceEntries
=
cconfiguration
.
find
(
'storageModule/configuration/sourceEntries'
)
entry
=
sourceEntries
.
find
(
'entry'
)
...
...
@@ -326,7 +327,7 @@ def UpdateCproject(env, project, excluding):
out
.
close
()
def
TargetEclipse
(
env
):
def
TargetEclipse
(
env
,
reset
=
False
,
prj_name
=
None
):
global
source_pattern
print
(
'Update eclipse setting...'
)
...
...
@@ -338,13 +339,13 @@ def TargetEclipse(env):
project
=
ProjectInfo
(
env
)
# update the project file structure info on '.project' file
UpdateProjectStructure
(
env
)
UpdateProjectStructure
(
env
,
prj_name
)
# generate the exclude paths and files
excluding
=
GenExcluding
(
env
,
project
)
# update the project configuration on '.cproject' file
UpdateCproject
(
env
,
project
,
excluding
)
UpdateCproject
(
env
,
project
,
excluding
,
reset
)
print
(
'done!'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录