未验证 提交 7278bcb5 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #2851 from armink/add_guiconfig

[tools] add menuconfig GUI by python.
......@@ -377,7 +377,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
dest = 'pyconfig',
action = 'store_true',
default = False,
help = 'make menuconfig for RT-Thread BSP')
help = 'Python GUI menuconfig for RT-Thread BSP')
AddOption('--pyconfig-silent',
dest = 'pyconfig_silent',
action = 'store_true',
......@@ -385,14 +385,14 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
help = 'Don`t show pyconfig window')
if GetOption('pyconfig_silent'):
from menuconfig import pyconfig_silent
from menuconfig import guiconfig_silent
pyconfig_silent(Rtt_Root)
guiconfig_silent(Rtt_Root)
exit(0)
elif GetOption('pyconfig'):
from menuconfig import pyconfig
from menuconfig import guiconfig
pyconfig(Rtt_Root)
guiconfig(Rtt_Root)
exit(0)
configfn = GetOption('useconfig')
......
#!/usr/bin/env python
# Copyright (c) 2019, Ulf Magnusson
# SPDX-License-Identifier: ISC
"""
Reads a specified configuration file, then writes a new configuration file.
This can be used to initialize the configuration from e.g. an arch-specific
configuration file. This input configuration file would usually be a minimal
configuration file, as generated by e.g. savedefconfig.
The default output filename is '.config'. A different filename can be passed in
the KCONFIG_CONFIG environment variable.
"""
import argparse
import kconfiglib
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description=__doc__)
parser.add_argument(
"--kconfig",
default="Kconfig",
help="Base Kconfig file (default: Kconfig)")
parser.add_argument(
"config",
metavar="CONFIGURATION",
help="Input configuration file")
args = parser.parse_args()
kconf = kconfiglib.Kconfig(args.kconfig)
print(kconf.load_config(args.config))
print(kconf.write_config())
if __name__ == "__main__":
main()
此差异已折叠。
......@@ -21,6 +21,7 @@
# Date Author Notes
# 2017-12-29 Bernard The first version
# 2018-07-31 weety Support pyconfig
# 2019-07-13 armink Support guiconfig
import os
import re
......@@ -225,9 +226,9 @@ def menuconfig(RTT_ROOT):
if mtime != mtime2:
mk_rtconfig(fn)
# pyconfig for windows and linux
def pyconfig(RTT_ROOT):
import pymenuconfig
# guiconfig for windows and linux
def guiconfig(RTT_ROOT):
import pyguiconfig
touch_env()
env_dir = get_env_dir()
......@@ -241,7 +242,8 @@ def pyconfig(RTT_ROOT):
else:
mtime = -1
pymenuconfig.main(['--kconfig', 'Kconfig', '--config', '.config'])
sys.argv = ['guiconfig', 'Kconfig'];
pyguiconfig._main()
if os.path.isfile(fn):
mtime2 = os.path.getmtime(fn)
......@@ -253,10 +255,9 @@ def pyconfig(RTT_ROOT):
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.")
# guiconfig for windows and linux
def guiconfig_silent(RTT_ROOT):
import defconfig
touch_env()
env_dir = get_env_dir()
......@@ -265,7 +266,8 @@ def pyconfig_silent(RTT_ROOT):
fn = '.config'
pymenuconfig.main(['--kconfig', 'Kconfig', '--config', '.config', '--silent', 'True'])
sys.argv = ['defconfig', '--kconfig', 'Kconfig', '.config']
defconfig.main()
# silent mode, force to make rtconfig.h
mk_rtconfig(fn)
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册