Skip to content

Commit 195a17b

Browse files
authored
Merge pull request #79 from SummerGGift/master
【完善】:错误提示信息
2 parents b487c88 + 9c87057 commit 195a17b

File tree

2 files changed

+30
-37
lines changed

2 files changed

+30
-37
lines changed

cmds/cmd_menuconfig.py

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,36 +153,26 @@ def find_macro_in_config(filename, macro_name):
153153

154154
def cmd(args):
155155

156-
from cmd_package import determine_support_chinese
157156
env_root = Import('env_root')
158-
currentdir = os.getcwd()
159-
dirname = os.path.split(os.path.split(currentdir)[0])[0]
160-
get_rtt_name = os.path.basename(dirname)
161157
os_version = platform.platform(True)[10:13]
162158
kconfig_win7_path = os.path.join(
163159
env_root, 'tools', 'bin', 'kconfig-mconf_win7.exe')
164160

165-
if not os.getenv("RTT_ROOT"):
166-
if get_rtt_name != 'rt-thread':
167-
if determine_support_chinese(env_root):
168-
print("\n<menuconfig> 命令应当在某一特定 BSP 目录下执行,例如:\"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
169-
print("请确保当前目录为 BSP 根目录,并且该目录中有 Kconfig 文件。\n")
161+
if not os.path.exists('Kconfig'):
162+
if platform.system() == "Windows":
163+
os.system('chcp 65001 > nul')
170164

171-
print ("<menuconfig> command should be used in a bsp root path with a Kconfig file.")
172-
print ("Example: \"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
173-
print ("You should check if there is a Kconfig file in your bsp root first.")
165+
print("\n<menuconfig> 命令应当在某一特定 BSP 目录下执行,例如:\"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
166+
print("请确保当前目录为 BSP 根目录,并且该目录中有 Kconfig 文件。\n")
174167

175-
print ('\nconfig $RTT_DIR')
176-
print ('string')
177-
print ('option env="RTT_ROOT"')
178-
print ('default "../.."\n')
168+
print ("<menuconfig> command should be used in a bsp root path with a Kconfig file.")
169+
print ("Example: \"rt-thread/bsp/stm32/stm32f091-st-nucleo\"")
170+
print ("You should check if there is a Kconfig file in your bsp root first.")
179171

180-
if determine_support_chinese(env_root):
181-
print ('例如修改 default 这一项为 rt-thread 所在路径: default "F:/git_repositories/rt-thread"')
182-
print ('\n下面的警告信息提示与找不到正确的 Kconfig 文件有关:')
172+
if platform.system() == "Windows":
173+
os.system('chcp 437 > nul')
183174

184-
# if not args.menuconfig_easy:
185-
# return
175+
return False
186176

187177
fn = '.config'
188178

@@ -224,10 +214,7 @@ def cmd(args):
224214
os.system('kconfig-mconf Kconfig')
225215

226216
os.chdir(beforepath)
227-
228-
if determine_support_chinese(env_root):
229-
if platform.system() == "Windows":
230-
os.system('chcp 65001 > nul')
217+
231218
return
232219

233220
else:
@@ -247,10 +234,6 @@ def cmd(args):
247234
if mtime != mtime2:
248235
mk_rtconfig(fn)
249236

250-
if determine_support_chinese(env_root):
251-
if platform.system() == "Windows":
252-
os.system('chcp 65001 > nul')
253-
254237
if platform.system() == "Windows":
255238
env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds')
256239
fn = os.path.join(env_kconfig_path, '.config')

cmds/cmd_package.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,18 @@ def package_list():
356356
env_root = Import('env_root')
357357

358358
if not os.path.isfile(fn):
359+
if platform.system() == "Windows":
360+
os.system('chcp 65001 > nul')
359361

360-
if determine_support_chinese(env_root):
361-
print ("\n当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。")
362-
print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n")
362+
print ("\n当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。")
363+
print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n")
363364

364-
print ('No system configuration file : .config.')
365+
print ('\nNo system configuration file : .config.')
365366
print ('You should use < menuconfig > command to config bsp first.')
367+
368+
if platform.system() == "Windows":
369+
os.system('chcp 437 > nul')
370+
366371
return
367372

368373
pkgs = kconfig.parse(fn)
@@ -510,15 +515,20 @@ def pre_package_update():
510515

511516
bsp_root = Import('bsp_root')
512517
env_root = Import('env_root')
513-
from cmd_package import determine_support_chinese
514518

515519
if not os.path.exists('.config'):
516-
if determine_support_chinese(env_root):
517-
print ("\n当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。")
518-
print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n")
520+
if platform.system() == "Windows":
521+
os.system('chcp 65001 > nul')
522+
523+
print ("\n当前路径下没有发现 .config 文件,请确保当前目录为 BSP 根目录。")
524+
print ("如果确定当前目录为 BSP 根目录,请先使用 <menuconfig> 命令来生成 .config 文件。\n")
519525

520526
print ('No system configuration file : .config.')
521527
print ('You should use < menuconfig > command to config bsp first.')
528+
529+
if platform.system() == "Windows":
530+
os.system('chcp 437 > nul')
531+
522532
return False
523533

524534
bsp_packages_path = os.path.join(bsp_root, 'packages')

0 commit comments

Comments
 (0)