diff --git a/cmds/cmd_menuconfig.py b/cmds/cmd_menuconfig.py index c433464d..a679ffac 100644 --- a/cmds/cmd_menuconfig.py +++ b/cmds/cmd_menuconfig.py @@ -29,7 +29,7 @@ import platform import re from vars import Import -from .cmd_package.cmd_package_utils import find_bool_macro_in_config +from .cmd_package.cmd_package_utils import find_bool_macro_in_config, find_IAR_EXEC_PATH, find_MDK_EXEC_PATH def is_pkg_special_config(config_str): @@ -227,15 +227,27 @@ def cmd(args): print("==============================>The packages have been updated completely.") if find_bool_macro_in_config(fn, 'SYS_CREATE_MDK_IAR_PROJECT'): + mdk_path = find_MDK_EXEC_PATH() + iar_path = find_IAR_EXEC_PATH() + if find_bool_macro_in_config(fn, 'SYS_CREATE_MDK4'): - os.system('scons --target=mdk4 -s') - print("Create mdk4 project done") + if mdk_path: + os.system('scons --target=mdk4 -s --exec-path="' + mdk_path+'"') + else: + os.system('scons --target=mdk4 -s') + print("Create Keil-MDK4 project done") elif find_bool_macro_in_config(fn, 'SYS_CREATE_MDK5'): - os.system('scons --target=mdk5 -s') - print("Create mdk5 project done") + if mdk_path: + os.system('scons --target=mdk5 -s --exec-path="' + mdk_path+'"') + else: + os.system('scons --target=mdk5 -s') + print("Create Keil-MDK5 project done") elif find_bool_macro_in_config(fn, 'SYS_CREATE_IAR'): - os.system('scons --target=iar -s') - print("Create iar project done") + if iar_path: + os.system('scons --target=iar -s --exec-path="' + iar_path+'"') + else: + os.system('scons --target=iar -s') + print("Create IAR project done") def add_parser(sub): diff --git a/cmds/cmd_package/__init__.py b/cmds/cmd_package/__init__.py index 22bb2a17..78d005aa 100644 --- a/cmds/cmd_package/__init__.py +++ b/cmds/cmd_package/__init__.py @@ -26,21 +26,11 @@ # 2020-04-08 SummerGift Optimize program structure # -import os from .cmd_package_printenv import package_print_env, package_print_help from .cmd_package_list import list_packages from .cmd_package_wizard import package_wizard from .cmd_package_update import package_update from .cmd_package_upgrade import package_upgrade, package_upgrade_modules -from .cmd_package_utils import find_IAR_EXEC_PATH, find_MDK_EXEC_PATH - -iar_exec_path = find_IAR_EXEC_PATH() -if iar_exec_path: - os.environ['RTT_EXEC_PATH'] = iar_exec_path - -mdk_exec_path = find_MDK_EXEC_PATH() -if mdk_exec_path: - os.environ['RTT_EXEC_PATH'] = mdk_exec_path def run_env_cmd(args): """Run packages command.""" diff --git a/cmds/cmd_package/cmd_package_utils.py b/cmds/cmd_package/cmd_package_utils.py index 71534003..a26e052c 100644 --- a/cmds/cmd_package/cmd_package_utils.py +++ b/cmds/cmd_package/cmd_package_utils.py @@ -32,6 +32,7 @@ import shutil import requests import logging +from vars import Import def execute_command(cmd_string, cwd=None, shell=True): """Execute the system command at the specified address.""" @@ -219,7 +220,7 @@ def find_string_macro_in_config(filename, macro_name): # return IAR execution path string or None for failure def find_IAR_EXEC_PATH(): - env_root = os.getenv("ENV_ROOT") + env_root = Import('env_root') # get the .config file from env env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds') env_config_file = os.path.join(env_kconfig_path, '.config') @@ -229,7 +230,7 @@ def find_IAR_EXEC_PATH(): # return Keil-MDK execution path string or None for failure def find_MDK_EXEC_PATH(): - env_root = os.getenv("ENV_ROOT") + env_root = Import('env_root') # get the .config file from env env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds') env_config_file = os.path.join(env_kconfig_path, '.config')