Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
acfb1c16
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
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看板
未验证
提交
acfb1c16
编写于
7月 24, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
7月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1634 from liangyongxiang/dist
[tools] rewrite "scons --dist/copy/copy-header"
上级
1b75a272
67b31178
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
201 deletion
+81
-201
tools/mkdist.py
tools/mkdist.py
+81
-201
未找到文件。
tools/mkdist.py
浏览文件 @
acfb1c16
...
...
@@ -89,116 +89,65 @@ 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 --copy to copy rt-thread to local bsp'
)
return
for
item
in
program
:
walk_children
(
item
)
source_list
.
sort
()
# fill source file in RT-Thread
target_list
=
[]
for
src
in
source_list
:
if
Env
[
'PLATFORM'
]
==
'win32'
:
src
=
src
.
lower
()
if
src
.
startswith
(
RTT_ROOT
):
target_list
.
append
(
src
)
source_list
=
target_list
# get source directory
src_dir
=
[]
for
src
in
source_list
:
src
=
src
.
replace
(
RTT_ROOT
,
''
)
if
src
[
0
]
==
os
.
sep
or
src
[
0
]
==
'/'
:
src
=
src
[
1
:]
path
=
os
.
path
.
dirname
(
src
)
sub_path
=
path
.
split
(
os
.
sep
)
full_path
=
RTT_ROOT
for
item
in
sub_path
:
full_path
=
os
.
path
.
join
(
full_path
,
item
)
if
full_path
not
in
src_dir
:
src_dir
.
append
(
full_path
)
for
item
in
src_dir
:
source_list
.
append
(
os
.
path
.
join
(
item
,
'SConscript'
))
walk_kconfig
(
RTT_ROOT
,
source_list
)
for
src
in
source_list
:
dst
=
src
.
replace
(
RTT_ROOT
,
''
)
if
dst
[
0
]
==
os
.
sep
or
dst
[
0
]
==
'/'
:
dst
=
dst
[
1
:]
print
'=> '
,
dst
dst
=
os
.
path
.
join
(
target_path
,
dst
)
do_copy_file
(
src
,
dst
)
# copy tools directory
print
(
"=> tools"
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"tools"
),
os
.
path
.
join
(
target_path
,
"tools"
),
ignore_patterns
(
'*.pyc'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'Kconfig'
),
os
.
path
.
join
(
target_path
,
'Kconfig'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'AUTHORS'
),
os
.
path
.
join
(
target_path
,
'AUTHORS'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'COPYING'
),
os
.
path
.
join
(
target_path
,
'COPYING'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'README.md'
),
os
.
path
.
join
(
target_path
,
'README.md'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'README_zh.md'
),
os
.
path
.
join
(
target_path
,
'README_zh.md'
))
print
(
'=> libc'
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"components"
,
'libc'
,
'compilers'
),
os
.
path
.
join
(
target_path
,
"components"
,
'libc'
,
'compilers'
))
print
(
'done!'
)
def
MakeCopyHeader
(
program
,
BSP_ROOT
,
RTT_ROOT
,
Env
):
global
source_list
global
source_ext
source_ext
=
[]
source_ext
=
[
"h"
,
"xpm"
]
target_path
=
os
.
path
.
join
(
BSP_ROOT
,
'rt-thread'
)
if
target_path
.
startswith
(
RTT_ROOT
):
print
(
'please use scons --copy-header to copy header files only'
)
return
for
item
in
program
:
walk_children
(
item
)
source_list
.
sort
()
# fill source file in RT-Thread
target_list
=
[]
for
src
in
source_list
:
if
Env
[
'PLATFORM'
]
==
'win32'
:
src
=
src
.
lower
()
if
src
.
startswith
(
RTT_ROOT
):
target_list
.
append
(
src
)
def
bsp_update_sconstruct
(
dist_dir
):
with
open
(
os
.
path
.
join
(
dist_dir
,
'SConstruct'
),
"r"
)
as
f
:
data
=
f
.
readlines
()
with
open
(
os
.
path
.
join
(
dist_dir
,
'SConstruct'
),
"w"
)
as
f
:
for
line
in
data
:
if
line
.
find
(
'RTT_ROOT'
)
!=
-
1
:
if
line
.
find
(
'sys.path'
)
!=
-
1
:
f
.
write
(
'# set RTT_ROOT
\n
'
)
f
.
write
(
"if not os.getenv('RTT_ROOT'):
\n
RTT_ROOT='rt-thread'
\n\n
"
)
f
.
write
(
line
)
source_list
=
target_list
def
bsp_update_kconfig
(
dist_dir
):
# change RTT_ROOT in Kconfig
with
open
(
os
.
path
.
join
(
dist_dir
,
'Kconfig'
),
"r"
)
as
f
:
data
=
f
.
readlines
()
with
open
(
os
.
path
.
join
(
dist_dir
,
'Kconfig'
),
"w"
)
as
f
:
found
=
0
for
line
in
data
:
if
line
.
find
(
'RTT_ROOT'
)
!=
-
1
:
found
=
1
if
line
.
find
(
'default'
)
!=
-
1
and
found
:
position
=
line
.
find
(
'default'
)
line
=
line
[
0
:
position
]
+
'default: "rt-thread"
\n
'
found
=
0
f
.
write
(
line
)
def
bs_update_ide_project
(
bsp_root
,
rtt_root
):
import
subprocess
# default update the projects which have template file
tgt_dict
=
{
'mdk4'
:(
'keil'
,
'armcc'
),
'mdk5'
:(
'keil'
,
'armcc'
),
'iar'
:(
'iar'
,
'iar'
),
'vs'
:(
'msvc'
,
'cl'
),
'vs2012'
:(
'msvc'
,
'cl'
),
'cdk'
:(
'gcc'
,
'gcc'
)}
scons_env
=
os
.
environ
.
copy
()
scons_env
[
"RTT_ROOT"
]
=
rtt_root
for
item
in
tgt_dict
:
child
=
subprocess
.
Popen
(
'scons --target='
+
item
,
cwd
=
bsp_root
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
stdout
,
stderr
=
child
.
communicate
()
if
child
.
returncode
==
0
:
print
(
"update %s project"
%
item
)
def
zip_dist
(
bsp_root
,
dist_dir
,
dist_name
):
import
zipfile
for
src
in
source_list
:
dst
=
src
.
replace
(
RTT_ROOT
,
''
)
if
dst
[
0
]
==
os
.
sep
or
dst
[
0
]
==
'/'
:
dst
=
dst
[
1
:]
print
'=> '
,
dst
dst
=
os
.
path
.
join
(
target_path
,
dst
)
do_copy_file
(
src
,
dst
)
zip_filename
=
os
.
path
.
join
(
bsp_root
,
'dist'
,
dist_name
)
zip
=
zipfile
.
ZipFile
(
zip_filename
+
".zip"
,
'w'
)
pre_len
=
len
(
os
.
path
.
dirname
(
dist_dir
))
# copy tools directory
print
"=> tools"
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"tools"
),
os
.
path
.
join
(
target_path
,
"tools"
),
ignore_patterns
(
'*.pyc'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'Kconfig'
),
os
.
path
.
join
(
target_path
,
'Kconfig'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'AUTHORS'
),
os
.
path
.
join
(
target_path
,
'AUTHORS'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'COPYING'
),
os
.
path
.
join
(
target_path
,
'COPYING'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'README.md'
),
os
.
path
.
join
(
target_path
,
'README.md'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'README_zh.md'
),
os
.
path
.
join
(
target_path
,
'README_zh.md'
))
for
parent
,
dirnames
,
filenames
in
os
.
walk
(
dist_dir
):
for
filename
in
filenames
:
pathfile
=
os
.
path
.
join
(
parent
,
filename
)
arcname
=
pathfile
[
pre_len
:].
strip
(
os
.
path
.
sep
)
zip
.
write
(
pathfile
,
arcname
)
print
(
'done!'
)
zip
.
close
(
)
def
MkDist
(
program
,
BSP_ROOT
,
RTT_ROOT
,
Env
):
print
(
"make distribution...."
)
...
...
@@ -206,122 +155,53 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
dist_name
=
os
.
path
.
basename
(
BSP_ROOT
)
dist_dir
=
os
.
path
.
join
(
BSP_ROOT
,
'dist'
,
dist_name
)
target_path
=
os
.
path
.
join
(
dist_dir
,
'rt-thread'
)
# copy BSP files
print
(
"=> %s"
%
os
.
path
.
basename
(
BSP_ROOT
))
do_copy_folder
(
os
.
path
.
join
(
BSP_ROOT
),
dist_dir
,
ignore_patterns
(
'build'
,
'dist'
,
'*.pyc'
,
'*.old'
,
'*.map'
,
'rtthread.bin'
,
'.sconsign.dblite'
,
'*.elf'
,
'*.axf'
,
'cconfig.h'
))
global
source_list
# copy tools directory
print
(
"=> components"
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"components"
),
os
.
path
.
join
(
target_path
,
"components"
))
target_path
=
os
.
path
.
join
(
dist_dir
,
'rt-thread'
)
# skip documentation directory
# skip examples
for
item
in
program
:
walk_children
(
item
)
# copy include directory
print
(
"=> include"
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"include"
),
os
.
path
.
join
(
target_path
,
"include"
))
source_list
.
sort
()
# copy all libcpu/ARCH directory
print
(
'=> libcpu'
)
import
rtconfig
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
'libcpu'
,
rtconfig
.
ARCH
),
os
.
path
.
join
(
target_path
,
'libcpu'
,
rtconfig
.
ARCH
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'libcpu'
,
'Kconfig'
),
os
.
path
.
join
(
target_path
,
'libcpu'
,
'Kconfig'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'libcpu'
,
'SConscript'
),
os
.
path
.
join
(
target_path
,
'libcpu'
,
'SConscript'
))
# copy the source files in RT-Thread
target_list
=
[]
for
src
in
source_list
:
if
src
.
lower
().
startswith
(
BSP_ROOT
.
lower
()):
continue
if
src
.
lower
().
startswith
(
RTT_ROOT
.
lower
()):
target_list
.
append
(
src
)
source_list
=
target_list
# get source directory
src_dir
=
[]
for
src
in
source_list
:
src
=
src
.
replace
(
RTT_ROOT
,
''
)
if
src
[
0
]
==
os
.
sep
or
src
[
0
]
==
'/'
:
src
=
src
[
1
:]
path
=
os
.
path
.
dirname
(
src
)
sub_path
=
path
.
split
(
os
.
sep
)
full_path
=
RTT_ROOT
for
item
in
sub_path
:
full_path
=
os
.
path
.
join
(
full_path
,
item
)
if
full_path
not
in
src_dir
:
src_dir
.
append
(
full_path
)
for
item
in
src_dir
:
source_list
.
append
(
os
.
path
.
join
(
item
,
'SConscript'
))
# add all of Kconfig files
walk_kconfig
(
RTT_ROOT
,
source_list
)
source_list
.
sort
()
for
src
in
source_list
:
dst
=
src
.
replace
(
RTT_ROOT
,
''
)
if
dst
[
0
]
==
os
.
sep
or
dst
[
0
]
==
'/'
:
dst
=
dst
[
1
:]
print
(
'=> %s'
%
dst
)
dst
=
os
.
path
.
join
(
target_path
,
dst
)
do_copy_file
(
src
,
dst
)
# copy src directory
print
(
"=> src"
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"src"
),
os
.
path
.
join
(
target_path
,
"src"
))
# copy tools directory
print
(
"=> tools"
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"tools"
),
os
.
path
.
join
(
target_path
,
"tools"
),
ignore_patterns
(
'*.pyc'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'Kconfig'
),
os
.
path
.
join
(
target_path
,
'Kconfig'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'AUTHORS'
),
os
.
path
.
join
(
target_path
,
'AUTHORS'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'COPYING'
),
os
.
path
.
join
(
target_path
,
'COPYING'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'README.md'
),
os
.
path
.
join
(
target_path
,
'README.md'
))
do_copy_file
(
os
.
path
.
join
(
RTT_ROOT
,
'README_zh.md'
),
os
.
path
.
join
(
target_path
,
'README_zh.md'
))
print
(
'=> libc'
)
do_copy_folder
(
os
.
path
.
join
(
RTT_ROOT
,
"components"
,
'libc'
,
'compilers'
),
os
.
path
.
join
(
target_path
,
"components"
,
'libc'
,
'compilers'
))
# change RTT_ROOT in SConstruct
try
:
sconstruct
=
file
(
os
.
path
.
join
(
BSP_ROOT
,
'SConstruct'
))
out
=
file
(
os
.
path
.
join
(
dist_dir
,
'SConstruct'
),
'w'
)
for
line
in
sconstruct
:
if
line
.
find
(
'RTT_ROOT'
)
!=
-
1
:
if
line
.
find
(
'sys.path'
)
!=
-
1
:
out
.
write
(
'# set RTT_ROOT
\n
'
)
out
.
write
(
"if not os.getenv('RTT_ROOT'):
\n
RTT_ROOT='rt-thread'
\n\n
"
)
out
.
write
(
line
)
except
:
print
(
''
)
bsp_update_sconstruct
(
dist_dir
)
# change RTT_ROOT in Kconfig
try
:
if
os
.
path
.
exists
(
os
.
path
.
join
(
BSP_ROOT
,
'Kconfig'
)):
Kconfig
=
file
(
os
.
path
.
join
(
BSP_ROOT
,
'Kconfig'
))
out
=
file
(
os
.
path
.
join
(
dist_dir
,
'Kconfig'
),
'w'
)
found
=
0
for
line
in
Kconfig
:
if
line
.
find
(
'RTT_ROOT'
)
!=
-
1
:
found
=
1
if
line
.
find
(
'default'
)
!=
-
1
and
found
:
position
=
line
.
find
(
'default'
)
line
=
line
[
0
:
position
]
+
'default: "rt-thread"
\n
'
found
=
0
out
.
write
(
line
)
out
.
close
()
except
:
print
(
''
)
bsp_update_kconfig
(
dist_dir
)
# update all project files
bs_update_ide_project
(
dist_dir
,
target_path
)
# make zip package
import
zipfile
zip_filename
=
os
.
path
.
join
(
BSP_ROOT
,
'dist'
,
dist_name
)
zip
=
zipfile
.
ZipFile
(
zip_filename
+
".zip"
,
'w'
)
pre_len
=
len
(
os
.
path
.
dirname
(
dist_dir
))
for
parent
,
dirnames
,
filenames
in
os
.
walk
(
dist_dir
):
for
filename
in
filenames
:
pathfile
=
os
.
path
.
join
(
parent
,
filename
)
arcname
=
pathfile
[
pre_len
:].
strip
(
os
.
path
.
sep
)
zip
.
write
(
pathfile
,
arcname
)
zip
.
close
()
zip_dist
(
BSP_ROOT
,
dist_dir
,
dist_name
)
print
(
'done!'
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录