diff --git a/tools/building.py b/tools/building.py index a8a24868ac..ed9f77876e 100644 --- a/tools/building.py +++ b/tools/building.py @@ -899,6 +899,7 @@ def GenTargetProject(program = None): ESPIDFProject(Env, Projects) def EndBuilding(target, program = None): + from mkdist import MkDist, MkDist_Strip need_exit = False @@ -923,24 +924,22 @@ def EndBuilding(target, program = None): need_exit = True BSP_ROOT = Dir('#').abspath + + project_name = GetOption('project-name') + project_path = GetOption('project-path') if GetOption('make-dist') and program != None: - from mkdist import MkDist - MkDist(program, BSP_ROOT, Rtt_Root, Env) + MkDist(program, BSP_ROOT, Rtt_Root, Env, project_name, project_path) + need_exit = True if GetOption('make-dist-strip') and program != None: - from mkdist import MkDist_Strip MkDist_Strip(program, BSP_ROOT, Rtt_Root, Env) need_exit = True if GetOption('make-dist-ide') and program != None: - from mkdist import MkDist - project_path = GetOption('project-path') - project_name = GetOption('project-name') - + import subprocess if not isinstance(project_path, str) or len(project_path) == 0 : - project_path = os.path.join(BSP_ROOT, 'rt-studio-project', project_name) - print("\nwarning : --project-path not specified, use default path: {0}.".format(project_path)) - - rtt_ide = {'project_path' : project_path, 'project_name' : project_name} - MkDist(program, BSP_ROOT, Rtt_Root, Env, rtt_ide) + project_path = os.path.join(BSP_ROOT, 'rt-studio-project') + MkDist(program, BSP_ROOT, Rtt_Root, Env, project_name, project_path) + child = subprocess.Popen('scons --target=eclipse --project-name=' + project_name, cwd=project_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + stdout, stderr = child.communicate() need_exit = True if GetOption('cscope'): from cscope import CscopeDatabase diff --git a/tools/iar.py b/tools/iar.py index 1b38b1e21e..fc2bc44f91 100644 --- a/tools/iar.py +++ b/tools/iar.py @@ -195,8 +195,7 @@ def IARVersion(): if os.path.exists(path): cmd = os.path.join(path, 'iccarm.exe') else: - print('Error: get IAR version failed. Please update the IAR installation path in rtconfig.py!') - exit(-1) + return "0.0" child = subprocess.Popen([cmd, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) stdout, stderr = child.communicate() diff --git a/tools/keil.py b/tools/keil.py index 0405eb0b1b..50d40e83e5 100644 --- a/tools/keil.py +++ b/tools/keil.py @@ -433,7 +433,6 @@ def ARMCC_Version(): if os.path.exists(path): cmd = path else: - print('Error: get armcc version failed. Please update the KEIL MDK installation path in rtconfig.py!') return "0.0" child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) @@ -447,7 +446,8 @@ def ARMCC_Version(): return version: MDK Plus 5.24/ARM Compiler 5.06 update 5 (build 528)/armcc [4d3621] ''' - + if not isinstance(stdout, str): + stdout = str(stdout, 'utf8') # Patch for Python 3 version_Product = re.search(r'Product: (.+)', stdout).group(1) version_Product = version_Product[:-1] version_Component = re.search(r'Component: (.*)', stdout).group(1) diff --git a/tools/mkdist.py b/tools/mkdist.py index f0a59cbd17..e8e5796c02 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -166,31 +166,6 @@ def bsp_update_kconfig_library(dist_dir): line = line[0:position] + 'libraries/HAL_Drivers/Kconfig"\n' f.write(line) -def bs_update_ide_project(bsp_root, rtt_root, rttide = None): - import subprocess - # default update the projects which have template file - - if rttide == None: - tgt_dict = {'mdk4':('keil', 'armcc'), - 'mdk5':('keil', 'armcc'), - 'iar':('iar', 'iccarm'), - 'vs':('msvc', 'cl'), - 'vs2012':('msvc', 'cl'), - 'cdk':('gcc', 'gcc'), - 'eclipse':('eclipse', 'gcc')} - else: - item = 'eclipse --project-name=' + rttide['project_name'] - tgt_dict = {item:('gcc', 'gcc')} - - scons_env = os.environ.copy() - scons_env['RTT_ROOT'] = rtt_root - - for item in tgt_dict: - child = subprocess.Popen('scons --target=' + item, cwd=bsp_root, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - stdout, stderr = child.communicate() - if child.returncode == 0: - print('update %s project' % item) - def zip_dist(dist_dir, dist_name): import zipfile @@ -328,23 +303,18 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): bsp_update_kconfig_library(dist_dir) # delete testcases in Kconfig bsp_update_kconfig_testcases(dist_dir) - # update all project files - bs_update_ide_project(dist_dir, target_path) - # make zip package zip_dist(dist_dir, dist_name) print('done!') -def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): +def MkDist(program, BSP_ROOT, RTT_ROOT, Env, project_name, project_path): print('make distribution....') - dist_name = os.path.basename(BSP_ROOT) - - if rttide == None: - dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name) + if project_path == None: + dist_dir = os.path.join(BSP_ROOT, 'dist', project_name) else: - dist_dir = rttide['project_path'] + dist_dir = project_path target_path = os.path.join(dist_dir, 'rt-thread') @@ -398,15 +368,10 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): bsp_update_kconfig_library(dist_dir) # delete testcases in Kconfig bsp_update_kconfig_testcases(dist_dir) - # update all project files - if rttide == None: - bs_update_ide_project(dist_dir, target_path) - else: - bs_update_ide_project(dist_dir, target_path, rttide) # make zip package - if rttide == None: - zip_dist(dist_dir, dist_name) + if project_path == None: + zip_dist(dist_dir, project_name) print('done!') diff --git a/tools/options.py b/tools/options.py index 076f648ef8..6f6c588f21 100644 --- a/tools/options.py +++ b/tools/options.py @@ -47,7 +47,7 @@ def AddOptions(): dest = 'project-path', type = 'string', default = None, - help = 'set dist-ide project output path') + help = 'set project output path') AddOption('--project-name', dest = 'project-name', type = 'string', diff --git a/tools/vsc.py b/tools/vsc.py index 5eed941bc8..29ee8a91f7 100644 --- a/tools/vsc.py +++ b/tools/vsc.py @@ -29,7 +29,6 @@ import os import json import utils import rtconfig -import rtconfig from utils import _make_path_relative