Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
红岛
rt-thread
提交
3333462d
R
rt-thread
项目概览
红岛
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
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 = [
action
=
'store_true'
,
default
=
False
,
help
=
'reset the project configurations to default'
)
AddOption
(
'--mcu-type'
,
dest
=
'mcu-type'
,
type
=
'string'
,
default
=
False
,
help
=
'set mcu type name'
)
AddOption
(
'--cscope'
,
dest
=
'cscope'
,
action
=
'store_true'
,
...
...
@@ -852,7 +857,7 @@ def GenTargetProject(program = None):
if
GetOption
(
'target'
)
==
'eclipse'
:
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
):
...
...
tools/eclipse.py
浏览文件 @
3333462d
...
...
@@ -128,7 +128,7 @@ def ConverToEclipsePathFormat(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'
])
CPPDEFINES
=
project
[
'CPPDEFINES'
]
...
...
@@ -137,46 +137,86 @@ def HandleToolOption(tools, env, project, reset):
for
tool
in
tools
:
if
tool
.
get
(
'id'
).
find
(
'c.compile'
)
!=
1
:
options
=
tool
.
findall
(
'option'
)
include_paths_option
=
None
include_files_option
=
None
defs_option
=
None
# find all compile 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
:
# find all of paths in this project
include_paths
=
option
.
findall
(
'listOptionValue'
)
project_paths
=
[]
for
item
in
include_paths
:
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
)
include_paths_option
=
option
elif
option
.
get
(
'id'
).
find
(
'c.compiler.include.files'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.includefiles'
)
!=
-
1
:
include_files_option
=
option
elif
option
.
get
(
'id'
).
find
(
'c.compiler.defs'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.definedsymbols'
)
!=
-
1
:
defs_option
=
option
# change the inclue path
if
include_paths_option
is
not
None
:
option
=
include_paths_option
# find all of paths in this project
include_paths
=
option
.
findall
(
'listOptionValue'
)
project_paths
=
[]
for
item
in
include_paths
:
if
reset
is
True
:
# clean all old configuration
option
.
remove
(
item
)
else
:
cproject_paths
=
paths
# print('c.compiler.include.paths')
cproject_paths
=
sorted
(
cproject_paths
)
for
item
in
cproject_paths
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
if
option
.
get
(
'id'
).
find
(
'c.compiler.defs'
)
!=
-
1
or
option
.
get
(
'id'
).
find
(
'c.compiler.option.definedsymbols'
)
!=
-
1
:
defs
=
option
.
findall
(
'listOptionValue'
)
project_defs
=
[]
for
item
in
defs
:
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
)
project_paths
+=
[
item
.
get
(
'value'
)]
if
len
(
project_paths
)
>
0
:
cproject_paths
=
set
(
paths
)
-
set
(
project_paths
)
else
:
cproject_paths
=
paths
# print('c.compiler.include.paths')
cproject_paths
=
sorted
(
cproject_paths
)
for
item
in
cproject_paths
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
# change the inclue files (default) or definitions
if
include_files_option
is
not
None
:
option
=
include_paths_option
file_header
=
'''
#ifndef RTCONFIG_PREINC_H__
#define RTCONFIG_PREINC_H__
/* 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
:
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')
cproject_defs
=
sorted
(
cproject_defs
)
for
item
in
cproject_defs
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
# print('c.compiler.defs')
cproject_defs
=
sorted
(
cproject_defs
)
for
item
in
cproject_defs
:
SubElement
(
option
,
'listOptionValue'
,
{
'builtIn'
:
'false'
,
'value'
:
item
})
if
tool
.
get
(
'id'
).
find
(
'c.linker'
)
!=
-
1
:
options
=
tool
.
findall
(
'option'
)
...
...
@@ -262,7 +302,7 @@ def UpdateProjectStructure(env, prj_name):
return
def
GenExcluding
(
env
,
project
):
def
GenExcluding
(
env
,
project
,
mcu_type
):
rtt_root
=
os
.
path
.
abspath
(
env
[
'RTT_ROOT'
])
bsp_root
=
os
.
path
.
abspath
(
env
[
'BSP_ROOT'
])
coll_dirs
=
CollectPaths
(
project
[
'DIRS'
])
...
...
@@ -300,7 +340,12 @@ def GenExcluding(env, project):
exclude_files
=
ExcludeFiles
(
all_files
,
src_files
)
exclude_files
=
[
RelativeProjectPath
(
env
,
file
).
replace
(
'
\\
'
,
'/'
)
for
file
in
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
...
...
@@ -320,7 +365,7 @@ def RelativeProjectPath(env, path):
return
path
def
UpdateCproject
(
env
,
project
,
excluding
,
reset
):
def
UpdateCproject
(
env
,
project
,
excluding
,
reset
,
mcu_type
):
excluding
=
sorted
(
excluding
)
cproject
=
etree
.
parse
(
'.cproject'
)
...
...
@@ -329,7 +374,7 @@ def UpdateCproject(env, project, excluding, reset):
cconfigurations
=
root
.
findall
(
'storageModule/cconfiguration'
)
for
cconfiguration
in
cconfigurations
:
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'
)
entry
=
sourceEntries
.
find
(
'entry'
)
...
...
@@ -354,7 +399,7 @@ def UpdateCproject(env, project, excluding, reset):
out
.
close
()
def
TargetEclipse
(
env
,
reset
=
False
,
prj_name
=
None
):
def
TargetEclipse
(
env
,
reset
=
False
,
prj_name
=
None
,
mcu_type
=
None
):
global
source_pattern
print
(
'Update eclipse setting...'
)
...
...
@@ -369,10 +414,10 @@ def TargetEclipse(env, reset = False, prj_name = None):
UpdateProjectStructure
(
env
,
prj_name
)
# generate the exclude paths and files
excluding
=
GenExcluding
(
env
,
project
)
excluding
=
GenExcluding
(
env
,
project
,
mcu_type
)
# update the project configuration on '.cproject' file
UpdateCproject
(
env
,
project
,
excluding
,
reset
)
UpdateCproject
(
env
,
project
,
excluding
,
reset
,
mcu_type
)
print
(
'done!'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录