Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
85495acd
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看板
未验证
提交
85495acd
编写于
6月 23, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
6月 23, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1561 from armink/fix_scons
完善对于 'scons --target=cc' 生成的工程可能编译出错问题的修复
上级
7da37628
dbe8e60f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
128 addition
and
148 deletion
+128
-148
tools/building.py
tools/building.py
+128
-148
未找到文件。
tools/building.py
浏览文件 @
85495acd
...
...
@@ -112,37 +112,33 @@ class Win32Spawn:
return
proc
.
wait
()
# auto fix the 'RTT_CC' and 'RTT_EXEC_PATH'
# when using 'scons --target=cc' the 'RTT_CC' will set to 'cc'
# it will fix the the 'rtconfig.EXEC_PATH' when get it failed.
# NOTE: this function will changed your env. Please backup the env before used it.
def
AutoFixRttCCAndExecPath
():
# generate cconfig.h file
def
GenCconfigFile
(
env
,
BuildOptions
):
import
rtconfig
target_option
=
None
if
rtconfig
.
PLATFORM
==
'gcc'
:
contents
=
''
if
not
os
.
path
.
isfile
(
'cconfig.h'
):
import
gcc
gcc
.
GenerateGCCConfig
(
rtconfig
)
# get --target=cc option
if
len
(
sys
.
argv
)
>
1
:
option
=
sys
.
argv
[
1
].
split
(
'='
)
if
len
(
option
)
>
1
and
option
[
0
]
==
'--target'
:
target_option
=
option
[
1
]
# try again
if
os
.
path
.
isfile
(
'cconfig.h'
):
f
=
file
(
'cconfig.h'
,
'r'
)
if
f
:
contents
=
f
.
read
()
f
.
close
();
# force change the 'RTT_CC' when using 'scons --target=cc'
if
target_option
:
if
target_option
==
'mdk'
or
target_option
==
'mdk4'
or
target_option
==
'mdk5'
:
os
.
environ
[
'RTT_CC'
]
=
'keil'
elif
target_option
==
'iar'
:
os
.
environ
[
'RTT_CC'
]
=
'iar'
prep
=
PatchedPreProcessor
()
prep
.
process_contents
(
contents
)
options
=
prep
.
cpp_namespace
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
reload
(
rtconfig
)
if
not
os
.
path
.
exists
(
rtconfig
.
EXEC_PATH
):
if
os
.
environ
[
'RTT_EXEC_PATH'
]:
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
del
os
.
environ
[
'RTT_EXEC_PATH'
]
reload
(
rtconfig
)
BuildOptions
.
update
(
options
)
# add HAVE_CCONFIG_H definition
env
.
AppendUnique
(
CPPDEFINES
=
[
'HAVE_CCONFIG_H'
])
def
PrepareBuilding
(
env
,
root_directory
,
has_libcpu
=
False
,
remove_components
=
[]):
import
SCons.cpp
import
rtconfig
global
BuildOptions
...
...
@@ -150,6 +146,64 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
global
Env
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
(
'--cscope'
,
dest
=
'cscope'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Build Cscope cross reference database. Requires cscope installed.'
)
AddOption
(
'--clang-analyzer'
,
dest
=
'clang-analyzer'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Perform static analyze with Clang-analyzer. '
+
\
'Requires Clang installed.
\n
'
+
\
'It is recommended to use with scan-build like this:
\n
'
+
\
'`scan-build scons --clang-analyzer`
\n
'
+
\
'If things goes well, scan-build will instruct you to invoke scan-view.'
)
AddOption
(
'--buildlib'
,
dest
=
'buildlib'
,
type
=
'string'
,
help
=
'building library of a component'
)
AddOption
(
'--cleanlib'
,
dest
=
'cleanlib'
,
action
=
'store_true'
,
default
=
False
,
help
=
'clean up the library by --buildlib'
)
AddOption
(
'--target'
,
dest
=
'target'
,
type
=
'string'
,
help
=
'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk'
)
AddOption
(
'--genconfig'
,
dest
=
'genconfig'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Generate .config from rtconfig.h'
)
AddOption
(
'--useconfig'
,
dest
=
'useconfig'
,
type
=
'string'
,
help
=
'make rtconfig.h from config file.'
)
AddOption
(
'--verbose'
,
dest
=
'verbose'
,
action
=
'store_true'
,
default
=
False
,
help
=
'print verbose information during build'
)
Env
=
env
Rtt_Root
=
os
.
path
.
abspath
(
root_directory
)
# set RTT_ROOT in ENV
...
...
@@ -159,22 +213,60 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
sys
.
path
=
sys
.
path
+
[
os
.
path
.
join
(
Rtt_Root
,
'tools'
)]
# auto fix the 'RTT_CC' and 'RTT_EXEC_PATH'
AutoFixRttCCAndExecPath
()
# {target_name:(CROSS_TOOL, PLATFORM)}
tgt_dict
=
{
'mdk'
:(
'keil'
,
'armcc'
),
'mdk4'
:(
'keil'
,
'armcc'
),
'mdk5'
:(
'keil'
,
'armcc'
),
'iar'
:(
'iar'
,
'iar'
),
'vs'
:(
'msvc'
,
'cl'
),
'vs2012'
:(
'msvc'
,
'cl'
),
'vsc'
:
(
'gcc'
,
'gcc'
),
'cb'
:(
'keil'
,
'armcc'
),
'ua'
:(
'gcc'
,
'gcc'
),
'cdk'
:(
'gcc'
,
'gcc'
)}
tgt_name
=
GetOption
(
'target'
)
if
tgt_name
:
# --target will change the toolchain settings which clang-analyzer is
# depend on
if
GetOption
(
'clang-analyzer'
):
print
'--clang-analyzer cannot be used with --target'
sys
.
exit
(
1
)
SetOption
(
'no_exec'
,
1
)
try
:
rtconfig
.
CROSS_TOOL
,
rtconfig
.
PLATFORM
=
tgt_dict
[
tgt_name
]
# replace the 'RTT_CC' to 'CROSS_TOOL'
os
.
environ
[
'RTT_CC'
]
=
rtconfig
.
CROSS_TOOL
reload
(
rtconfig
)
except
KeyError
:
print
'Unknow target: %s. Avaible targets: %s'
%
\
(
tgt_name
,
', '
.
join
(
tgt_dict
.
keys
()))
sys
.
exit
(
1
)
elif
(
GetDepend
(
'RT_USING_NEWLIB'
)
==
False
and
GetDepend
(
'RT_USING_NOLIBC'
)
==
False
)
\
and
rtconfig
.
PLATFORM
==
'gcc'
:
AddDepend
(
'RT_USING_MINILIBC'
)
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
if
not
os
.
path
.
exists
(
rtconfig
.
EXEC_PATH
):
if
os
.
environ
[
'RTT_EXEC_PATH'
]:
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
del
os
.
environ
[
'RTT_EXEC_PATH'
]
reload
(
rtconfig
)
# add compability with Keil MDK 4.6 which changes the directory of armcc.exe
if
rtconfig
.
PLATFORM
==
'armcc'
:
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
rtconfig
.
EXEC_PATH
,
'armcc.exe'
)):
if
rtconfig
.
EXEC_PATH
.
find
(
'bin40'
)
>
0
:
rtconfig
.
EXEC_PATH
=
rtconfig
.
EXEC_PATH
.
replace
(
'bin40'
,
'armcc/bin'
)
Env
[
'LINKFLAGS'
]
=
Env
[
'LINKFLAGS'
].
replace
(
'RV31'
,
'armcc'
)
Env
[
'LINKFLAGS'
]
=
Env
[
'LINKFLAGS'
].
replace
(
'RV31'
,
'armcc'
)
# reset AR command flags
env
[
'ARCOM'
]
=
'$AR --create $TARGET $SOURCES'
env
[
'LIBPREFIX'
]
=
''
env
[
'LIBSUFFIX'
]
=
'.lib'
env
[
'LIBPREFIX'
]
=
''
env
[
'LIBSUFFIX'
]
=
'.lib'
env
[
'LIBLINKPREFIX'
]
=
''
env
[
'LIBLINKSUFFIX'
]
=
'.lib'
env
[
'LIBLINKSUFFIX'
]
=
'.lib'
env
[
'LIBDIRPREFIX'
]
=
'--userlibpath '
# patch for win32 spawn
...
...
@@ -206,62 +298,6 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
PreProcessor
.
process_contents
(
contents
)
BuildOptions
=
PreProcessor
.
cpp_namespace
if
rtconfig
.
PLATFORM
==
'gcc'
:
contents
=
''
if
not
os
.
path
.
isfile
(
'cconfig.h'
):
import
gcc
gcc
.
GenerateGCCConfig
(
rtconfig
)
# try again
if
os
.
path
.
isfile
(
'cconfig.h'
):
f
=
file
(
'cconfig.h'
,
'r'
)
if
f
:
contents
=
f
.
read
()
f
.
close
();
prep
=
PatchedPreProcessor
()
prep
.
process_contents
(
contents
)
options
=
prep
.
cpp_namespace
BuildOptions
.
update
(
options
)
# add HAVE_CCONFIG_H definition
env
.
AppendUnique
(
CPPDEFINES
=
[
'HAVE_CCONFIG_H'
])
if
str
(
env
[
'LINKFLAGS'
]).
find
(
'nano.specs'
)
!=
-
1
:
env
.
AppendUnique
(
CPPDEFINES
=
[
'_REENT_SMALL'
])
# add copy option
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
(
'--cscope'
,
dest
=
'cscope'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Build Cscope cross reference database. Requires cscope installed.'
)
AddOption
(
'--clang-analyzer'
,
dest
=
'clang-analyzer'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Perform static analyze with Clang-analyzer. '
+
\
'Requires Clang installed.
\n
'
+
\
'It is recommended to use with scan-build like this:
\n
'
+
\
'`scan-build scons --clang-analyzer`
\n
'
+
\
'If things goes well, scan-build will instruct you to invoke scan-view.'
)
if
GetOption
(
'clang-analyzer'
):
# perform what scan-build does
env
.
Replace
(
...
...
@@ -281,59 +317,13 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
# found or something like that).
rtconfig
.
POST_ACTION
=
''
# add build library option
AddOption
(
'--buildlib'
,
dest
=
'buildlib'
,
type
=
'string'
,
help
=
'building library of a component'
)
AddOption
(
'--cleanlib'
,
dest
=
'cleanlib'
,
action
=
'store_true'
,
default
=
False
,
help
=
'clean up the library by --buildlib'
)
# add target option
AddOption
(
'--target'
,
dest
=
'target'
,
type
=
'string'
,
help
=
'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk'
)
# generate cconfig.h file
GenCconfigFile
(
env
,
BuildOptions
)
#{target_name:(CROSS_TOOL, PLATFORM)}
tgt_dict
=
{
'mdk'
:(
'keil'
,
'armcc'
),
'mdk4'
:(
'keil'
,
'armcc'
),
'mdk5'
:(
'keil'
,
'armcc'
),
'iar'
:(
'iar'
,
'iar'
),
'vs'
:(
'msvc'
,
'cl'
),
'vs2012'
:(
'msvc'
,
'cl'
),
'vsc'
:
(
'gcc'
,
'gcc'
),
'cb'
:(
'keil'
,
'armcc'
),
'ua'
:(
'gcc'
,
'gcc'
),
'cdk'
:(
'gcc'
,
'gcc'
)}
tgt_name
=
GetOption
(
'target'
)
if
tgt_name
:
# --target will change the toolchain settings which clang-analyzer is
# depend on
if
GetOption
(
'clang-analyzer'
):
print
'--clang-analyzer cannot be used with --target'
sys
.
exit
(
1
)
# auto append '_REENT_SMALL' when using newlib 'nano.specs' option
if
rtconfig
.
PLATFORM
==
'gcc'
and
str
(
env
[
'LINKFLAGS'
]).
find
(
'nano.specs'
)
!=
-
1
:
env
.
AppendUnique
(
CPPDEFINES
=
[
'_REENT_SMALL'
])
SetOption
(
'no_exec'
,
1
)
try
:
rtconfig
.
CROSS_TOOL
,
rtconfig
.
PLATFORM
=
tgt_dict
[
tgt_name
]
except
KeyError
:
print
'Unknow target: %s. Avaible targets: %s'
%
\
(
tgt_name
,
', '
.
join
(
tgt_dict
.
keys
()))
sys
.
exit
(
1
)
elif
(
GetDepend
(
'RT_USING_NEWLIB'
)
==
False
and
GetDepend
(
'RT_USING_NOLIBC'
)
==
False
)
\
and
rtconfig
.
PLATFORM
==
'gcc'
:
AddDepend
(
'RT_USING_MINILIBC'
)
AddOption
(
'--genconfig'
,
dest
=
'genconfig'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Generate .config from rtconfig.h'
)
if
GetOption
(
'genconfig'
):
from
genconf
import
genconfig
genconfig
()
...
...
@@ -350,22 +340,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
menuconfig
(
Rtt_Root
)
exit
(
0
)
AddOption
(
'--useconfig'
,
dest
=
'useconfig'
,
type
=
'string'
,
help
=
'make rtconfig.h from config file.'
)
configfn
=
GetOption
(
'useconfig'
)
if
configfn
:
from
menuconfig
import
mk_rtconfig
mk_rtconfig
(
configfn
)
exit
(
0
)
# add comstr option
AddOption
(
'--verbose'
,
dest
=
'verbose'
,
action
=
'store_true'
,
default
=
False
,
help
=
'print verbose information during build'
)
if
not
GetOption
(
'verbose'
):
# override the default verbose command string
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录