2013-08-06 13:38:00 +00:00
"""
mbed SDK
Copyright ( c ) 2011 - 2013 ARM Limited
Licensed under the Apache License , Version 2.0 ( the " License " ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : / / www . apache . org / licenses / LICENSE - 2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an " AS IS " BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
"""
2016-06-24 22:15:01 +00:00
from argparse import ArgumentParser
2016-06-09 20:34:53 +00:00
from tools . toolchains import TOOLCHAINS
from tools . targets import TARGET_NAMES
2016-06-29 00:46:22 +00:00
from utils import argparse_force_uppercase_type , argparse_lowercase_hyphen_type , argparse_many
2013-02-18 15:32:11 +00:00
2016-06-09 21:05:35 +00:00
def get_default_options_parser ( add_clean = True , add_options = True ) :
2016-06-24 22:15:01 +00:00
parser = ArgumentParser ( )
2014-05-29 13:42:03 +00:00
2014-10-31 12:59:26 +00:00
targetnames = TARGET_NAMES
targetnames . sort ( )
toolchainlist = list ( TOOLCHAINS )
toolchainlist . sort ( )
2016-06-24 22:15:01 +00:00
parser . add_argument ( " -m " , " --mcu " ,
help = " build for the given MCU ( %s ) " % ' , ' . join ( targetnames ) ,
metavar = " MCU " ,
2016-06-29 00:46:22 +00:00
type = argparse_many ( argparse_force_uppercase_type ( targetnames , " MCU " ) ) )
2014-05-29 13:42:03 +00:00
2016-06-24 22:15:01 +00:00
parser . add_argument ( " -t " , " --tool " ,
help = " build using the given TOOLCHAIN ( %s ) " % ' , ' . join ( toolchainlist ) ,
metavar = " TOOLCHAIN " ,
2016-06-29 00:46:22 +00:00
type = argparse_many ( argparse_force_uppercase_type ( toolchainlist , " toolchain " ) ) )
2014-05-29 13:42:03 +00:00
2016-06-09 21:05:35 +00:00
if add_clean :
2016-06-24 22:15:01 +00:00
parser . add_argument ( " -c " , " --clean " , action = " store_true " , default = False ,
2016-06-09 21:05:35 +00:00
help = " clean the build directory " )
2014-05-29 13:42:03 +00:00
2016-06-09 21:05:35 +00:00
if add_options :
2016-06-24 22:15:01 +00:00
parser . add_argument ( " -o " , " --options " , nargs = " * " ,
help = ' Add a build argument ( " save-asm " : save the asm generated by the compiler, " debug-info " : generate debugging information, " analyze " : run Goanna static code analyzer " ) ' ,
type = argparse_lowercase_hyphen_type ( [ ' save-asm ' , ' debug-info ' , ' analyze ' ] , " build option " ) )
2014-05-29 13:42:03 +00:00
2013-02-18 15:32:11 +00:00
return parser