Skip to content

Commit

Permalink
将menuconfig.py重命名为menukconfig.py以防重名,解决了ci环境下无法找到kconfiglib
Browse files Browse the repository at this point in the history
  • Loading branch information
ComerLater committed Apr 7, 2024
1 parent 4cc8e1e commit 70f94c8
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/bsp_buildings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/compile_bsp_with_drivers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/manual_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/manual_trigger_scons_STM32_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/manual_trigger_scons_except_STM32_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/manual_trigger_scons_fail_bsp_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file removed tools/Kconfiglib/__init__.py
Empty file.
28 changes: 14 additions & 14 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'),
Expand Down Expand Up @@ -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)

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

Expand Down
32 changes: 0 additions & 32 deletions tools/genconfig.py

This file was deleted.

38 changes: 35 additions & 3 deletions tools/menuconfig.py → tools/menukconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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.")

0 comments on commit 70f94c8

Please sign in to comment.