Merge pull request #2785 from SummerGGift/add_ide_dist
[tools] add scons --dist-ide function
This commit is contained in:
commit
0c45bb6f96
|
@ -161,6 +161,21 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
default = False,
|
default = False,
|
||||||
help = 'make distribution and strip useless files')
|
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',
|
AddOption('--cscope',
|
||||||
dest = 'cscope',
|
dest = 'cscope',
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
|
@ -865,6 +880,24 @@ def EndBuilding(target, program = None):
|
||||||
from mkdist import MkDist_Strip
|
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:
|
||||||
|
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'):
|
if GetOption('cscope'):
|
||||||
from cscope import CscopeDatabase
|
from cscope import CscopeDatabase
|
||||||
CscopeDatabase(Projects)
|
CscopeDatabase(Projects)
|
||||||
|
|
|
@ -141,15 +141,20 @@ def bsp_update_kconfig_library(dist_dir):
|
||||||
found = 0
|
found = 0
|
||||||
f.write(line)
|
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
|
import subprocess
|
||||||
# default update the projects which have template file
|
# default update the projects which have template file
|
||||||
|
|
||||||
|
if rttide == None:
|
||||||
tgt_dict = {'mdk4':('keil', 'armcc'),
|
tgt_dict = {'mdk4':('keil', 'armcc'),
|
||||||
'mdk5':('keil', 'armcc'),
|
'mdk5':('keil', 'armcc'),
|
||||||
'iar':('iar', 'iar'),
|
'iar':('iar', 'iar'),
|
||||||
'vs':('msvc', 'cl'),
|
'vs':('msvc', 'cl'),
|
||||||
'vs2012':('msvc', 'cl'),
|
'vs2012':('msvc', 'cl'),
|
||||||
'cdk':('gcc', 'gcc')}
|
'cdk':('gcc', 'gcc')}
|
||||||
|
else:
|
||||||
|
item = 'eclipse --project-name=' + rttide['project_name']
|
||||||
|
tgt_dict = {item:('gcc', 'gcc')}
|
||||||
|
|
||||||
scons_env = os.environ.copy()
|
scons_env = os.environ.copy()
|
||||||
scons_env['RTT_ROOT'] = rtt_root
|
scons_env['RTT_ROOT'] = rtt_root
|
||||||
|
@ -302,11 +307,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env):
|
||||||
|
|
||||||
print('done!')
|
print('done!')
|
||||||
|
|
||||||
def MkDist(program, BSP_ROOT, RTT_ROOT, Env):
|
def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None):
|
||||||
print('make distribution....')
|
print('make distribution....')
|
||||||
|
|
||||||
dist_name = os.path.basename(BSP_ROOT)
|
dist_name = os.path.basename(BSP_ROOT)
|
||||||
|
|
||||||
|
if rttide == None:
|
||||||
dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name)
|
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')
|
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
|
# change RTT_ROOT in Kconfig
|
||||||
bsp_update_kconfig(dist_dir)
|
bsp_update_kconfig(dist_dir)
|
||||||
bsp_update_kconfig_library(dist_dir)
|
bsp_update_kconfig_library(dist_dir)
|
||||||
|
|
||||||
# update all project files
|
# update all project files
|
||||||
|
if rttide == None:
|
||||||
bs_update_ide_project(dist_dir, target_path)
|
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:
|
||||||
zip_dist(dist_dir, dist_name)
|
zip_dist(dist_dir, dist_name)
|
||||||
|
|
||||||
print('done!')
|
print('done!')
|
||||||
|
|
Loading…
Reference in New Issue