Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76519099
rt-thread
提交
fd0ae672
R
rt-thread
项目概览
2301_76519099
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
3
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
fd0ae672
编写于
5月 30, 2018
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Tools] Add target=vsc in building script.
上级
fe691c2a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
186 addition
and
8 deletion
+186
-8
tools/building.py
tools/building.py
+21
-4
tools/mkdist.py
tools/mkdist.py
+3
-4
tools/utils.py
tools/utils.py
+116
-0
tools/vsc.py
tools/vsc.py
+46
-0
未找到文件。
tools/building.py
浏览文件 @
fd0ae672
...
...
@@ -123,6 +123,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
Env
=
env
Rtt_Root
=
os
.
path
.
abspath
(
root_directory
)
# set RTT_ROOT in ENV
Env
[
'RTT_ROOT'
]
=
Rtt_Root
# set BSP_ROOT in ENV
Env
[
'BSP_ROOT'
]
=
Dir
(
'#'
).
abspath
sys
.
path
=
sys
.
path
+
[
os
.
path
.
join
(
Rtt_Root
,
'tools'
)]
# add compability with Keil MDK 4.6 which changes the directory of armcc.exe
...
...
@@ -259,7 +264,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
AddOption
(
'--target'
,
dest
=
'target'
,
type
=
'string'
,
help
=
'set target project: mdk/mdk4/
iar/vs
/ua'
)
help
=
'set target project: mdk/mdk4/
mdk5/iar/vs/vsc
/ua'
)
#{target_name:(CROSS_TOOL, PLATFORM)}
tgt_dict
=
{
'mdk'
:(
'keil'
,
'armcc'
),
...
...
@@ -268,6 +273,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
'iar'
:(
'iar'
,
'iar'
),
'vs'
:(
'msvc'
,
'cl'
),
'vs2012'
:(
'msvc'
,
'cl'
),
'vsc'
:
(
'gcc'
,
'gcc'
),
'cb'
:(
'keil'
,
'armcc'
),
'ua'
:(
'gcc'
,
'gcc'
)}
tgt_name
=
GetOption
(
'target'
)
...
...
@@ -320,6 +326,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
mk_rtconfig
(
configfn
)
exit
(
0
)
AddOption
(
'--test'
,
dest
=
'test'
,
action
=
'store_true'
,
default
=
False
,
help
=
'some test feature'
)
# add comstr option
AddOption
(
'--verbose'
,
dest
=
'verbose'
,
...
...
@@ -531,7 +543,7 @@ def DefineGroup(name, src, depend, **parameters):
group
=
parameters
group
[
'name'
]
=
name
group
[
'path'
]
=
group_path
if
type
(
src
)
==
type
([
'src1'
]):
if
type
(
src
)
==
type
([]):
group
[
'src'
]
=
File
(
src
)
else
:
group
[
'src'
]
=
src
...
...
@@ -692,6 +704,9 @@ def DoBuilding(target, objects):
def
EndBuilding
(
target
,
program
=
None
):
import
rtconfig
Env
[
'target'
]
=
program
Env
[
'project'
]
=
Projects
Env
.
AddPostAction
(
target
,
rtconfig
.
POST_ACTION
)
# Add addition clean files
Clean
(
target
,
'cconfig.h'
)
...
...
@@ -745,6 +760,10 @@ def EndBuilding(target, program = None):
from
ua
import
PrepareUA
PrepareUA
(
Projects
,
Rtt_Root
,
str
(
Dir
(
'#'
)))
if
GetOption
(
'target'
)
==
'vsc'
:
from
vsc
import
GenerateVSCode
GenerateVSCode
(
Env
)
BSP_ROOT
=
Dir
(
'#'
).
abspath
if
GetOption
(
'copy'
)
and
program
!=
None
:
from
mkdist
import
MakeCopy
...
...
@@ -830,5 +849,3 @@ def PackageSConscript(package):
from
package
import
BuildPackage
return
BuildPackage
(
package
)
tools/mkdist.py
浏览文件 @
fd0ae672
...
...
@@ -66,14 +66,13 @@ def walk_kconfig(RTT_ROOT, source_list):
pathfile
=
os
.
path
.
join
(
parent
,
'KConfig'
)
source_list
.
append
(
pathfile
)
def
MakeCopy
(
program
,
BSP_ROOT
,
RTT_ROOT
,
Env
):
global
source_list
target_path
=
os
.
path
.
join
(
BSP_ROOT
,
'rt-thread'
)
if
target_path
.
startswith
(
RTT_ROOT
):
print
(
'please use scons --
dist to make a distribution
'
)
print
(
'please use scons --
copy to copy rt-thread to local bsp
'
)
return
for
item
in
program
:
...
...
@@ -140,7 +139,7 @@ def MakeCopyHeader(program, BSP_ROOT, RTT_ROOT, Env):
target_path
=
os
.
path
.
join
(
BSP_ROOT
,
'rt-thread'
)
if
target_path
.
startswith
(
RTT_ROOT
):
print
(
'please use scons --
dist to make a distribution
'
)
print
(
'please use scons --
copy-header to copy header files only
'
)
return
for
item
in
program
:
...
...
@@ -186,7 +185,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
# copy BSP files
do_copy_folder
(
os
.
path
.
join
(
BSP_ROOT
),
dist_dir
,
ignore_patterns
(
'build'
,
'dist'
,
'*.pyc'
,
'*.old'
,
'*.map'
,
'rtthread.bin'
,
'.sconsign.dblite'
,
'*.elf'
,
'*.axf'
))
ignore_patterns
(
'build'
,
'dist'
,
'*.pyc'
,
'*.old'
,
'*.map'
,
'rtthread.bin'
,
'.sconsign.dblite'
,
'*.elf'
,
'*.axf'
,
'cconfig.h'
))
global
source_list
...
...
tools/utils.py
浏览文件 @
fd0ae672
...
...
@@ -124,3 +124,119 @@ def walk_children(child):
if
children
!=
[]:
for
item
in
children
:
walk_children
(
item
)
def
PrefixPath
(
prefix
,
path
):
path
=
os
.
path
.
abspath
(
path
)
prefix
=
os
.
path
.
abspath
(
prefix
)
if
sys
.
platform
==
'win32'
:
prefix
=
prefix
.
lower
()
path
=
path
.
lower
()
if
path
.
startswith
(
prefix
):
return
True
return
False
def
ListMap
(
l
):
ret_list
=
[]
for
item
in
l
:
if
type
(
item
)
==
type
(()):
ret
=
ListMap
(
item
)
ret_list
+=
ret
elif
type
(
item
)
==
type
([]):
ret
=
ListMap
(
item
)
ret_list
+=
ret
else
:
ret_list
.
append
(
item
)
return
ret_list
def
TargetGetList
(
env
,
postfix
):
global
source_ext
global
source_list
target
=
env
[
'target'
]
source_ext
=
postfix
for
item
in
target
:
walk_children
(
item
)
source_list
.
sort
()
return
source_list
def
ProjectInfo
(
env
):
project
=
env
[
'project'
]
RTT_ROOT
=
env
[
'RTT_ROOT'
]
BSP_ROOT
=
env
[
'BSP_ROOT'
]
FILES
=
[]
DIRS
=
[]
HEADERS
=
[]
CPPPATH
=
[]
CPPDEFINES
=
[]
for
group
in
project
:
# get each files
if
group
.
has_key
(
'src'
)
and
group
[
'src'
]:
FILES
+=
group
[
'src'
]
# get each include path
if
group
.
has_key
(
'CPPPATH'
)
and
group
[
'CPPPATH'
]:
CPPPATH
+=
group
[
'CPPPATH'
]
if
env
.
has_key
(
'CPPDEFINES'
):
CPPDEFINES
=
env
[
'CPPDEFINES'
]
CPPDEFINES
=
ListMap
(
CPPDEFINES
)
# process FILES and DIRS
if
len
(
FILES
):
# use absolute path
for
i
in
range
(
len
(
FILES
)):
FILES
[
i
]
=
os
.
path
.
abspath
(
str
(
FILES
[
i
]))
DIRS
.
append
(
os
.
path
.
dirname
(
FILES
[
i
]))
FILES
.
sort
()
DIRS
=
list
(
set
(
DIRS
))
DIRS
.
sort
()
# process HEADERS
HEADERS
=
TargetGetList
(
env
,
[
'h'
])
# process CPPPATH
if
len
(
CPPPATH
):
# use absolute path
for
i
in
range
(
len
(
CPPPATH
)):
CPPPATH
[
i
]
=
os
.
path
.
abspath
(
CPPPATH
[
i
])
# remove repeat path
paths
=
[
i
for
i
in
set
(
CPPPATH
)]
CPPPATH
=
[]
for
path
in
paths
:
if
PrefixPath
(
RTT_ROOT
,
path
):
CPPPATH
+=
[
os
.
path
.
abspath
(
path
).
replace
(
'
\\
'
,
'/'
)]
elif
PrefixPath
(
BSP_ROOT
,
path
):
CPPPATH
+=
[
os
.
path
.
abspath
(
path
).
replace
(
'
\\
'
,
'/'
)]
else
:
CPPPATH
+=
[
'"%s",'
%
path
.
replace
(
'
\\
'
,
'/'
)]
CPPPATH
.
sort
()
# process CPPDEFINES
if
len
(
CPPDEFINES
):
CPPDEFINES
=
[
i
for
i
in
set
(
CPPDEFINES
)]
CPPDEFINES
.
sort
()
proj
=
{}
proj
[
'FILES'
]
=
FILES
proj
[
'DIRS'
]
=
DIRS
proj
[
'HEADERS'
]
=
HEADERS
proj
[
'CPPPATH'
]
=
CPPPATH
proj
[
'CPPDEFINES'
]
=
CPPDEFINES
return
proj
tools/vsc.py
0 → 100644
浏览文件 @
fd0ae672
"""
Utils for VSCode
"""
import
os
import
json
import
utils
import
rtconfig
def
GenerateCFiles
(
env
):
"""
Generate c_cpp_properties files
"""
if
not
os
.
path
.
exists
(
'.vscode'
):
os
.
mkdir
(
'.vscode'
)
vsc_file
=
file
(
'.vscode/c_cpp_properties.json'
,
'wb'
)
if
vsc_file
:
info
=
utils
.
ProjectInfo
(
env
)
cc
=
os
.
path
.
join
(
rtconfig
.
EXEC_PATH
,
rtconfig
.
CC
)
cc
=
os
.
path
.
abspath
(
cc
).
replace
(
'
\\
'
,
'/'
)
config_obj
=
{}
config_obj
[
'name'
]
=
'Win32'
config_obj
[
'includePath'
]
=
info
[
'CPPPATH'
]
config_obj
[
'defines'
]
=
info
[
'CPPDEFINES'
]
config_obj
[
'intelliSenseMode'
]
=
'clang-x64'
config_obj
[
'compilerPath'
]
=
cc
config_obj
[
'cStandard'
]
=
"c99"
config_obj
[
'cppStandard'
]
=
"c++11"
json_obj
=
{}
json_obj
[
'configurations'
]
=
[
config_obj
]
vsc_file
.
write
(
json
.
dumps
(
json_obj
))
vsc_file
.
close
()
return
def
GenerateVSCode
(
env
):
print
(
'Update setting files for VSCode...'
),
GenerateCFiles
(
env
)
print
(
'Done!'
)
return
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录