From 883cbc416e96d542856eef18dad92804bc9cd6d7 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Mon, 21 Sep 2020 11:37:23 +0200 Subject: [PATCH] tools: Use kconfiglib from package --- .flake8 | 3 - .gitlab-ci.yml | 2 +- docs/en/COPYRIGHT.rst | 5 - .../api-guides/linker-script-generation.rst | 2 +- .../api-guides/linker-script-generation.rst | 4 +- requirements.txt | 1 + tools/cmake/kconfig.cmake | 1 - tools/kconfig_new/README.md | 2 +- tools/kconfig_new/confgen.py | 9 +- tools/kconfig_new/confserver.py | 8 +- tools/kconfig_new/gen_kconfig_doc.py | 9 +- tools/kconfig_new/kconfiglib.py | 7153 ----------------- tools/kconfig_new/menuconfig.py | 3304 +------- .../gen_kconfig_doc/test_target_visibility.py | 8 +- tools/ldgen/sdkconfig.py | 11 +- 15 files changed, 46 insertions(+), 10476 deletions(-) delete mode 100644 tools/kconfig_new/kconfiglib.py diff --git a/.flake8 b/.flake8 index 9a4690697f..18f7ddd768 100644 --- a/.flake8 +++ b/.flake8 @@ -152,9 +152,6 @@ exclude = components/unity/unity, examples/build_system/cmake/import_lib/main/lib/tinyxml2, examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib, - # other third-party libraries - tools/kconfig_new/kconfiglib.py, - tools/kconfig_new/menuconfig.py, # autogenerated scripts components/protocomm/python/constants_pb2.py, components/protocomm/python/sec0_pb2.py, diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb596d7b37..8549c1ecd2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,7 @@ variables: CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/tools/ci/config/target-test.yml" # Versioned esp-idf-doc env image to use for all document building jobs - ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v6" + ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v7" # before each job, we need to check if this job is filtered by bot stage/job filter diff --git a/docs/en/COPYRIGHT.rst b/docs/en/COPYRIGHT.rst index 3cbd5844cd..67c5987104 100644 --- a/docs/en/COPYRIGHT.rst +++ b/docs/en/COPYRIGHT.rst @@ -74,11 +74,6 @@ This is the list of licenses for tools included in this repository, which are us * :idf:`KConfig ` is Copyright (C) 2002 Roman Zippel and others, and is licensed under the GNU General Public License V2. -* :idf_file:`Kconfiglib ` is Copyright (C) 2011-2019, Ulf Magnusson, and is licensed under the ISC License. - -* :idf_file:`Menuconfig of Kconfiglib ` is Copyright (C) 2018-2019, Nordic Semiconductor ASA and Ulf Magnusson, and is licensed under the ISC License. - - Documentation ------------- diff --git a/docs/en/api-guides/linker-script-generation.rst b/docs/en/api-guides/linker-script-generation.rst index d2869fb6c1..2c1f2c3b32 100644 --- a/docs/en/api-guides/linker-script-generation.rst +++ b/docs/en/api-guides/linker-script-generation.rst @@ -276,7 +276,7 @@ The three fragment types share a common grammar: **Condition Checking** Condition checking enable the linker script generation to be configuration-aware. Depending on whether expressions involving configuration values -are true or not, a particular set of values for a key can be used. The evaluation uses ``eval_string`` from :idf_file:`tools/kconfig_new/kconfiglib.py` +are true or not, a particular set of values for a key can be used. The evaluation uses ``eval_string`` from kconfiglib package and adheres to its required syntax and limitations. Supported operators are as follows: - comparison diff --git a/docs/zh_CN/api-guides/linker-script-generation.rst b/docs/zh_CN/api-guides/linker-script-generation.rst index afbb0d14c9..343517ea2d 100644 --- a/docs/zh_CN/api-guides/linker-script-generation.rst +++ b/docs/zh_CN/api-guides/linker-script-generation.rst @@ -244,7 +244,7 @@ CMake **条件检查** -条件检查使得链接脚本生成机制可以感知配置。含有配置值的表达式是否为真,决定了使用哪些特定键值。检查使用的是 :idf_file:`tools/kconfig_new/kconfiglib.py` 脚本的 ``eval_string``,遵循该脚本要求的语法和局限性,支持: +条件检查使得链接脚本生成机制可以感知配置。含有配置值的表达式是否为真,决定了使用哪些特定键值。检查使用的是 kconfiglib 脚本的 ``eval_string``,遵循该脚本要求的语法和局限性,支持: - 比较 - 小于 ``<`` @@ -538,4 +538,4 @@ ESP-IDF v4.0 变更了链接脚本片段文件使用的一些语法: 这是根据默认协议条目 ``iram -> iram0_text`` 生成的规则。默认协议指定了 ``iram -> iram0_text`` 条目,因此生成的规则同样也放在被 ``iram0_text`` 标记的地方。由于该规则是根据默认协议生成的,因此在同一目标下收集的所有规则下排在第一位。 目前使用的链接脚本模板是 :component_file:`{IDF_TARGET_PATH_NAME}/ld/{IDF_TARGET_PATH_NAME}.project.ld.in`,由 ``{IDF_TARGET_PATH_NAME}`` 组件指定,生成的脚本存放在构建目录下。 - \ No newline at end of file + diff --git a/requirements.txt b/requirements.txt index 574a5272a8..4b07c671b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,7 @@ pygdbmi<=0.9.0.2 # The pygdbmi required max version 0.9.0.2 since 0.9.0.3 is not copatible with latest gdbgui (>=0.13.2.0) reedsolo>=1.5.3,<=1.5.4 bitstring>=3.1.6 +kconfiglib==13.7.1 # windows-curses are required in Windows command line but cannot be installed in MSYS2. A requirement like # "windows-curses; sys_platform == 'win32'" would want to install the package on both of them. There is no environment diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index 8db65bdbf4..2862a539a9 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -239,7 +239,6 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) # Or if the config generation tool changes set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${idf_path}/tools/kconfig_new/confgen.py") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${idf_path}/tools/kconfig_new/kconfiglib.py") set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${sdkconfig_header}" "${sdkconfig_cmake}") diff --git a/tools/kconfig_new/README.md b/tools/kconfig_new/README.md index ce597c07ac..d278ad0775 100644 --- a/tools/kconfig_new/README.md +++ b/tools/kconfig_new/README.md @@ -2,7 +2,7 @@ kconfig_new is the kconfig support used by the CMake-based build system. -It uses a fork of [kconfiglib](https://github.com/ulfalizer/Kconfiglib) which adds a few small features (newer upstream kconfiglib also has the support we need, we just haven't updated yet). See comments at top of kconfiglib.py for details +It depends on the [kconfiglib](https://github.com/ulfalizer/Kconfiglib) package. ## confserver.py diff --git a/tools/kconfig_new/confgen.py b/tools/kconfig_new/confgen.py index e757d1d4f1..d03d76fb38 100755 --- a/tools/kconfig_new/confgen.py +++ b/tools/kconfig_new/confgen.py @@ -21,23 +21,18 @@ # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function +from future.utils import iteritems import argparse import json +import kconfiglib import os import os.path import re import sys import tempfile -from future.utils import iteritems import gen_kconfig_doc -try: - from . import kconfiglib -except Exception: - sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) - import kconfiglib - __version__ = "0.1" if "IDF_CMAKE" not in os.environ: diff --git a/tools/kconfig_new/confserver.py b/tools/kconfig_new/confserver.py index f8694a9338..b84a3d0d41 100755 --- a/tools/kconfig_new/confserver.py +++ b/tools/kconfig_new/confserver.py @@ -7,16 +7,12 @@ from __future__ import print_function import argparse import confgen import json +import kconfiglib import os import sys import tempfile -from confgen import FatalError, __version__ -try: - from . import kconfiglib -except Exception: - sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) - import kconfiglib +from confgen import FatalError, __version__ # Min/Max supported protocol versions MIN_PROTOCOL_VERSION = 1 diff --git a/tools/kconfig_new/gen_kconfig_doc.py b/tools/kconfig_new/gen_kconfig_doc.py index 9b614794c1..df1920e022 100644 --- a/tools/kconfig_new/gen_kconfig_doc.py +++ b/tools/kconfig_new/gen_kconfig_doc.py @@ -21,15 +21,8 @@ # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function -import os import re -import sys - -try: - from . import kconfiglib -except Exception: - sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) - import kconfiglib +import kconfiglib # Indentation to be used in the generated file INDENT = ' ' diff --git a/tools/kconfig_new/kconfiglib.py b/tools/kconfig_new/kconfiglib.py deleted file mode 100644 index c0a5b2ab69..0000000000 --- a/tools/kconfig_new/kconfiglib.py +++ /dev/null @@ -1,7153 +0,0 @@ -# Copyright (c) 2011-2019, 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. - -Since Kconfiglib 12.0.0, the library version is available in -kconfiglib.VERSION, which is a (, , ) tuple, e.g. -(12, 0, 0). - - -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 kmenuconfig ----------------- - -This target runs the curses menuconfig interface with Python 3. As of -Kconfiglib 12.2.0, both Python 2 and Python 3 are supported (previously, only -Python 3 was supported, so this was a backport). - - -make guiconfig --------------- - -This target runs the Tkinter menuconfig interface. Both Python 2 and Python 3 -are supported. To change the Python interpreter used, pass -PYTHONCMD= to 'make'. The default is 'python'. - - -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=