[tool] 增加scons --dist --project-path=xxxx命令 (#6713)

* [tools] 所有dist都打zip包

* 完善scons --dist/dist-ide --project-name  --project-path命令
This commit is contained in:
Man, Jianting (Meco) 2022-12-19 01:12:08 -05:00 committed by GitHub
parent 0df51b8aa9
commit 8c7e0b71ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 59 deletions

View File

@ -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

View File

@ -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()

View File

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

View File

@ -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!')

View File

@ -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',

View File

@ -29,7 +29,6 @@ import os
import json
import utils
import rtconfig
import rtconfig
from utils import _make_path_relative