Merge pull request #2785 from SummerGGift/add_ide_dist

[tools] add scons --dist-ide function
This commit is contained in:
Bernard Xiong 2019-06-18 18:04:25 +08:00 committed by GitHub
commit 0c45bb6f96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 11 deletions

View File

@ -161,6 +161,21 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
action = 'store_true',
default = False,
help = 'make distribution and strip useless files')
AddOption('--dist-ide',
dest = 'make-dist-ide',
action = 'store_true',
default = False,
help = 'make distribution for RT-Thread Studio IDE')
AddOption('--project-path',
dest = 'make-project-path',
type = 'string',
default = False,
help = 'set dist-ide project output path')
AddOption('--project-name',
dest = 'make-project-name',
type = 'string',
default = False,
help = 'set project name')
AddOption('--cscope',
dest = 'cscope',
action = 'store_true',
@ -865,6 +880,24 @@ def EndBuilding(target, 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('make-project-path')
project_name = GetOption('make-project-name')
if not isinstance(project_path, str) or len(project_path) == 0 :
print("\nwarning : --project-path=your_project_path parameter is required.")
print("\nstop!")
exit(0)
if not isinstance(project_name, str) or len(project_name) == 0:
print("\nwarning : --project-name=your_project_name parameter is required.")
print("\nstop!")
exit(0)
rtt_ide = {'project_path' : project_path, 'project_name' : project_name}
MkDist(program, BSP_ROOT, Rtt_Root, Env, rtt_ide)
need_exit = True
if GetOption('cscope'):
from cscope import CscopeDatabase
CscopeDatabase(Projects)

View File

@ -141,15 +141,20 @@ def bsp_update_kconfig_library(dist_dir):
found = 0
f.write(line)
def bs_update_ide_project(bsp_root, rtt_root):
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', 'iar'),
'vs':('msvc', 'cl'),
'vs2012':('msvc', 'cl'),
'cdk':('gcc', '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
@ -302,11 +307,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
print('done!')
def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None):
print('make distribution....')
dist_name = os.path.basename(BSP_ROOT)
if rttide == None:
dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name)
else:
dist_dir = rttide['project_path']
target_path = os.path.join(dist_dir, 'rt-thread')
@ -366,10 +375,15 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
# change RTT_ROOT in Kconfig
bsp_update_kconfig(dist_dir)
bsp_update_kconfig_library(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)
print('done!')