[tool] 增加scons --dist --project-path=xxxx命令 (#6713)
* [tools] 所有dist都打zip包 * 完善scons --dist/dist-ide --project-name --project-path命令
This commit is contained in:
parent
0df51b8aa9
commit
8c7e0b71ce
@ -899,6 +899,7 @@ def GenTargetProject(program = None):
|
|||||||
ESPIDFProject(Env, Projects)
|
ESPIDFProject(Env, Projects)
|
||||||
|
|
||||||
def EndBuilding(target, program = None):
|
def EndBuilding(target, program = None):
|
||||||
|
from mkdist import MkDist, MkDist_Strip
|
||||||
|
|
||||||
need_exit = False
|
need_exit = False
|
||||||
|
|
||||||
@ -923,24 +924,22 @@ def EndBuilding(target, program = None):
|
|||||||
need_exit = True
|
need_exit = True
|
||||||
|
|
||||||
BSP_ROOT = Dir('#').abspath
|
BSP_ROOT = Dir('#').abspath
|
||||||
|
|
||||||
|
project_name = GetOption('project-name')
|
||||||
|
project_path = GetOption('project-path')
|
||||||
if GetOption('make-dist') and program != None:
|
if GetOption('make-dist') and program != None:
|
||||||
from mkdist import MkDist
|
MkDist(program, BSP_ROOT, Rtt_Root, Env, project_name, project_path)
|
||||||
MkDist(program, BSP_ROOT, Rtt_Root, Env)
|
need_exit = True
|
||||||
if GetOption('make-dist-strip') and program != None:
|
if GetOption('make-dist-strip') and program != None:
|
||||||
from mkdist import MkDist_Strip
|
|
||||||
MkDist_Strip(program, BSP_ROOT, Rtt_Root, Env)
|
MkDist_Strip(program, BSP_ROOT, Rtt_Root, Env)
|
||||||
need_exit = True
|
need_exit = True
|
||||||
if GetOption('make-dist-ide') and program != None:
|
if GetOption('make-dist-ide') and program != None:
|
||||||
from mkdist import MkDist
|
import subprocess
|
||||||
project_path = GetOption('project-path')
|
|
||||||
project_name = GetOption('project-name')
|
|
||||||
|
|
||||||
if not isinstance(project_path, str) or len(project_path) == 0 :
|
if not isinstance(project_path, str) or len(project_path) == 0 :
|
||||||
project_path = os.path.join(BSP_ROOT, 'rt-studio-project', project_name)
|
project_path = os.path.join(BSP_ROOT, 'rt-studio-project')
|
||||||
print("\nwarning : --project-path not specified, use default path: {0}.".format(project_path))
|
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)
|
||||||
rtt_ide = {'project_path' : project_path, 'project_name' : project_name}
|
stdout, stderr = child.communicate()
|
||||||
MkDist(program, BSP_ROOT, Rtt_Root, Env, rtt_ide)
|
|
||||||
need_exit = True
|
need_exit = True
|
||||||
if GetOption('cscope'):
|
if GetOption('cscope'):
|
||||||
from cscope import CscopeDatabase
|
from cscope import CscopeDatabase
|
||||||
|
@ -195,8 +195,7 @@ def IARVersion():
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
cmd = os.path.join(path, 'iccarm.exe')
|
cmd = os.path.join(path, 'iccarm.exe')
|
||||||
else:
|
else:
|
||||||
print('Error: get IAR version failed. Please update the IAR installation path in rtconfig.py!')
|
return "0.0"
|
||||||
exit(-1)
|
|
||||||
|
|
||||||
child = subprocess.Popen([cmd, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
child = subprocess.Popen([cmd, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||||
stdout, stderr = child.communicate()
|
stdout, stderr = child.communicate()
|
||||||
|
@ -433,7 +433,6 @@ def ARMCC_Version():
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
cmd = path
|
cmd = path
|
||||||
else:
|
else:
|
||||||
print('Error: get armcc version failed. Please update the KEIL MDK installation path in rtconfig.py!')
|
|
||||||
return "0.0"
|
return "0.0"
|
||||||
|
|
||||||
child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
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]
|
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 = re.search(r'Product: (.+)', stdout).group(1)
|
||||||
version_Product = version_Product[:-1]
|
version_Product = version_Product[:-1]
|
||||||
version_Component = re.search(r'Component: (.*)', stdout).group(1)
|
version_Component = re.search(r'Component: (.*)', stdout).group(1)
|
||||||
|
@ -166,31 +166,6 @@ def bsp_update_kconfig_library(dist_dir):
|
|||||||
line = line[0:position] + 'libraries/HAL_Drivers/Kconfig"\n'
|
line = line[0:position] + 'libraries/HAL_Drivers/Kconfig"\n'
|
||||||
f.write(line)
|
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):
|
def zip_dist(dist_dir, dist_name):
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
@ -328,23 +303,18 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
|
|||||||
bsp_update_kconfig_library(dist_dir)
|
bsp_update_kconfig_library(dist_dir)
|
||||||
# delete testcases in Kconfig
|
# delete testcases in Kconfig
|
||||||
bsp_update_kconfig_testcases(dist_dir)
|
bsp_update_kconfig_testcases(dist_dir)
|
||||||
# update all project files
|
|
||||||
bs_update_ide_project(dist_dir, target_path)
|
|
||||||
|
|
||||||
# make zip package
|
# make zip package
|
||||||
zip_dist(dist_dir, dist_name)
|
zip_dist(dist_dir, dist_name)
|
||||||
|
|
||||||
print('done!')
|
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....')
|
print('make distribution....')
|
||||||
|
|
||||||
dist_name = os.path.basename(BSP_ROOT)
|
if project_path == None:
|
||||||
|
dist_dir = os.path.join(BSP_ROOT, 'dist', project_name)
|
||||||
if rttide == None:
|
|
||||||
dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name)
|
|
||||||
else:
|
else:
|
||||||
dist_dir = rttide['project_path']
|
dist_dir = project_path
|
||||||
|
|
||||||
target_path = os.path.join(dist_dir, 'rt-thread')
|
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)
|
bsp_update_kconfig_library(dist_dir)
|
||||||
# delete testcases in Kconfig
|
# delete testcases in Kconfig
|
||||||
bsp_update_kconfig_testcases(dist_dir)
|
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
|
# make zip package
|
||||||
if rttide == None:
|
if project_path == None:
|
||||||
zip_dist(dist_dir, dist_name)
|
zip_dist(dist_dir, project_name)
|
||||||
|
|
||||||
print('done!')
|
print('done!')
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ def AddOptions():
|
|||||||
dest = 'project-path',
|
dest = 'project-path',
|
||||||
type = 'string',
|
type = 'string',
|
||||||
default = None,
|
default = None,
|
||||||
help = 'set dist-ide project output path')
|
help = 'set project output path')
|
||||||
AddOption('--project-name',
|
AddOption('--project-name',
|
||||||
dest = 'project-name',
|
dest = 'project-name',
|
||||||
type = 'string',
|
type = 'string',
|
||||||
|
@ -29,7 +29,6 @@ import os
|
|||||||
import json
|
import json
|
||||||
import utils
|
import utils
|
||||||
import rtconfig
|
import rtconfig
|
||||||
import rtconfig
|
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user