[tools] 支持通过--project-name=xxx设置生成的工程文件名称

默认为project.xx 与原来保持一致
相关:https://club.rt-thread.org/ask/article/f998b21633f90916.html
This commit is contained in:
Meco Man 2022-11-24 22:57:36 -05:00 committed by Man, Jianting (Meco)
parent cf221f45d7
commit 88e5657082
2 changed files with 11 additions and 13 deletions

View File

@ -812,35 +812,37 @@ def GenTargetProject(program = None):
from keil import MDK2Project, MDK4Project, MDK5Project, ARMCC_Version from keil import MDK2Project, MDK4Project, MDK5Project, ARMCC_Version
if os.path.isfile('template.uvprojx') and GetOption('target') not in ['mdk4']: # Keil5 if os.path.isfile('template.uvprojx') and GetOption('target') not in ['mdk4']: # Keil5
MDK5Project('project.uvprojx', Projects) MDK5Project(GetOption('project-name') + '.uvprojx', Projects)
print("Keil5 project is generating...") print("Keil5 project is generating...")
elif os.path.isfile('template.uvproj') and GetOption('target') not in ['mdk5']: # Keil4 elif os.path.isfile('template.uvproj') and GetOption('target') not in ['mdk5']: # Keil4
MDK4Project('project.uvproj', Projects) MDK4Project(GetOption('project-name') + '.uvproj', Projects)
print("Keil4 project is generating...") print("Keil4 project is generating...")
elif os.path.isfile('template.Uv2') and GetOption('target') not in ['mdk4', 'mdk5']: # Keil2 elif os.path.isfile('template.Uv2') and GetOption('target') not in ['mdk4', 'mdk5']: # Keil2
MDK2Project('project.Uv2', Projects) MDK2Project(GetOption('project-name') + '.Uv2', Projects)
print("Keil2 project is generating...") print("Keil2 project is generating...")
else: else:
print ('No template project file found.') print ('No template project file found.')
exit(1) exit(1)
print("Keil Version: " + ARMCC_Version()) print("Keil Version: " + ARMCC_Version())
print("Keil-MDK project has generated successfully!")
if GetOption('target') == 'iar': if GetOption('target') == 'iar':
from iar import IARProject, IARVersion from iar import IARProject, IARVersion
print("IAR Version: " + IARVersion()) print("IAR Version: " + IARVersion())
IARProject('project.ewp', Projects) IARProject(GetOption('project-name') + '.ewp', Projects)
print("IAR project has generated successfully!")
if GetOption('target') == 'vs': if GetOption('target') == 'vs':
from vs import VSProject from vs import VSProject
VSProject('project.vcproj', Projects, program) VSProject(GetOption('project-name') + '.vcproj', Projects, program)
if GetOption('target') == 'vs2012': if GetOption('target') == 'vs2012':
from vs2012 import VS2012Project from vs2012 import VS2012Project
VS2012Project('project.vcxproj', Projects, program) VS2012Project(GetOption('project-name') + '.vcxproj', Projects, program)
if GetOption('target') == 'cb': if GetOption('target') == 'cb':
from codeblocks import CBProject from codeblocks import CBProject
CBProject('project.cbp', Projects, program) CBProject(GetOption('project-name') + '.cbp', Projects, program)
if GetOption('target') == 'ua': if GetOption('target') == 'ua':
from ua import PrepareUA from ua import PrepareUA
@ -852,7 +854,7 @@ def GenTargetProject(program = None):
if GetOption('target') == 'cdk': if GetOption('target') == 'cdk':
from cdk import CDKProject from cdk import CDKProject
CDKProject('project.cdkproj', Projects) CDKProject(GetOption('project-name') + '.cdkproj', Projects)
if GetOption('target') == 'ses': if GetOption('target') == 'ses':
from ses import SESProject from ses import SESProject
@ -919,10 +921,6 @@ def EndBuilding(target, program = None):
project_path = GetOption('project-path') project_path = GetOption('project-path')
project_name = GetOption('project-name') project_name = GetOption('project-name')
if not isinstance(project_name, str) or len(project_name) == 0:
project_name = "dist_ide_project"
print("\nwarning : --project-name not specified, use default project name: {0}.".format(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', project_name)
print("\nwarning : --project-path not specified, use default path: {0}.".format(project_path)) print("\nwarning : --project-path not specified, use default path: {0}.".format(project_path))

View File

@ -51,7 +51,7 @@ def AddOptions():
AddOption('--project-name', AddOption('--project-name',
dest = 'project-name', dest = 'project-name',
type = 'string', type = 'string',
default = None, default = "project",
help = 'set project name') help = 'set project name')
AddOption('--reset-project-config', AddOption('--reset-project-config',
dest = 'reset-project-config', dest = 'reset-project-config',