From bc30ca4743ccca4e36feb5711c980f46f21526fe Mon Sep 17 00:00:00 2001 From: zhkag Date: Sun, 8 Oct 2023 09:59:24 +0800 Subject: [PATCH 1/3] Fix the deque issue for Env['CPPDEFINES'] --- tools/building.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/building.py b/tools/building.py index 91c6d05c992..f6566a84eb4 100644 --- a/tools/building.py +++ b/tools/building.py @@ -733,8 +733,8 @@ def local_group(group, objects): CFLAGS = Env.get('CFLAGS', '') + group.get('LOCAL_CFLAGS', '') CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '') CXXFLAGS = Env.get('CXXFLAGS', '') + group.get('LOCAL_CXXFLAGS', '') - CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', ['']) - CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', ['']) + CPPPATH = list(Env.get('CPPPATH', [''])) + group.get('LOCAL_CPPPATH', ['']) + CPPDEFINES = list(Env.get('CPPDEFINES', [''])) + group.get('LOCAL_CPPDEFINES', ['']) ASFLAGS = Env.get('ASFLAGS', '') + group.get('LOCAL_ASFLAGS', '') for source in group['src']: From 5cf711488ce68a4d6f0bc54a0d52b8d886e85505 Mon Sep 17 00:00:00 2001 From: latercomer Date: Thu, 27 Jun 2024 21:38:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86kconfiglib?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81=EF=BC=8C=E5=B9=B6=E5=85=BC=E5=AE=B9?= =?UTF-8?q?env-windows=20v2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/building.py | 37 +- tools/defconfig.py | 43 - tools/genconf.py | 32 - tools/kconfiglib.py | 7024 ------------------------------------------ tools/menuconfig.py | 51 +- tools/options.py | 15 +- tools/pyguiconfig.py | 2314 -------------- tools/utils.py | 12 + 8 files changed, 82 insertions(+), 9446 deletions(-) delete mode 100644 tools/defconfig.py delete mode 100644 tools/genconf.py delete mode 100644 tools/kconfiglib.py delete mode 100644 tools/pyguiconfig.py diff --git a/tools/building.py b/tools/building.py index f6566a84eb4..4d813ca3b92 100644 --- a/tools/building.py +++ b/tools/building.py @@ -164,8 +164,21 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ # set RTT_ROOT in ENV Env['RTT_ROOT'] = Rtt_Root + os.environ["RTT_DIR"] = Rtt_Root # set BSP_ROOT in ENV Env['BSP_ROOT'] = Dir('#').abspath + os.environ["BSP_DIR"] = Dir('#').abspath + # set PKGS_ROOT in ENV + if "PKGS_DIR" in os.environ: + pass + elif "PKGS_ROOT" in os.environ: + os.environ["PKGS_DIR"] = os.environ["PKGS_ROOT"] + elif "ENV_ROOT" in os.environ: + os.environ["PKGS_DIR"] = os.path.join(os.environ["ENV_ROOT"], "packages") + elif sys.platform == "win32": + os.environ["PKGS_DIR"] = os.path.join(os.environ["USERPROFILE"], ".env", "packages") + else: + os.environ["PKGS_DIR"] = os.path.join(os.environ["HOME"], ".env", "packages") sys.path = sys.path + [os.path.join(Rtt_Root, 'tools')] @@ -299,27 +312,25 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ from WCS import ThreadStackStaticAnalysis ThreadStackStaticAnalysis(Env) exit(0) - if platform.system() != 'Windows': - if GetOption('menuconfig'): - from menuconfig import menuconfig - menuconfig(Rtt_Root) - exit(0) - if GetOption('pyconfig_silent'): - from menuconfig import guiconfig_silent + if GetOption('menuconfig'): + menuconfig = utils.ImportModule('menuconfig') + menuconfig.menuconfig(Rtt_Root) + exit(0) - guiconfig_silent(Rtt_Root) + if GetOption('pyconfig_silent'): + menuconfig = utils.ImportModule('menuconfig') + menuconfig.guiconfig_silent(Rtt_Root) exit(0) elif GetOption('pyconfig'): - from menuconfig import guiconfig - - guiconfig(Rtt_Root) + menuconfig = utils.ImportModule('menuconfig') + menuconfig.guiconfig(Rtt_Root) exit(0) configfn = GetOption('useconfig') if configfn: - from menuconfig import mk_rtconfig - mk_rtconfig(configfn) + menuconfig = utils.ImportModule('menuconfig') + menuconfig.mk_rtconfig(configfn) exit(0) diff --git a/tools/defconfig.py b/tools/defconfig.py deleted file mode 100644 index d1b1e4ea739..00000000000 --- a/tools/defconfig.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/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() diff --git a/tools/genconf.py b/tools/genconf.py deleted file mode 100644 index d033c4007d6..00000000000 --- a/tools/genconf.py +++ /dev/null @@ -1,32 +0,0 @@ -import os - -def genconfig() : - from SCons.Script import SCons - - PreProcessor = SCons.cpp.PreProcessor() - - try: - f = open('rtconfig.h', 'r') - contents = f.read() - f.close() - except : - print("Open rtconfig.h file failed.") - - PreProcessor.process_contents(contents) - options = PreProcessor.cpp_namespace - - try: - f = open('.config', 'w') - for (opt, value) in options.items(): - if type(value) == type(1): - f.write("CONFIG_%s=%d\n" % (opt, value)) - - if type(value) == type('') and value == '': - f.write("CONFIG_%s=y\n" % opt) - elif type(value) == type('str'): - f.write("CONFIG_%s=%s\n" % (opt, value)) - - print("Generate .config done!") - f.close() - except: - print("Generate .config file failed.") diff --git a/tools/kconfiglib.py b/tools/kconfiglib.py deleted file mode 100644 index 9a9b2f03f78..00000000000 --- a/tools/kconfiglib.py +++ /dev/null @@ -1,7024 +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=