Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IAR、Keil工程在自动更新时使用scons --exec-path命令设置工具链安装位置 #181

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions cmds/cmd_menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
10 changes: 0 additions & 10 deletions cmds/cmd_package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
5 changes: 3 additions & 2 deletions cmds/cmd_package/cmd_package_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand Down