Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
1f389c68
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看板
提交
1f389c68
编写于
8月 03, 2018
作者:
L
liang yongxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[tools] add scons --dist-strip support
上级
ba1aedd1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
116 addition
and
23 deletion
+116
-23
tools/building.py
tools/building.py
+10
-20
tools/mkdist.py
tools/mkdist.py
+106
-3
未找到文件。
tools/building.py
浏览文件 @
1f389c68
...
...
@@ -115,7 +115,7 @@ class Win32Spawn:
# generate cconfig.h file
def
GenCconfigFile
(
env
,
BuildOptions
):
import
rtconfig
if
rtconfig
.
PLATFORM
==
'gcc'
:
contents
=
''
if
not
os
.
path
.
isfile
(
'cconfig.h'
):
...
...
@@ -147,21 +147,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
global
Rtt_Root
# ===== Add option to SCons =====
AddOption
(
'--copy'
,
dest
=
'copy'
,
action
=
'store_true'
,
default
=
False
,
help
=
'copy rt-thread directory to local.'
)
AddOption
(
'--copy-header'
,
dest
=
'copy-header'
,
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
(
'--dist-strip'
,
dest
=
'make-dist-strip'
,
action
=
'store_true'
,
default
=
False
,
help
=
'make distribution and strip useless files'
)
AddOption
(
'--cscope'
,
dest
=
'cscope'
,
action
=
'store_true'
,
...
...
@@ -713,7 +708,7 @@ def DoBuilding(target, objects):
program
=
Env
.
Program
(
target
,
objects
)
EndBuilding
(
target
,
program
)
def
GenTargetProject
(
program
=
None
):
if
GetOption
(
'target'
)
==
'mdk'
:
...
...
@@ -789,17 +784,12 @@ def EndBuilding(target, program = None):
GenTargetProject
(
program
)
BSP_ROOT
=
Dir
(
'#'
).
abspath
if
GetOption
(
'copy'
)
and
program
!=
None
:
from
mkdist
import
MakeCopy
MakeCopy
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
need_exit
=
True
if
GetOption
(
'copy-header'
)
and
program
!=
None
:
from
mkdist
import
MakeCopyHeader
MakeCopyHeader
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
need_exit
=
True
if
GetOption
(
'make-dist'
)
and
program
!=
None
:
from
mkdist
import
MkDist
MkDist
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
if
GetOption
(
'make-dist-strip'
)
and
program
!=
None
:
from
mkdist
import
MkDist_Strip
MkDist_Strip
(
program
,
BSP_ROOT
,
Rtt_Root
,
Env
)
need_exit
=
True
if
GetOption
(
'cscope'
):
from
cscope
import
CscopeDatabase
...
...
tools/mkdist.py
浏览文件 @
1f389c68
...
...
@@ -89,7 +89,12 @@ def walk_kconfig(RTT_ROOT, source_list):
pathfile
=
os
.
path
.
join
(
parent
,
'KConfig'
)
source_list
.
append
(
pathfile
)
def
bsp_update_sconstruct
(
dist_dir
):
def
bsp_copy_files
(
bsp_root
,
dist_dir
):
# 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'
,
'cconfig.h'
))
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
:
...
...
@@ -149,6 +154,104 @@ def zip_dist(bsp_root, dist_dir, dist_name):
zip
.
close
()
def
MkDist_Strip
(
program
,
BSP_ROOT
,
RTT_ROOT
,
Env
):
global
source_list
print
(
"make distribution and strip useless files...."
)
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'
)
bsp_copy_files
(
BSP_ROOT
,
dist_dir
):
# get all source files from program
for
item
in
program
:
walk_children
(
item
)
source_list
.
sort
()
# copy the source files without libcpu and components/libc in RT-Thread
target_list
=
[]
libcpu_dir
=
os
.
path
.
join
(
RTT_ROOT
,
'libcpu'
).
lower
()
libc_dir
=
os
.
path
.
join
(
RTT_ROOT
,
'components'
,
'libc'
).
lower
()
for
src
in
source_list
:
if
src
.
lower
().
startswith
(
BSP_ROOT
.
lower
()):
continue
# skip libc and libcpu dir
if
src
.
lower
().
startswith
(
libcpu_dir
):
continue
if
src
.
lower
().
startswith
(
libc_dir
):
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
)
# add all of SConscript files
for
item
in
src_dir
:
source_list
.
append
(
os
.
path
.
join
(
item
,
'SConscript'
))
# add all of Kconfig files
walk_kconfig
(
RTT_ROOT
,
source_list
)
# copy all files to target directory
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'
))
# 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'
))
# change RTT_ROOT in SConstruct
bsp_update_sconstruct
(
dist_dir
)
# change RTT_ROOT in Kconfig
bsp_update_kconfig
(
dist_dir
)
# update all project files
bs_update_ide_project
(
dist_dir
,
target_path
)
# make zip package
zip_dist
(
BSP_ROOT
,
dist_dir
,
dist_name
)
print
(
'done!'
)
def
MkDist
(
program
,
BSP_ROOT
,
RTT_ROOT
,
Env
):
print
(
"make distribution...."
)
...
...
@@ -159,8 +262,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
# 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'
))
bsp_copy_files
(
BSP_ROOT
,
dist_dir
):
# copy tools directory
print
(
"=> components"
)
...
...
@@ -205,3 +307,4 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录