Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
6e6f12ac
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看板
未验证
提交
6e6f12ac
编写于
11月 07, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
11月 07, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1952 from ArdaFu/master
[Tools] Modify buliding.py and gcc.py for work with python 3.
上级
ddd7343b
e7ca31cc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
66 deletion
+65
-66
tools/building.py
tools/building.py
+49
-50
tools/gcc.py
tools/gcc.py
+16
-16
未找到文件。
tools/building.py
浏览文件 @
6e6f12ac
...
...
@@ -83,13 +83,13 @@ class Win32Spawn:
try
:
os
.
remove
(
f
)
except
Exception
as
e
:
print
'Error removing file: %s'
%
e
print
(
'Error removing file: '
+
e
)
return
-
1
return
0
import
subprocess
newargs
=
string
.
join
(
args
[
1
:],
' '
)
newargs
=
' '
.
join
(
args
[
1
:]
)
cmdline
=
cmd
+
" "
+
newargs
# Make sure the env is constructed by strings
...
...
@@ -104,8 +104,8 @@ class Win32Spawn:
try
:
proc
=
subprocess
.
Popen
(
cmdline
,
env
=
_e
,
shell
=
False
)
except
Exception
as
e
:
print
'Error in calling:
\n
%s'
%
cmdline
print
'Exception: %s: %s'
%
(
e
,
os
.
strerror
(
e
.
errno
))
print
(
'Error in calling:
\n
'
+
cmdline
)
print
(
'Exception: '
+
e
+
': '
+
os
.
strerror
(
e
.
errno
))
return
e
.
errno
finally
:
os
.
environ
[
'PATH'
]
=
old_path
...
...
@@ -124,7 +124,7 @@ def GenCconfigFile(env, BuildOptions):
# try again
if
os
.
path
.
isfile
(
'cconfig.h'
):
f
=
file
(
'cconfig.h'
,
'r'
)
f
=
open
(
'cconfig.h'
,
'r'
)
if
f
:
contents
=
f
.
read
()
f
.
close
();
...
...
@@ -225,7 +225,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
# --target will change the toolchain settings which clang-analyzer is
# depend on
if
GetOption
(
'clang-analyzer'
):
print
'--clang-analyzer cannot be used with --target'
print
(
'--clang-analyzer cannot be used with --target'
)
sys
.
exit
(
1
)
SetOption
(
'no_exec'
,
1
)
...
...
@@ -235,8 +235,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
os
.
environ
[
'RTT_CC'
]
=
rtconfig
.
CROSS_TOOL
reload
(
rtconfig
)
except
KeyError
:
print
'Unknow target: %s. Avaible targets: %s'
%
\
(
tgt_name
,
', '
.
join
(
tgt_dict
.
keys
()))
print
(
'Unknow target: '
+
tgt_name
+
'. Avaible targets: '
+
', '
.
join
(
tgt_dict
.
keys
()))
sys
.
exit
(
1
)
elif
(
GetDepend
(
'RT_USING_NEWLIB'
)
==
False
and
GetDepend
(
'RT_USING_NOLIBC'
)
==
False
)
\
and
rtconfig
.
PLATFORM
==
'gcc'
:
...
...
@@ -287,7 +286,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
# parse rtconfig.h to get used component
PreProcessor
=
PatchedPreProcessor
()
f
=
file
(
'rtconfig.h'
,
'r'
)
f
=
open
(
'rtconfig.h'
,
'r'
)
contents
=
f
.
read
()
f
.
close
()
PreProcessor
.
process_contents
(
contents
)
...
...
@@ -438,7 +437,7 @@ def GetConfigValue(name):
def
GetDepend
(
depend
):
building
=
True
if
type
(
depend
)
==
type
(
'str'
):
if
not
BuildOptions
.
has_key
(
depend
)
or
BuildOptions
[
depend
]
==
0
:
if
not
depend
in
BuildOptions
or
BuildOptions
[
depend
]
==
0
:
building
=
False
elif
BuildOptions
[
depend
]
!=
''
:
return
BuildOptions
[
depend
]
...
...
@@ -448,7 +447,7 @@ def GetDepend(depend):
# for list type depend
for
item
in
depend
:
if
item
!=
''
:
if
not
BuildOptions
.
has_key
(
item
)
or
BuildOptions
[
item
]
==
0
:
if
not
item
in
BuildOptions
or
BuildOptions
[
item
]
==
0
:
building
=
False
return
building
...
...
@@ -471,7 +470,7 @@ def LocalOptions(config_filename):
def
GetLocalDepend
(
options
,
depend
):
building
=
True
if
type
(
depend
)
==
type
(
'str'
):
if
not
options
.
has_key
(
depend
)
or
options
[
depend
]
==
0
:
if
not
depend
in
options
or
options
[
depend
]
==
0
:
building
=
False
elif
options
[
depend
]
!=
''
:
return
options
[
depend
]
...
...
@@ -481,7 +480,7 @@ def GetLocalDepend(options, depend):
# for list type depend
for
item
in
depend
:
if
item
!=
''
:
if
not
options
.
has_key
(
item
)
or
options
[
item
]
==
0
:
if
not
item
in
options
or
options
[
item
]
==
0
:
building
=
False
return
building
...
...
@@ -491,61 +490,61 @@ def AddDepend(option):
def
MergeGroup
(
src_group
,
group
):
src_group
[
'src'
]
=
src_group
[
'src'
]
+
group
[
'src'
]
if
group
.
has_key
(
'CCFLAGS'
)
:
if
src_group
.
has_key
(
'CCFLAGS'
)
:
if
'CCFLAGS'
in
group
:
if
'CCFLAGS'
in
src_group
:
src_group
[
'CCFLAGS'
]
=
src_group
[
'CCFLAGS'
]
+
group
[
'CCFLAGS'
]
else
:
src_group
[
'CCFLAGS'
]
=
group
[
'CCFLAGS'
]
if
group
.
has_key
(
'CPPPATH'
)
:
if
src_group
.
has_key
(
'CPPPATH'
)
:
if
'CPPPATH'
in
group
:
if
'CPPPATH'
in
src_group
:
src_group
[
'CPPPATH'
]
=
src_group
[
'CPPPATH'
]
+
group
[
'CPPPATH'
]
else
:
src_group
[
'CPPPATH'
]
=
group
[
'CPPPATH'
]
if
group
.
has_key
(
'CPPDEFINES'
)
:
if
src_group
.
has_key
(
'CPPDEFINES'
)
:
if
'CPPDEFINES'
in
group
:
if
'CPPDEFINES'
in
src_group
:
src_group
[
'CPPDEFINES'
]
=
src_group
[
'CPPDEFINES'
]
+
group
[
'CPPDEFINES'
]
else
:
src_group
[
'CPPDEFINES'
]
=
group
[
'CPPDEFINES'
]
if
group
.
has_key
(
'ASFLAGS'
)
:
if
src_group
.
has_key
(
'ASFLAGS'
)
:
if
'ASFLAGS'
in
group
:
if
'ASFLAGS'
in
src_group
:
src_group
[
'ASFLAGS'
]
=
src_group
[
'ASFLAGS'
]
+
group
[
'ASFLAGS'
]
else
:
src_group
[
'ASFLAGS'
]
=
group
[
'ASFLAGS'
]
# for local CCFLAGS/CPPPATH/CPPDEFINES
if
group
.
has_key
(
'LOCAL_CCFLAGS'
)
:
if
src_group
.
has_key
(
'LOCAL_CCFLAGS'
)
:
if
'LOCAL_CCFLAGS'
in
group
:
if
'LOCAL_CCFLAGS'
in
src_group
:
src_group
[
'LOCAL_CCFLAGS'
]
=
src_group
[
'LOCAL_CCFLAGS'
]
+
group
[
'LOCAL_CCFLAGS'
]
else
:
src_group
[
'LOCAL_CCFLAGS'
]
=
group
[
'LOCAL_CCFLAGS'
]
if
group
.
has_key
(
'LOCAL_CPPPATH'
)
:
if
src_group
.
has_key
(
'LOCAL_CPPPATH'
)
:
if
'LOCAL_CPPPATH'
in
group
:
if
'LOCAL_CPPPATH'
in
src_group
:
src_group
[
'LOCAL_CPPPATH'
]
=
src_group
[
'LOCAL_CPPPATH'
]
+
group
[
'LOCAL_CPPPATH'
]
else
:
src_group
[
'LOCAL_CPPPATH'
]
=
group
[
'LOCAL_CPPPATH'
]
if
group
.
has_key
(
'LOCAL_CPPDEFINES'
)
:
if
src_group
.
has_key
(
'LOCAL_CPPDEFINES'
)
:
if
'LOCAL_CPPDEFINES'
in
group
:
if
'LOCAL_CPPDEFINES'
in
src_group
:
src_group
[
'LOCAL_CPPDEFINES'
]
=
src_group
[
'LOCAL_CPPDEFINES'
]
+
group
[
'LOCAL_CPPDEFINES'
]
else
:
src_group
[
'LOCAL_CPPDEFINES'
]
=
group
[
'LOCAL_CPPDEFINES'
]
if
group
.
has_key
(
'LINKFLAGS'
)
:
if
src_group
.
has_key
(
'LINKFLAGS'
)
:
if
'LINKFLAGS'
in
group
:
if
'LINKFLAGS'
in
src_group
:
src_group
[
'LINKFLAGS'
]
=
src_group
[
'LINKFLAGS'
]
+
group
[
'LINKFLAGS'
]
else
:
src_group
[
'LINKFLAGS'
]
=
group
[
'LINKFLAGS'
]
if
group
.
has_key
(
'LIBS'
)
:
if
src_group
.
has_key
(
'LIBS'
)
:
if
'LIBS'
in
group
:
if
'LIBS'
in
src_group
:
src_group
[
'LIBS'
]
=
src_group
[
'LIBS'
]
+
group
[
'LIBS'
]
else
:
src_group
[
'LIBS'
]
=
group
[
'LIBS'
]
if
group
.
has_key
(
'LIBPATH'
)
:
if
src_group
.
has_key
(
'LIBPATH'
)
:
if
'LIBPATH'
in
group
:
if
'LIBPATH'
in
src_group
:
src_group
[
'LIBPATH'
]
=
src_group
[
'LIBPATH'
]
+
group
[
'LIBPATH'
]
else
:
src_group
[
'LIBPATH'
]
=
group
[
'LIBPATH'
]
if
group
.
has_key
(
'LOCAL_ASFLAGS'
)
:
if
src_group
.
has_key
(
'LOCAL_ASFLAGS'
)
:
if
'LOCAL_ASFLAGS'
in
group
:
if
'LOCAL_ASFLAGS'
in
src_group
:
src_group
[
'LOCAL_ASFLAGS'
]
=
src_group
[
'LOCAL_ASFLAGS'
]
+
group
[
'LOCAL_ASFLAGS'
]
else
:
src_group
[
'LOCAL_ASFLAGS'
]
=
group
[
'LOCAL_ASFLAGS'
]
...
...
@@ -571,32 +570,32 @@ def DefineGroup(name, src, depend, **parameters):
else
:
group
[
'src'
]
=
src
if
group
.
has_key
(
'CCFLAGS'
)
:
if
'CCFLAGS'
in
group
:
Env
.
AppendUnique
(
CCFLAGS
=
group
[
'CCFLAGS'
])
if
group
.
has_key
(
'CPPPATH'
)
:
if
'CPPPATH'
in
group
:
Env
.
AppendUnique
(
CPPPATH
=
group
[
'CPPPATH'
])
if
group
.
has_key
(
'CPPDEFINES'
)
:
if
'CPPDEFINES'
in
group
:
Env
.
AppendUnique
(
CPPDEFINES
=
group
[
'CPPDEFINES'
])
if
group
.
has_key
(
'LINKFLAGS'
)
:
if
'LINKFLAGS'
in
group
:
Env
.
AppendUnique
(
LINKFLAGS
=
group
[
'LINKFLAGS'
])
if
group
.
has_key
(
'ASFLAGS'
)
:
if
'ASFLAGS'
in
group
:
Env
.
AppendUnique
(
ASFLAGS
=
group
[
'ASFLAGS'
])
# check whether to clean up library
if
GetOption
(
'cleanlib'
)
and
os
.
path
.
exists
(
os
.
path
.
join
(
group
[
'path'
],
GroupLibFullName
(
name
,
Env
))):
if
group
[
'src'
]
!=
[]:
print
'Remove library:'
,
GroupLibFullName
(
name
,
Env
)
print
(
'Remove library:'
+
GroupLibFullName
(
name
,
Env
)
)
fn
=
os
.
path
.
join
(
group
[
'path'
],
GroupLibFullName
(
name
,
Env
))
if
os
.
path
.
exists
(
fn
):
os
.
unlink
(
fn
)
if
group
.
has_key
(
'LIBS'
)
:
if
'LIBS'
in
group
:
Env
.
AppendUnique
(
LIBS
=
group
[
'LIBS'
])
if
group
.
has_key
(
'LIBPATH'
)
:
if
'LIBPATH'
in
group
:
Env
.
AppendUnique
(
LIBPATH
=
group
[
'LIBPATH'
])
# check whether to build group library
if
group
.
has_key
(
'LIBRARY'
)
:
if
'LIBRARY'
in
group
:
objs
=
Env
.
Library
(
name
,
group
[
'src'
])
else
:
# only add source
...
...
@@ -650,7 +649,7 @@ def BuildLibInstallAction(target, source, env):
if
Group
[
'name'
]
==
lib_name
:
lib_name
=
GroupLibFullName
(
Group
[
'name'
],
env
)
dst_name
=
os
.
path
.
join
(
Group
[
'path'
],
lib_name
)
print
'Copy %s => %s'
%
(
lib_name
,
dst_name
)
print
(
'Copy '
+
lib_name
+
' => '
+
dst_name
)
do_copy_file
(
lib_name
,
dst_name
)
break
...
...
@@ -668,7 +667,7 @@ def DoBuilding(target, objects):
# handle local group
def
local_group
(
group
,
objects
):
if
group
.
has_key
(
'LOCAL_CCFLAGS'
)
or
group
.
has_key
(
'LOCAL_CPPPATH'
)
or
group
.
has_key
(
'LOCAL_CPPDEFINES'
)
or
group
.
has_key
(
'LOCAL_ASFLAGS'
)
:
if
'LOCAL_CCFLAGS'
in
group
or
'LOCAL_CPPPATH'
in
group
or
'LOCAL_CPPDEFINES'
in
group
or
'LOCAL_ASFLAGS'
in
group
:
CCFLAGS
=
Env
.
get
(
'CCFLAGS'
,
''
)
+
group
.
get
(
'LOCAL_CCFLAGS'
,
''
)
CPPPATH
=
Env
.
get
(
'CPPPATH'
,
[
''
])
+
group
.
get
(
'LOCAL_CPPPATH'
,
[
''
])
CPPDEFINES
=
Env
.
get
(
'CPPDEFINES'
,
[
''
])
+
group
.
get
(
'LOCAL_CPPDEFINES'
,
[
''
])
...
...
@@ -705,7 +704,7 @@ def DoBuilding(target, objects):
else
:
# remove source files with local flags setting
for
group
in
Projects
:
if
group
.
has_key
(
'LOCAL_CCFLAGS'
)
or
group
.
has_key
(
'LOCAL_CPPPATH'
)
or
group
.
has_key
(
'LOCAL_CPPDEFINES'
)
:
if
'LOCAL_CCFLAGS'
in
group
or
'LOCAL_CPPPATH'
in
group
or
'LOCAL_CPPDEFINES'
in
group
:
for
source
in
group
[
'src'
]:
for
obj
in
objects
:
if
source
.
abspath
==
obj
.
abspath
or
(
len
(
obj
.
sources
)
>
0
and
source
.
abspath
==
obj
.
sources
[
0
].
abspath
):
...
...
@@ -738,7 +737,7 @@ def GenTargetProject(program = None):
if
template
:
MDK5Project
(
'project.uvprojx'
,
Projects
)
else
:
print
'No template project file found.'
print
(
'No template project file found.'
)
if
GetOption
(
'target'
)
==
'mdk4'
:
from
keil
import
MDK4Project
...
...
@@ -807,7 +806,7 @@ def EndBuilding(target, program = None):
if
not
GetOption
(
'help'
)
and
not
GetOption
(
'target'
):
if
not
os
.
path
.
exists
(
rtconfig
.
EXEC_PATH
):
print
"Error: the toolchain path (%s) is not exist, please check 'EXEC_PATH' in path or rtconfig.py."
%
rtconfig
.
EXEC_PATH
print
(
"Error: the toolchain path ("
+
rtconfig
.
EXEC_PATH
+
") is not exist, please check 'EXEC_PATH' in path or rtconfig.py."
)
need_exit
=
True
if
need_exit
:
...
...
@@ -873,7 +872,7 @@ def GetVersion():
version
=
int
(
filter
(
lambda
ch
:
ch
in
'0123456789.'
,
def_ns
[
'RT_VERSION'
]))
subversion
=
int
(
filter
(
lambda
ch
:
ch
in
'0123456789.'
,
def_ns
[
'RT_SUBVERSION'
]))
if
def_ns
.
has_key
(
'RT_REVISION'
)
:
if
'RT_REVISION'
in
def_ns
:
revision
=
int
(
filter
(
lambda
ch
:
ch
in
'0123456789.'
,
def_ns
[
'RT_REVISION'
]))
return
'%d.%d.%d'
%
(
version
,
subversion
,
revision
)
...
...
tools/gcc.py
浏览文件 @
6e6f12ac
...
...
@@ -50,18 +50,19 @@ def GetNewLibVersion(rtconfig):
root
=
GetGCCRoot
(
rtconfig
)
if
CheckHeader
(
rtconfig
,
'_newlib_version.h'
):
# get version from _newlib_version.h file
f
=
file
(
os
.
path
.
join
(
root
,
'include'
,
'_newlib_version.h'
)
)
f
=
open
(
os
.
path
.
join
(
root
,
'include'
,
'_newlib_version.h'
),
'r'
)
if
f
:
for
line
in
f
:
if
line
.
find
(
'_NEWLIB_VERSION'
)
!=
-
1
and
line
.
find
(
'"'
)
!=
-
1
:
version
=
re
.
search
(
r
'\"([^"]+)\"'
,
line
).
groups
()[
0
]
f
.
close
()
elif
CheckHeader
(
rtconfig
,
'newlib.h'
):
# get version from newlib.h
f
=
file
(
os
.
path
.
join
(
root
,
'include'
,
'newlib.h'
)
)
f
=
open
(
os
.
path
.
join
(
root
,
'include'
,
'newlib.h'
),
'r'
)
if
f
:
for
line
in
f
:
if
line
.
find
(
'_NEWLIB_VERSION'
)
!=
-
1
and
line
.
find
(
'"'
)
!=
-
1
:
version
=
re
.
search
(
r
'\"([^"]+)\"'
,
line
).
groups
()[
0
]
f
.
close
()
return
version
def
GCCResult
(
rtconfig
,
str
):
...
...
@@ -77,7 +78,7 @@ def GCCResult(rtconfig, str):
gcc_cmd
=
os
.
path
.
join
(
rtconfig
.
EXEC_PATH
,
rtconfig
.
CC
)
# use temp file to get more information
f
=
file
(
'__tmp.c'
,
'w'
)
f
=
open
(
'__tmp.c'
,
'w'
)
if
f
:
f
.
write
(
str
)
f
.
close
()
...
...
@@ -103,27 +104,27 @@ def GCCResult(rtconfig, str):
stdc
=
'1989'
posix_thread
=
0
for
line
in
stdout
.
split
(
'
\n
'
):
if
re
.
search
(
'fd_set'
,
line
):
for
line
in
stdout
.
split
(
b
'
\n
'
):
if
re
.
search
(
b
'fd_set'
,
line
):
have_fdset
=
1
# check for sigal
if
re
.
search
(
'struct[
\t
]+sigaction'
,
line
):
if
re
.
search
(
b
'struct[
\t
]+sigaction'
,
line
):
have_sigaction
=
1
if
re
.
search
(
'struct[
\t
]+sigevent'
,
line
):
if
re
.
search
(
b
'struct[
\t
]+sigevent'
,
line
):
have_sigevent
=
1
if
re
.
search
(
'siginfo_t'
,
line
):
if
re
.
search
(
b
'siginfo_t'
,
line
):
have_siginfo
=
1
if
re
.
search
(
'union[
\t
]+sigval'
,
line
):
if
re
.
search
(
b
'union[
\t
]+sigval'
,
line
):
have_sigval
=
1
if
re
.
search
(
'char\* version'
,
line
):
version
=
re
.
search
(
r
'\"([^"]+)\"'
,
line
).
groups
()[
0
]
if
re
.
search
(
b
'char\* version'
,
line
):
version
=
re
.
search
(
b
r
'\"([^"]+)\"'
,
line
).
groups
()[
0
]
if
re
.
findall
(
'iso_c_visible = [\d]+'
,
line
):
if
re
.
findall
(
b
'iso_c_visible = [\d]+'
,
line
):
stdc
=
re
.
findall
(
'[\d]+'
,
line
)[
0
]
if
re
.
findall
(
'pthread_create'
,
line
):
if
re
.
findall
(
b
'pthread_create'
,
line
):
posix_thread
=
1
if
have_fdset
:
...
...
@@ -147,7 +148,6 @@ def GCCResult(rtconfig, str):
result
+=
'#define LIBC_POSIX_THREADS 1
\n
'
os
.
remove
(
'__tmp.c'
)
return
result
def
GenerateGCCConfig
(
rtconfig
):
...
...
@@ -187,7 +187,7 @@ def GenerateGCCConfig(rtconfig):
cc_header
+=
GCCResult
(
rtconfig
,
str
)
cc_header
+=
'
\n
#endif
\n
'
cc_file
=
file
(
'cconfig.h'
,
'w'
)
cc_file
=
open
(
'cconfig.h'
,
'w'
)
if
cc_file
:
cc_file
.
write
(
cc_header
)
cc_file
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录