From 70f94c84a62fd6c75322314f22d98f38403dc84c Mon Sep 17 00:00:00 2001 From: latercomer Date: Sun, 7 Apr 2024 10:31:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86menuconfig.py=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E4=B8=BAmenukconfig.py=E4=BB=A5=E9=98=B2=E9=87=8D?= =?UTF-8?q?=E5=90=8D=EF=BC=8C=E8=A7=A3=E5=86=B3=E4=BA=86ci=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=E6=97=A0=E6=B3=95=E6=89=BE=E5=88=B0kconfigli?= =?UTF-8?q?b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/bsp_buildings.yml | 3 +- .../workflows/compile_bsp_with_drivers.yml | 3 +- .github/workflows/manual_dist.yml | 3 +- .../manual_trigger_scons_STM32_all.yml | 3 +- .../manual_trigger_scons_except_STM32_all.yml | 3 +- .../manual_trigger_scons_fail_bsp_all.yml | 3 +- tools/Kconfiglib/__init__.py | 0 tools/building.py | 28 +++++++------- tools/genconfig.py | 32 ---------------- tools/{menuconfig.py => menukconfig.py} | 38 +++++++++++++++++-- 10 files changed, 61 insertions(+), 55 deletions(-) delete mode 100644 tools/Kconfiglib/__init__.py delete mode 100644 tools/genconfig.py rename tools/{menuconfig.py => menukconfig.py} (93%) diff --git a/.github/workflows/bsp_buildings.yml b/.github/workflows/bsp_buildings.yml index 3bdc0c76506..9f197bb2b5d 100644 --- a/.github/workflows/bsp_buildings.yml +++ b/.github/workflows/bsp_buildings.yml @@ -348,7 +348,8 @@ jobs: chmod 777 install_ubuntu.sh ./install_ubuntu.sh git config --global http.postBuffer 524288000 - python -c "import tools.menuconfig; tools.menuconfig.touch_env()" + python -m pip install windows-curses + python -c "import tools.menukconfig; tools.menukconfig.touch_env()" echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV diff --git a/.github/workflows/compile_bsp_with_drivers.yml b/.github/workflows/compile_bsp_with_drivers.yml index 634eab49bb0..eb0480ffe6d 100644 --- a/.github/workflows/compile_bsp_with_drivers.yml +++ b/.github/workflows/compile_bsp_with_drivers.yml @@ -52,7 +52,8 @@ jobs: git config --global http.postBuffer 524288000 git remote -v git fetch origin - python -c "import tools.menuconfig; tools.menuconfig.touch_env()" + python -m pip install windows-curses + python -c "import tools.menukconfig; tools.menukconfig.touch_env()" - name: Install Arm ToolChains if: ${{ success() }} diff --git a/.github/workflows/manual_dist.yml b/.github/workflows/manual_dist.yml index b3ec3e80bb6..406aefa35f0 100644 --- a/.github/workflows/manual_dist.yml +++ b/.github/workflows/manual_dist.yml @@ -66,7 +66,8 @@ jobs: chmod 777 install_ubuntu.sh ./install_ubuntu.sh git config --global http.postBuffer 524288000 - python -c "import tools.menuconfig; tools.menuconfig.touch_env()" + python -m pip install windows-curses + python -c "import tools.menukconfig; tools.menukconfig.touch_env()" echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV diff --git a/.github/workflows/manual_trigger_scons_STM32_all.yml b/.github/workflows/manual_trigger_scons_STM32_all.yml index ee99da365de..8bd628b6bf6 100644 --- a/.github/workflows/manual_trigger_scons_STM32_all.yml +++ b/.github/workflows/manual_trigger_scons_STM32_all.yml @@ -141,7 +141,8 @@ jobs: chmod 777 install_ubuntu.sh ./install_ubuntu.sh git config --global http.postBuffer 524288000 - python -c "import tools.menuconfig; tools.menuconfig.touch_env()" + python -m pip install windows-curses + python -c "import tools.menukconfig; tools.menukconfig.touch_env()" echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV diff --git a/.github/workflows/manual_trigger_scons_except_STM32_all.yml b/.github/workflows/manual_trigger_scons_except_STM32_all.yml index 7658f948c0a..5b15197e92b 100644 --- a/.github/workflows/manual_trigger_scons_except_STM32_all.yml +++ b/.github/workflows/manual_trigger_scons_except_STM32_all.yml @@ -284,7 +284,8 @@ jobs: chmod 777 install_ubuntu.sh ./install_ubuntu.sh git config --global http.postBuffer 524288000 - python -c "import tools.menuconfig; tools.menuconfig.touch_env()" + python -m pip install windows-curses + python -c "import tools.menukconfig; tools.menukconfig.touch_env()" echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV diff --git a/.github/workflows/manual_trigger_scons_fail_bsp_all.yml b/.github/workflows/manual_trigger_scons_fail_bsp_all.yml index 8ad5188b239..d563975fe20 100644 --- a/.github/workflows/manual_trigger_scons_fail_bsp_all.yml +++ b/.github/workflows/manual_trigger_scons_fail_bsp_all.yml @@ -116,7 +116,8 @@ jobs: chmod 777 install_ubuntu.sh ./install_ubuntu.sh git config --global http.postBuffer 524288000 - python -c "import tools.menuconfig; tools.menuconfig.touch_env()" + python -m pip install windows-curses + python -c "import tools.menukconfig; tools.menukconfig.touch_env()" echo "RTT_ROOT=${{ github.workspace }}" >> $GITHUB_ENV echo "RTT_CC=gcc" >> $GITHUB_ENV diff --git a/tools/Kconfiglib/__init__.py b/tools/Kconfiglib/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/building.py b/tools/building.py index 2726c118fdd..a032aef822d 100644 --- a/tools/building.py +++ b/tools/building.py @@ -128,14 +128,6 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ global Env global Rtt_Root - os.environ["RTT_DIR"] = root_directory - os.environ["BSP_DIR"] = os.getcwd() - if not "PKGS_DIR" in os.environ: - if "ENV_ROOT" in os.environ: - os.environ["PKGS_DIR"] = os.path.join(os.environ["ENV_ROOT"], "packages") - else: - os.environ["PKGS_DIR"] = os.path.join(os.getcwd(), "packages") - AddOptions() Env = env @@ -147,10 +139,18 @@ 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 not "PKGS_DIR" in os.environ: + if "ENV_ROOT" in os.environ: + os.environ["PKGS_DIR"] = os.path.join(os.environ["ENV_ROOT"], "packages") + else: + os.environ["PKGS_DIR"] = os.path.join(Dir('#').abspath, "packages") - sys.path = sys.path + [os.path.join(Rtt_Root, 'tools')] + sys.path = sys.path + [os.path.join(Rtt_Root, 'tools'), os.path.join(Rtt_Root, 'tools/kconfiglib')] # {target_name:(CROSS_TOOL, PLATFORM)} tgt_dict = {'mdk':('keil', 'armcc'), @@ -311,7 +311,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ print('--global-macros arguments are illegal!') if GetOption('genconfig'): - from genconfig import genconfig + from menukconfig import genconfig genconfig() exit(0) @@ -321,23 +321,23 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ exit(0) if GetOption('menuconfig'): - from menuconfig import menuconfig + from menukconfig import menuconfig menuconfig(Rtt_Root) exit(0) if GetOption('pyconfig-silent'): - from menuconfig import guiconfig_silent + from menukconfig import guiconfig_silent guiconfig_silent(Rtt_Root) exit(0) elif GetOption('pyconfig'): - from menuconfig import guiconfig + from menukconfig import guiconfig guiconfig(Rtt_Root) exit(0) configfn = GetOption('useconfig') if configfn: - from menuconfig import mk_rtconfig + from menukconfig import mk_rtconfig mk_rtconfig(configfn) exit(0) diff --git a/tools/genconfig.py b/tools/genconfig.py deleted file mode 100644 index d033c4007d6..00000000000 --- a/tools/genconfig.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/menuconfig.py b/tools/menukconfig.py similarity index 93% rename from tools/menuconfig.py rename to tools/menukconfig.py index 40707553730..d31c9dc1739 100644 --- a/tools/menuconfig.py +++ b/tools/menukconfig.py @@ -245,7 +245,7 @@ def exclude_utestcases(RTT_ROOT): # menuconfig for Linux and Windows def menuconfig(RTT_ROOT): - from Kconfiglib import menuconfig + import menuconfig # Exclude utestcases exclude_utestcases(RTT_ROOT) @@ -278,7 +278,7 @@ def menuconfig(RTT_ROOT): # guiconfig for windows and linux def guiconfig(RTT_ROOT): - from Kconfiglib import guiconfig + import guiconfig # Exclude utestcases exclude_utestcases(RTT_ROOT) @@ -312,7 +312,7 @@ def guiconfig(RTT_ROOT): # guiconfig for windows and linux def guiconfig_silent(RTT_ROOT): - from Kconfiglib import defconfig + import defconfig # Exclude utestcases exclude_utestcases(RTT_ROOT) @@ -331,3 +331,35 @@ def guiconfig_silent(RTT_ROOT): # silent mode, force to make rtconfig.h mk_rtconfig(fn) + + +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.")