Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
6f6dd801
R
rt-thread
项目概览
2345VOR
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f6dd801
编写于
11月 04, 2017
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Tools] Add scons --dist command.
上级
a9a02d5e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
324 addition
and
163 deletion
+324
-163
tools/building.py
tools/building.py
+19
-163
tools/mkdist.py
tools/mkdist.py
+305
-0
未找到文件。
tools/building.py
浏览文件 @
6f6dd801
...
...
@@ -179,6 +179,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
action
=
'store_true'
,
default
=
False
,
help
=
'copy header of rt-thread directory to local.'
)
AddOption
(
'--dist'
,
dest
=
'make-dist'
,
action
=
'store_true'
,
default
=
False
,
help
=
'make distribution'
)
AddOption
(
'--cscope'
,
dest
=
'cscope'
,
action
=
'store_true'
,
...
...
@@ -502,7 +507,9 @@ def DefineGroup(name, src, depend, **parameters):
if
GetOption
(
'cleanlib'
)
and
os
.
path
.
exists
(
os
.
path
.
join
(
group
[
'path'
],
GroupLibFullName
(
name
,
Env
))):
if
group
[
'src'
]
!=
[]:
print
'Remove library:'
,
GroupLibFullName
(
name
,
Env
)
do_rm_file
(
os
.
path
.
join
(
group
[
'path'
],
GroupLibFullName
(
name
,
Env
)))
fn
=
os
.
path
.
join
(
group
[
'path'
],
GroupLibFullName
(
name
,
Env
))
if
os
.
path
.
exists
(
fn
):
os
.
unlink
(
fn
)
# check whether exist group library
if
not
GetOption
(
'buildlib'
)
and
os
.
path
.
exists
(
os
.
path
.
join
(
group
[
'path'
],
GroupLibFullName
(
name
,
Env
))):
...
...
@@ -692,11 +699,19 @@ def EndBuilding(target, program = None):
from
ua
import
PrepareUA
PrepareUA
(
Projects
,
Rtt_Root
,
str
(
Dir
(
'#'
)))
BSP_ROOT
=
Dir
(
'#'
).
abspath
if
GetOption
(
'copy'
)
and
program
!=
None
:
MakeCopy
(
program
)
from
mkdist
import
MakeCopy
MakeCopy
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
exit
(
0
)
if
GetOption
(
'copy-header'
)
and
program
!=
None
:
MakeCopyHeader
(
program
)
from
mkdist
import
MakeCopyHeader
MakeCopyHeader
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
exit
(
0
)
if
GetOption
(
'make-dist'
)
and
program
!=
None
:
from
mkdist
import
MkDist
MkDist
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
exit
(
0
)
if
GetOption
(
'cscope'
):
from
cscope
import
CscopeDatabase
CscopeDatabase
(
Projects
)
...
...
@@ -761,163 +776,4 @@ def PackageSConscript(package):
return
BuildPackage
(
package
)
def
file_path_exist
(
path
,
*
args
):
return
os
.
path
.
exists
(
os
.
path
.
join
(
path
,
*
args
))
def
do_rm_file
(
src
):
if
os
.
path
.
exists
(
src
):
os
.
unlink
(
src
)
def
do_copy_file
(
src
,
dst
):
import
shutil
# check source file
if
not
os
.
path
.
exists
(
src
):
return
path
=
os
.
path
.
dirname
(
dst
)
# mkdir if path not exist
if
not
os
.
path
.
exists
(
path
):
os
.
makedirs
(
path
)
shutil
.
copy2
(
src
,
dst
)
def
do_copy_folder
(
src_dir
,
dst_dir
):
import
shutil
# check source directory
if
not
os
.
path
.
exists
(
src_dir
):
return
if
os
.
path
.
exists
(
dst_dir
):
shutil
.
rmtree
(
dst_dir
)
shutil
.
copytree
(
src_dir
,
dst_dir
)
source_ext
=
[
"c"
,
"h"
,
"s"
,
"S"
,
"cpp"
,
"xpm"
]
source_list
=
[]
def
walk_children
(
child
):
global
source_list
global
source_ext
# print child
full_path
=
child
.
rfile
().
abspath
file_type
=
full_path
.
rsplit
(
'.'
,
1
)[
1
]
#print file_type
if
file_type
in
source_ext
:
if
full_path
not
in
source_list
:
source_list
.
append
(
full_path
)
children
=
child
.
all_children
()
if
children
!=
[]:
for
item
in
children
:
walk_children
(
item
)
def
MakeCopy
(
program
):
global
source_list
global
Rtt_Root
global
Env
target_path
=
os
.
path
.
join
(
Dir
(
'#'
).
abspath
,
'rt-thread'
)
if
Env
[
'PLATFORM'
]
==
'win32'
:
RTT_ROOT
=
Rtt_Root
.
lower
()
else
:
RTT_ROOT
=
Rtt_Root
if
target_path
.
startswith
(
RTT_ROOT
):
return
for
item
in
program
:
walk_children
(
item
)
source_list
.
sort
()
# filte 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 path
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'
))
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"
))
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'
))
def
MakeCopyHeader
(
program
):
global
source_ext
source_ext
=
[]
source_ext
=
[
"h"
,
"xpm"
]
global
source_list
global
Rtt_Root
global
Env
target_path
=
os
.
path
.
join
(
Dir
(
'#'
).
abspath
,
'rt-thread'
)
if
Env
[
'PLATFORM'
]
==
'win32'
:
RTT_ROOT
=
Rtt_Root
.
lower
()
else
:
RTT_ROOT
=
Rtt_Root
if
target_path
.
startswith
(
RTT_ROOT
):
return
for
item
in
program
:
walk_children
(
item
)
source_list
.
sort
()
# filte 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
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"
))
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'
))
tools/mkdist.py
0 → 100644
浏览文件 @
6f6dd801
import
os
import
shutil
from
shutil
import
ignore_patterns
def
do_copy_file
(
src
,
dst
):
# check source file
if
not
os
.
path
.
exists
(
src
):
return
path
=
os
.
path
.
dirname
(
dst
)
# mkdir if path not exist
if
not
os
.
path
.
exists
(
path
):
os
.
makedirs
(
path
)
shutil
.
copy2
(
src
,
dst
)
def
do_copy_folder
(
src_dir
,
dst_dir
,
ignore
=
None
):
import
shutil
# check source directory
if
not
os
.
path
.
exists
(
src_dir
):
return
try
:
if
os
.
path
.
exists
(
dst_dir
):
shutil
.
rmtree
(
dst_dir
)
except
:
print
(
'Deletes folder: %s failed.'
%
dst_dir
)
return
shutil
.
copytree
(
src_dir
,
dst_dir
,
ignore
=
ignore
)
source_ext
=
[
"c"
,
"h"
,
"s"
,
"S"
,
"cpp"
,
"xpm"
]
source_list
=
[]
def
walk_children
(
child
):
global
source_list
global
source_ext
# print child
full_path
=
child
.
rfile
().
abspath
file_type
=
full_path
.
rsplit
(
'.'
,
1
)[
1
]
#print file_type
if
file_type
in
source_ext
:
if
full_path
not
in
source_list
:
source_list
.
append
(
full_path
)
children
=
child
.
all_children
()
if
children
!=
[]:
for
item
in
children
:
walk_children
(
item
)
def
walk_kconfig
(
RTT_ROOT
,
source_list
):
for
parent
,
dirnames
,
filenames
in
os
.
walk
(
RTT_ROOT
):
if
'bsp'
in
parent
:
continue
if
'.git'
in
parent
:
continue
if
'tools'
in
parent
:
continue
if
'Kconfig'
in
filenames
:
pathfile
=
os
.
path
.
join
(
parent
,
'Kconfig'
)
source_list
.
append
(
pathfile
)
if
'KConfig'
in
filenames
:
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'
)
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 --dist to make a distribution'
)
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
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
(
'done!'
)
def
MkDist
(
program
,
BSP_ROOT
,
RTT_ROOT
,
Env
):
print
(
"make distribution...."
)
dist_name
=
os
.
path
.
basename
(
BSP_ROOT
)
dist_dir
=
os
.
path
.
join
(
BSP_ROOT
,
'dist'
,
dist_name
)
# 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'
))
global
source_list
target_path
=
os
.
path
.
join
(
dist_dir
,
'rt-thread'
)
for
item
in
program
:
walk_children
(
item
)
source_list
.
sort
()
# 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 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
(
''
)
# 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
(
''
)
# 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
()
print
(
'done!'
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录