Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
9255a443
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看板
未验证
提交
9255a443
编写于
12月 26, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
12月 26, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2120 from zhaojuntao/Add-tools-silent
[tools] pyconfig 增加 silent 模式,不显示窗口但可以更新 .config 和 rtconfig.h
上级
fd36c064
2d19eafc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
83 addition
and
10 deletion
+83
-10
tools/building.py
tools/building.py
+14
-2
tools/menuconfig.py
tools/menuconfig.py
+28
-0
tools/pymenuconfig.py
tools/pymenuconfig.py
+41
-8
未找到文件。
tools/building.py
浏览文件 @
9255a443
...
...
@@ -131,7 +131,7 @@ def GenCconfigFile(env, BuildOptions):
f
=
open
(
'cconfig.h'
,
'r'
)
if
f
:
contents
=
f
.
read
()
f
.
close
()
;
f
.
close
()
prep
=
PatchedPreProcessor
()
prep
.
process_contents
(
contents
)
...
...
@@ -349,8 +349,20 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
action
=
'store_true'
,
default
=
False
,
help
=
'make menuconfig for RT-Thread BSP'
)
if
GetOption
(
'pyconfig'
):
AddOption
(
'--pyconfig-silent'
,
dest
=
'pyconfig_silent'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Don`t show pyconfig window'
)
if
GetOption
(
'pyconfig_silent'
):
from
menuconfig
import
pyconfig_silent
pyconfig_silent
(
Rtt_Root
)
exit
(
0
)
elif
GetOption
(
'pyconfig'
):
from
menuconfig
import
pyconfig
pyconfig
(
Rtt_Root
)
exit
(
0
)
...
...
tools/menuconfig.py
浏览文件 @
9255a443
...
...
@@ -251,3 +251,31 @@ def pyconfig(RTT_ROOT):
if
mtime
!=
mtime2
:
mk_rtconfig
(
fn
)
# pyconfig_silent for windows and linux
def
pyconfig_silent
(
RTT_ROOT
):
import
pymenuconfig
print
(
"In pyconfig silent mode. Don`t display menuconfig window."
)
touch_env
()
env_dir
=
get_env_dir
()
os
.
environ
[
'PKGS_ROOT'
]
=
os
.
path
.
join
(
env_dir
,
'packages'
)
fn
=
'.config'
if
os
.
path
.
isfile
(
fn
):
mtime
=
os
.
path
.
getmtime
(
fn
)
else
:
mtime
=
-
1
pymenuconfig
.
main
([
'--kconfig'
,
'Kconfig'
,
'--config'
,
'.config'
,
'--silent'
,
'True'
])
if
os
.
path
.
isfile
(
fn
):
mtime2
=
os
.
path
.
getmtime
(
fn
)
else
:
mtime2
=
-
1
# make rtconfig.h
if
mtime
!=
mtime2
:
mk_rtconfig
(
fn
)
tools/pymenuconfig.py
浏览文件 @
9255a443
...
...
@@ -543,8 +543,11 @@ class MenuConfig(object):
(
'Save as'
,
ACTION_SAVE_AS
),
)
def
__init__
(
self
,
kconfig
):
def
__init__
(
self
,
kconfig
,
__silent
=
None
):
self
.
kconfig
=
kconfig
self
.
__silent
=
__silent
if
self
.
__silent
is
True
:
return
# Instantiate Tk widgets
self
.
root
=
tk
.
Tk
()
...
...
@@ -728,6 +731,8 @@ class MenuConfig(object):
def
_close_window
(
self
):
if
self
.
prevent_losing_changes
():
print
(
'Exiting..'
)
if
self
.
__silent
is
True
:
return
self
.
root
.
destroy
()
def
_action_exit
(
self
):
...
...
@@ -949,6 +954,8 @@ class MenuConfig(object):
- current config path
- status string (see set_status_string())
"""
if
self
.
__silent
is
True
:
return
self
.
tk_status
.
set
(
'{} [{}] {}'
.
format
(
'<UNSAVED>'
if
self
.
unsaved_changes
else
''
,
self
.
config_path
if
self
.
config_path
else
''
,
...
...
@@ -1017,6 +1024,10 @@ class MenuConfig(object):
self
.
mark_as_changed
()
if
not
self
.
unsaved_changes
:
return
True
if
self
.
__silent
:
saved
=
self
.
save_config
()
return
saved
res
=
messagebox
.
askyesnocancel
(
parent
=
self
.
root
,
title
=
'Unsaved changes'
,
...
...
@@ -1056,11 +1067,13 @@ class MenuConfig(object):
self
.
kconfig
.
load_config
(
path
)
except
IOError
as
e
:
self
.
set_status_string
(
'Failed to load:
\'
{}
\'
'
.
format
(
path
))
self
.
refresh_display
()
if
not
self
.
__silent
:
self
.
refresh_display
()
print
(
'Failed to load config
\'
{}
\'
: {}'
.
format
(
path
,
e
))
return
False
self
.
set_status_string
(
'Opened config'
)
self
.
refresh_display
()
if
not
self
.
__silent
:
self
.
refresh_display
()
return
True
def
save_config
(
self
,
force_file_dialog
=
False
):
...
...
@@ -1154,19 +1167,39 @@ def main(argv=None):
type
=
str
,
help
=
'path to .config file to load'
)
if
"--silent"
in
argv
:
parser
.
add_argument
(
'--silent'
,
dest
=
'_silent_'
,
type
=
str
,
help
=
'silent mode, not show window'
)
args
=
parser
.
parse_args
(
argv
)
kconfig_path
=
args
.
kconfig
config_path
=
args
.
config
# Verify that Kconfig file exists
if
not
os
.
path
.
isfile
(
kconfig_path
):
raise
RuntimeError
(
'
\'
{}
\'
: no such file'
.
format
(
kconfig_path
))
# Parse Kconfig files
kconf
=
kconfiglib
.
Kconfig
(
filename
=
kconfig_path
)
mc
=
MenuConfig
(
kconf
)
# If config file was specified, load it
if
config_path
:
mc
.
open_config
(
config_path
)
tk
.
mainloop
()
if
"--silent"
not
in
argv
:
print
(
"In normal mode. Will show menuconfig window."
)
mc
=
MenuConfig
(
kconf
)
# If config file was specified, load it
if
config_path
:
mc
.
open_config
(
config_path
)
print
(
"Enter mainloop. Waiting..."
)
tk
.
mainloop
()
else
:
print
(
"In silent mode. Don`t show menuconfig window."
)
mc
=
MenuConfig
(
kconf
,
True
)
# If config file was specified, load it
if
config_path
:
mc
.
open_config
(
config_path
)
mc
.
_close_window
()
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录