Merge pull request #2851 from armink/add_guiconfig

[tools] add menuconfig GUI by python.
This commit is contained in:
Bernard Xiong 2019-07-25 00:59:43 +08:00 committed by GitHub
commit 7278bcb5f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 4658 additions and 2648 deletions

View File

@ -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')

43
tools/defconfig.py Normal file
View File

@ -0,0 +1,43 @@
#!/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()

File diff suppressed because it is too large Load Diff

View File

@ -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)

2313
tools/pyguiconfig.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff