Decouple the addition of command line arguments (#5848)
* Decouple the addition of command line arguments * Decouple the addition of command line arguments * Modify change logs * Modify change logs * Decouple the addition of command line arguments * delete wrong edits * Modify file header * remove duplicate imports
This commit is contained in:
parent
04fe6232fb
commit
0624bbf009
|
@ -29,10 +29,13 @@ import sys
|
||||||
import string
|
import string
|
||||||
import utils
|
import utils
|
||||||
import operator
|
import operator
|
||||||
|
import rtconfig
|
||||||
|
|
||||||
from SCons.Script import *
|
from SCons.Script import *
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
from mkdist import do_copy_file
|
from mkdist import do_copy_file
|
||||||
|
from options import AddOptions
|
||||||
|
|
||||||
|
|
||||||
BuildOptions = {}
|
BuildOptions = {}
|
||||||
Projects = []
|
Projects = []
|
||||||
|
@ -119,7 +122,6 @@ class Win32Spawn:
|
||||||
|
|
||||||
# generate cconfig.h file
|
# generate cconfig.h file
|
||||||
def GenCconfigFile(env, BuildOptions):
|
def GenCconfigFile(env, BuildOptions):
|
||||||
import rtconfig
|
|
||||||
|
|
||||||
if rtconfig.PLATFORM == 'gcc':
|
if rtconfig.PLATFORM == 'gcc':
|
||||||
contents = ''
|
contents = ''
|
||||||
|
@ -144,90 +146,13 @@ def GenCconfigFile(env, BuildOptions):
|
||||||
env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H'])
|
env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H'])
|
||||||
|
|
||||||
def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = []):
|
def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = []):
|
||||||
import rtconfig
|
|
||||||
|
|
||||||
global BuildOptions
|
global BuildOptions
|
||||||
global Projects
|
global Projects
|
||||||
global Env
|
global Env
|
||||||
global Rtt_Root
|
global Rtt_Root
|
||||||
|
|
||||||
# ===== Add option to SCons =====
|
AddOptions()
|
||||||
AddOption('--dist',
|
|
||||||
dest = 'make-dist',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'make distribution')
|
|
||||||
AddOption('--dist-strip',
|
|
||||||
dest = 'make-dist-strip',
|
|
||||||
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 = 'project-path',
|
|
||||||
type = 'string',
|
|
||||||
default = None,
|
|
||||||
help = 'set dist-ide project output path')
|
|
||||||
AddOption('--project-name',
|
|
||||||
dest = 'project-name',
|
|
||||||
type = 'string',
|
|
||||||
default = None,
|
|
||||||
help = 'set project name')
|
|
||||||
AddOption('--reset-project-config',
|
|
||||||
dest = 'reset-project-config',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'reset the project configurations to default')
|
|
||||||
AddOption('--cscope',
|
|
||||||
dest = 'cscope',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'Build Cscope cross reference database. Requires cscope installed.')
|
|
||||||
AddOption('--clang-analyzer',
|
|
||||||
dest = 'clang-analyzer',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'Perform static analyze with Clang-analyzer. ' + \
|
|
||||||
'Requires Clang installed.\n' + \
|
|
||||||
'It is recommended to use with scan-build like this:\n' + \
|
|
||||||
'`scan-build scons --clang-analyzer`\n' + \
|
|
||||||
'If things goes well, scan-build will instruct you to invoke scan-view.')
|
|
||||||
AddOption('--buildlib',
|
|
||||||
dest = 'buildlib',
|
|
||||||
type = 'string',
|
|
||||||
help = 'building library of a component')
|
|
||||||
AddOption('--cleanlib',
|
|
||||||
dest = 'cleanlib',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'clean up the library by --buildlib')
|
|
||||||
AddOption('--target',
|
|
||||||
dest = 'target',
|
|
||||||
type = 'string',
|
|
||||||
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake')
|
|
||||||
AddOption('--stackanalysis',
|
|
||||||
dest = 'stackanalysis',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'thread stack static analysis')
|
|
||||||
AddOption('--genconfig',
|
|
||||||
dest = 'genconfig',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'Generate .config from rtconfig.h')
|
|
||||||
AddOption('--useconfig',
|
|
||||||
dest = 'useconfig',
|
|
||||||
type = 'string',
|
|
||||||
help = 'make rtconfig.h from config file.')
|
|
||||||
AddOption('--verbose',
|
|
||||||
dest = 'verbose',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'print verbose information during build')
|
|
||||||
|
|
||||||
Env = env
|
Env = env
|
||||||
Rtt_Root = os.path.abspath(root_directory)
|
Rtt_Root = os.path.abspath(root_directory)
|
||||||
|
@ -373,28 +298,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
ThreadStackStaticAnalysis(Env)
|
ThreadStackStaticAnalysis(Env)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if env['PLATFORM'] != 'win32':
|
|
||||||
AddOption('--menuconfig',
|
|
||||||
dest = 'menuconfig',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'make menuconfig for RT-Thread BSP')
|
|
||||||
if GetOption('menuconfig'):
|
if GetOption('menuconfig'):
|
||||||
from menuconfig import menuconfig
|
from menuconfig import menuconfig
|
||||||
menuconfig(Rtt_Root)
|
menuconfig(Rtt_Root)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
AddOption('--pyconfig',
|
|
||||||
dest = 'pyconfig',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'Python GUI menuconfig for RT-Thread BSP')
|
|
||||||
AddOption('--pyconfig-silent',
|
|
||||||
dest = 'pyconfig_silent',
|
|
||||||
action = 'store_true',
|
|
||||||
default = False,
|
|
||||||
help = 'Don`t show pyconfig window')
|
|
||||||
|
|
||||||
if GetOption('pyconfig_silent'):
|
if GetOption('pyconfig_silent'):
|
||||||
from menuconfig import guiconfig_silent
|
from menuconfig import guiconfig_silent
|
||||||
|
|
||||||
|
@ -457,7 +365,6 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
return objs
|
return objs
|
||||||
|
|
||||||
def PrepareModuleBuilding(env, root_directory, bsp_directory):
|
def PrepareModuleBuilding(env, root_directory, bsp_directory):
|
||||||
import rtconfig
|
|
||||||
|
|
||||||
global BuildOptions
|
global BuildOptions
|
||||||
global Env
|
global Env
|
||||||
|
@ -480,17 +387,6 @@ def PrepareModuleBuilding(env, root_directory, bsp_directory):
|
||||||
PreProcessor.process_contents(contents)
|
PreProcessor.process_contents(contents)
|
||||||
BuildOptions = PreProcessor.cpp_namespace
|
BuildOptions = PreProcessor.cpp_namespace
|
||||||
|
|
||||||
# add build/clean library option for library checking
|
|
||||||
AddOption('--buildlib',
|
|
||||||
dest='buildlib',
|
|
||||||
type='string',
|
|
||||||
help='building library of a component')
|
|
||||||
AddOption('--cleanlib',
|
|
||||||
dest='cleanlib',
|
|
||||||
action='store_true',
|
|
||||||
default=False,
|
|
||||||
help='clean up the library by --buildlib')
|
|
||||||
|
|
||||||
# add program path
|
# add program path
|
||||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||||
|
|
||||||
|
@ -709,7 +605,7 @@ def DefineGroup(name, src, depend, **parameters):
|
||||||
paths.append(os.path.abspath(item))
|
paths.append(os.path.abspath(item))
|
||||||
group['LOCAL_CPPPATH'] = paths
|
group['LOCAL_CPPPATH'] = paths
|
||||||
|
|
||||||
import rtconfig
|
|
||||||
if rtconfig.PLATFORM == 'gcc':
|
if rtconfig.PLATFORM == 'gcc':
|
||||||
if 'CFLAGS' in group:
|
if 'CFLAGS' in group:
|
||||||
group['CFLAGS'] = utils.GCCC99Patch(group['CFLAGS'])
|
group['CFLAGS'] = utils.GCCC99Patch(group['CFLAGS'])
|
||||||
|
@ -786,7 +682,7 @@ def PreBuilding():
|
||||||
a()
|
a()
|
||||||
|
|
||||||
def GroupLibName(name, env):
|
def GroupLibName(name, env):
|
||||||
import rtconfig
|
|
||||||
if rtconfig.PLATFORM == 'armcc':
|
if rtconfig.PLATFORM == 'armcc':
|
||||||
return name + '_rvds'
|
return name + '_rvds'
|
||||||
elif rtconfig.PLATFORM == 'gcc':
|
elif rtconfig.PLATFORM == 'gcc':
|
||||||
|
@ -953,7 +849,6 @@ def GenTargetProject(program = None):
|
||||||
|
|
||||||
|
|
||||||
def EndBuilding(target, program = None):
|
def EndBuilding(target, program = None):
|
||||||
import rtconfig
|
|
||||||
|
|
||||||
need_exit = False
|
need_exit = False
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
#
|
||||||
|
# File : options.py
|
||||||
|
# This file is part of RT-Thread RTOS
|
||||||
|
# COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
#
|
||||||
|
# Change Logs:
|
||||||
|
# Date Author Notes
|
||||||
|
# 2022-04-20 WuGensheng Add Options to SCons
|
||||||
|
#
|
||||||
|
|
||||||
|
from SCons.Script import AddOption
|
||||||
|
import platform
|
||||||
|
|
||||||
|
def AddOptions():
|
||||||
|
''' ===== Add options to SCons ===== '''
|
||||||
|
|
||||||
|
AddOption('--dist',
|
||||||
|
dest = 'make-dist',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'make distribution')
|
||||||
|
AddOption('--dist-strip',
|
||||||
|
dest = 'make-dist-strip',
|
||||||
|
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 = 'project-path',
|
||||||
|
type = 'string',
|
||||||
|
default = None,
|
||||||
|
help = 'set dist-ide project output path')
|
||||||
|
AddOption('--project-name',
|
||||||
|
dest = 'project-name',
|
||||||
|
type = 'string',
|
||||||
|
default = None,
|
||||||
|
help = 'set project name')
|
||||||
|
AddOption('--reset-project-config',
|
||||||
|
dest = 'reset-project-config',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'reset the project configurations to default')
|
||||||
|
AddOption('--cscope',
|
||||||
|
dest = 'cscope',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'Build Cscope cross reference database. Requires cscope installed.')
|
||||||
|
AddOption('--clang-analyzer',
|
||||||
|
dest = 'clang-analyzer',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'Perform static analyze with Clang-analyzer. ' + \
|
||||||
|
'Requires Clang installed.\n' + \
|
||||||
|
'It is recommended to use with scan-build like this:\n' + \
|
||||||
|
'`scan-build scons --clang-analyzer`\n' + \
|
||||||
|
'If things goes well, scan-build will instruct you to invoke scan-view.')
|
||||||
|
AddOption('--buildlib',
|
||||||
|
dest = 'buildlib',
|
||||||
|
type = 'string',
|
||||||
|
help = 'building library of a component')
|
||||||
|
AddOption('--cleanlib',
|
||||||
|
dest = 'cleanlib',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'clean up the library by --buildlib')
|
||||||
|
AddOption('--target',
|
||||||
|
dest = 'target',
|
||||||
|
type = 'string',
|
||||||
|
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake')
|
||||||
|
AddOption('--stackanalysis',
|
||||||
|
dest = 'stackanalysis',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'thread stack static analysis')
|
||||||
|
AddOption('--genconfig',
|
||||||
|
dest = 'genconfig',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'Generate .config from rtconfig.h')
|
||||||
|
AddOption('--useconfig',
|
||||||
|
dest = 'useconfig',
|
||||||
|
type = 'string',
|
||||||
|
help = 'make rtconfig.h from config file.')
|
||||||
|
AddOption('--verbose',
|
||||||
|
dest = 'verbose',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'print verbose information during build')
|
||||||
|
AddOption('--pyconfig',
|
||||||
|
dest = 'pyconfig',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'Python GUI menuconfig for RT-Thread BSP')
|
||||||
|
AddOption('--pyconfig-silent',
|
||||||
|
dest = 'pyconfig_silent',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'Don`t show pyconfig window')
|
||||||
|
if platform.system() != 'Windows':
|
||||||
|
AddOption('--menuconfig',
|
||||||
|
dest = 'menuconfig',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'make menuconfig for RT-Thread BSP')
|
||||||
|
|
Loading…
Reference in New Issue