Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mozi
rt-thread
提交
3333462d
R
rt-thread
项目概览
Mozi
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3333462d
编写于
10月 24, 2019
作者:
armink_ztl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[tools] add include file for scons --target=eclipse
上级
2c610505
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
94 addition
and
44 deletion
+94
-44
tools/building.py
tools/building.py
+6
-1
tools/eclipse.py
tools/eclipse.py
+88
-43
未找到文件。
tools/building.py
浏览文件 @
3333462d
...
@@ -181,6 +181,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
...
@@ -181,6 +181,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
action
=
'store_true'
,
action
=
'store_true'
,
default
=
False
,
default
=
False
,
help
=
'reset the project configurations to default'
)
help
=
'reset the project configurations to default'
)
AddOption
(
'--mcu-type'
,
dest
=
'mcu-type'
,
type
=
'string'
,
default
=
False
,
help
=
'set mcu type name'
)
AddOption
(
'--cscope'
,
AddOption
(
'--cscope'
,
dest
=
'cscope'
,
dest
=
'cscope'
,
action
=
'store_true'
,
action
=
'store_true'
,
...
@@ -852,7 +857,7 @@ def GenTargetProject(program = None):
...
@@ -852,7 +857,7 @@ def GenTargetProject(program = None):
if
GetOption
(
'target'
)
==
'eclipse'
:
if
GetOption
(
'target'
)
==
'eclipse'
:
from
eclipse
import
TargetEclipse
from
eclipse
import
TargetEclipse
TargetEclipse
(
Env
,
GetOption
(
'reset-project-config'
),
GetOption
(
'project-name'
))
TargetEclipse
(
Env
,
GetOption
(
'reset-project-config'
),
GetOption
(
'project-name'
)
,
GetOption
(
'mcu-type'
)
)
def
EndBuilding
(
target
,
program
=
None
):
def
EndBuilding
(
target
,
program
=
None
):
...
...
tools/eclipse.py
浏览文件 @
3333462d
...
@@ -128,7 +128,7 @@ def ConverToEclipsePathFormat(path):
...
@@ -128,7 +128,7 @@ def ConverToEclipsePathFormat(path):
return
'"${workspace_loc:/${ProjName}/'
+
path
+
'}"'
return
'"${workspace_loc:/${ProjName}/'
+
path
+
'}"'
def
HandleToolOption
(
tools
,
env
,
project
,
reset
):
def
HandleToolOption
(
tools
,
env
,
project
,
reset
,
mcu_type
):
BSP_ROOT
=
os
.
path
.
abspath
(
env
[
'BSP_ROOT'
])
BSP_ROOT
=
os
.
path
.
abspath
(
env
[
'BSP_ROOT'
])
CPPDEFINES
=
project
[
'CPPDEFINES'
]
CPPDEFINES
=
project
[
'CPPDEFINES'
]
...
@@ -137,46 +137,86 @@ def HandleToolOption(tools, env, project, reset):
...
@@ -137,46 +137,86 @@ def HandleToolOption(tools, env, project, reset):
for
tool
in
tools
:
for
tool
in
tools
:
if
tool
.
get
(
'id'
).
find
(
'c.compile'
)
!=
1
:
if
tool
.
get
(
'id'
).
find
(
'c.compile'
)
!=
1
:
options
=
tool
.
findall
(
'option'
)
options
=
tool
.
findall
(
'option'
)
include_paths_option
=
None
include_files_option
=
None
defs_option
=
None
# find all compile options
for
option
in
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
:
if
option
.
get
(
'id'
).
find
(
'c.compiler.include.paths'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.includepaths'
)
!=
-
1
:
# find all of paths in this project
include_paths_option
=
option
include_paths
=
option
.
findall
(
'listOptionValue'
)
elif
option
.
get
(
'id'
).
find
(
'c.compiler.include.files'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.includefiles'
)
!=
-
1
:
project_paths
=
[]
include_files_option
=
option
for
item
in
include_paths
:
elif
option
.
get
(
'id'
).
find
(
'c.compiler.defs'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.definedsymbols'
)
!=
-
1
:
if
reset
is
True
:
defs_option
=
option
# clean all old configuration
# change the inclue path
option
.
remove
(
item
)
if
include_paths_option
is
not
None
:
else
:
option
=
include_paths_option
project_paths
+=
[
item
.
get
(
'value'
)]
# find all of paths in this project
include_paths
=
option
.
findall
(
'listOptionValue'
)
if
len
(
project_paths
)
>
0
:
project_paths
=
[]
cproject_paths
=
set
(
paths
)
-
set
(
project_paths
)
for
item
in
include_paths
:
if
reset
is
True
:
# clean all old configuration
option
.
remove
(
item
)
else
:
else
:
cproject_paths
=
paths
project_paths
+=
[
item
.
get
(
'value'
)]
# print('c.compiler.include.paths')
if
len
(
project_paths
)
>
0
:
cproject_paths
=
sorted
(
cproject_paths
)
cproject_paths
=
set
(
paths
)
-
set
(
project_paths
)
for
item
in
cproject_paths
:
else
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
cproject_paths
=
paths
if
option
.
get
(
'id'
).
find
(
'c.compiler.defs'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.definedsymbols'
)
!=
-
1
:
# print('c.compiler.include.paths')
defs
=
option
.
findall
(
'listOptionValue'
)
cproject_paths
=
sorted
(
cproject_paths
)
project_defs
=
[]
for
item
in
cproject_paths
:
for
item
in
defs
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
if
reset
is
True
:
# change the inclue files (default) or definitions
# clean all old configuration
if
include_files_option
is
not
None
:
option
.
remove
(
item
)
option
=
include_paths_option
else
:
file_header
=
'''
project_defs
+=
[
item
.
get
(
'value'
)]
#ifndef RTCONFIG_PREINC_H__
if
len
(
project_defs
)
>
0
:
#define RTCONFIG_PREINC_H__
cproject_defs
=
set
(
CPPDEFINES
)
-
set
(
project_defs
)
/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread Configuration */
'''
file_tail
=
'
\n
#endif /*RTCONFIG_PREINC_H__*/
\n
'
rtt_pre_inc_item
=
'"${workspace_loc:/${ProjName}/rtconfig_preinc.h}"'
# save the CPPDEFINES in to rtconfig_preinc.h
with
open
(
'rtconfig_preinc.h'
,
mode
=
'w+'
)
as
f
:
f
.
write
(
file_header
)
for
cppdef
in
CPPDEFINES
:
f
.
write
(
"#define "
+
cppdef
+
'
\n
'
)
f
.
write
(
file_tail
)
# change the c.compiler.include.files
files
=
option
.
findall
(
'listOptionValue'
)
find_ok
=
False
for
item
in
files
:
if
item
.
get
(
'value'
)
==
rtt_pre_inc_item
:
find_ok
=
True
break
if
find_ok
is
False
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
rtt_pre_inc_item
})
elif
defs_option
is
not
None
:
option
=
defs_option
defs
=
option
.
findall
(
'listOptionValue'
)
project_defs
=
[]
for
item
in
defs
:
if
reset
is
True
:
# clean all old configuration
option
.
remove
(
item
)
else
:
else
:
cproject_defs
=
CPPDEFINES
project_defs
+=
[
item
.
get
(
'value'
)]
if
len
(
project_defs
)
>
0
:
cproject_defs
=
set
(
CPPDEFINES
)
-
set
(
project_defs
)
else
:
cproject_defs
=
CPPDEFINES
# print('c.compiler.defs')
# print('c.compiler.defs')
cproject_defs
=
sorted
(
cproject_defs
)
cproject_defs
=
sorted
(
cproject_defs
)
for
item
in
cproject_defs
:
for
item
in
cproject_defs
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
if
tool
.
get
(
'id'
).
find
(
'c.linker'
)
!=
-
1
:
if
tool
.
get
(
'id'
).
find
(
'c.linker'
)
!=
-
1
:
options
=
tool
.
findall
(
'option'
)
options
=
tool
.
findall
(
'option'
)
...
@@ -262,7 +302,7 @@ def UpdateProjectStructure(env, prj_name):
...
@@ -262,7 +302,7 @@ def UpdateProjectStructure(env, prj_name):
return
return
def
GenExcluding
(
env
,
project
):
def
GenExcluding
(
env
,
project
,
mcu_type
):
rtt_root
=
os
.
path
.
abspath
(
env
[
'RTT_ROOT'
])
rtt_root
=
os
.
path
.
abspath
(
env
[
'RTT_ROOT'
])
bsp_root
=
os
.
path
.
abspath
(
env
[
'BSP_ROOT'
])
bsp_root
=
os
.
path
.
abspath
(
env
[
'BSP_ROOT'
])
coll_dirs
=
CollectPaths
(
project
[
'DIRS'
])
coll_dirs
=
CollectPaths
(
project
[
'DIRS'
])
...
@@ -300,7 +340,12 @@ def GenExcluding(env, project):
...
@@ -300,7 +340,12 @@ def GenExcluding(env, project):
exclude_files
=
ExcludeFiles
(
all_files
,
src_files
)
exclude_files
=
ExcludeFiles
(
all_files
,
src_files
)
exclude_files
=
[
RelativeProjectPath
(
env
,
file
).
replace
(
'
\\
'
,
'/'
)
for
file
in
exclude_files
]
exclude_files
=
[
RelativeProjectPath
(
env
,
file
).
replace
(
'
\\
'
,
'/'
)
for
file
in
exclude_files
]
env
[
'ExFiles'
]
=
exclude_files
env
[
'ExFiles'
]
=
exclude_files
if
mcu_type
:
# TODO save the rt-thread and packages exclude folder only
# TODO exclude the libraries/STM32L4xx_HAL/CMSIS/Device/ST/STM32L4xx/Source/Templates/ arm|iar|gcc/xxx.s
pass
return
exclude_paths
+
exclude_files
return
exclude_paths
+
exclude_files
...
@@ -320,7 +365,7 @@ def RelativeProjectPath(env, path):
...
@@ -320,7 +365,7 @@ def RelativeProjectPath(env, path):
return
path
return
path
def
UpdateCproject
(
env
,
project
,
excluding
,
reset
):
def
UpdateCproject
(
env
,
project
,
excluding
,
reset
,
mcu_type
):
excluding
=
sorted
(
excluding
)
excluding
=
sorted
(
excluding
)
cproject
=
etree
.
parse
(
'.cproject'
)
cproject
=
etree
.
parse
(
'.cproject'
)
...
@@ -329,7 +374,7 @@ def UpdateCproject(env, project, excluding, reset):
...
@@ -329,7 +374,7 @@ def UpdateCproject(env, project, excluding, reset):
cconfigurations
=
root
.
findall
(
'storageModule/cconfiguration'
)
cconfigurations
=
root
.
findall
(
'storageModule/cconfiguration'
)
for
cconfiguration
in
cconfigurations
:
for
cconfiguration
in
cconfigurations
:
tools
=
cconfiguration
.
findall
(
'storageModule/configuration/folderInfo/toolChain/tool'
)
tools
=
cconfiguration
.
findall
(
'storageModule/configuration/folderInfo/toolChain/tool'
)
HandleToolOption
(
tools
,
env
,
project
,
reset
)
HandleToolOption
(
tools
,
env
,
project
,
reset
,
mcu_type
)
sourceEntries
=
cconfiguration
.
find
(
'storageModule/configuration/sourceEntries'
)
sourceEntries
=
cconfiguration
.
find
(
'storageModule/configuration/sourceEntries'
)
entry
=
sourceEntries
.
find
(
'entry'
)
entry
=
sourceEntries
.
find
(
'entry'
)
...
@@ -354,7 +399,7 @@ def UpdateCproject(env, project, excluding, reset):
...
@@ -354,7 +399,7 @@ def UpdateCproject(env, project, excluding, reset):
out
.
close
()
out
.
close
()
def
TargetEclipse
(
env
,
reset
=
False
,
prj_name
=
None
):
def
TargetEclipse
(
env
,
reset
=
False
,
prj_name
=
None
,
mcu_type
=
None
):
global
source_pattern
global
source_pattern
print
(
'Update eclipse setting...'
)
print
(
'Update eclipse setting...'
)
...
@@ -369,10 +414,10 @@ def TargetEclipse(env, reset = False, prj_name = None):
...
@@ -369,10 +414,10 @@ def TargetEclipse(env, reset = False, prj_name = None):
UpdateProjectStructure
(
env
,
prj_name
)
UpdateProjectStructure
(
env
,
prj_name
)
# generate the exclude paths and files
# generate the exclude paths and files
excluding
=
GenExcluding
(
env
,
project
)
excluding
=
GenExcluding
(
env
,
project
,
mcu_type
)
# update the project configuration on '.cproject' file
# update the project configuration on '.cproject' file
UpdateCproject
(
env
,
project
,
excluding
,
reset
)
UpdateCproject
(
env
,
project
,
excluding
,
reset
,
mcu_type
)
print
(
'done!'
)
print
(
'done!'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录