From 937e22fc8b0be590b690be4b76a0e3f56f854b12 Mon Sep 17 00:00:00 2001 From: weety <494406036@qq.com> Date: Tue, 4 Sep 2018 17:14:33 +0800 Subject: [PATCH] Add scons --pyconfig command for configure project. --- tools/building.py | 10 + tools/kconfiglib.py | 6159 +++++++++++++++++++++++++++++++++++++++++ tools/menuconfig.py | 124 +- tools/pymenuconfig.py | 1103 ++++++++ 4 files changed, 7380 insertions(+), 16 deletions(-) create mode 100644 tools/kconfiglib.py create mode 100644 tools/pymenuconfig.py diff --git a/tools/building.py b/tools/building.py index 527da03103..e334056337 100644 --- a/tools/building.py +++ b/tools/building.py @@ -335,6 +335,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ menuconfig(Rtt_Root) exit(0) + AddOption('--pyconfig', + dest = 'pyconfig', + action = 'store_true', + default = False, + help = 'make menuconfig for RT-Thread BSP') + if GetOption('pyconfig'): + from menuconfig import pyconfig + pyconfig(Rtt_Root) + exit(0) + configfn = GetOption('useconfig') if configfn: from menuconfig import mk_rtconfig diff --git a/tools/kconfiglib.py b/tools/kconfiglib.py new file mode 100644 index 0000000000..098f5883f1 --- /dev/null +++ b/tools/kconfiglib.py @@ -0,0 +1,6159 @@ +# Copyright (c) 2011-2018, Ulf Magnusson +# SPDX-License-Identifier: ISC + +""" +Overview +======== + +Kconfiglib is a Python 2/3 library for scripting and extracting information +from Kconfig (https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt) +configuration systems. + +See the homepage at https://github.com/ulfalizer/Kconfiglib for a longer +overview. + +Using Kconfiglib on the Linux kernel with the Makefile targets +============================================================== + +For the Linux kernel, a handy interface is provided by the +scripts/kconfig/Makefile patch, which can be applied with either 'git am' or +the 'patch' utility: + + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | git am + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | patch -p1 + +Warning: Not passing -p1 to patch will cause the wrong file to be patched. + +Please tell me if the patch does not apply. It should be trivial to apply +manually, as it's just a block of text that needs to be inserted near the other +*conf: targets in scripts/kconfig/Makefile. + +Look further down for a motivation for the Makefile patch and for instructions +on how you can use Kconfiglib without it. + +If you do not wish to install Kconfiglib via pip, the Makefile patch is set up +so that you can also just clone Kconfiglib into the kernel root: + + $ git clone git://github.com/ulfalizer/Kconfiglib.git + $ git am Kconfiglib/makefile.patch (or 'patch -p1 < Kconfiglib/makefile.patch') + +Warning: The directory name Kconfiglib/ is significant in this case, because +it's added to PYTHONPATH by the new targets in makefile.patch. + +The targets added by the Makefile patch are described in the following +sections. + + +make [ARCH=] iscriptconfig +-------------------------------- + +This target gives an interactive Python prompt where a Kconfig instance has +been preloaded and is available in 'kconf'. To change the Python interpreter +used, pass PYTHONCMD= to make. The default is "python". + +To get a feel for the API, try evaluating and printing the symbols in +kconf.defined_syms, and explore the MenuNode menu tree starting at +kconf.top_node by following 'next' and 'list' pointers. + +The item contained in a menu node is found in MenuNode.item (note that this can +be one of the constants kconfiglib.MENU and kconfiglib.COMMENT), and all +symbols and choices have a 'nodes' attribute containing their menu nodes +(usually only one). Printing a menu node will print its item, in Kconfig +format. + +If you want to look up a symbol by name, use the kconf.syms dictionary. + + +make scriptconfig SCRIPT=