Clone of official tools

Committer:
screamer
Date:
Sat Jul 16 00:34:03 2016 +0100
Revision:
22:9e85236d8716
Parent:
13:ab47a20b66f0
Child:
29:1210849dba19
Sync with the mbedmicro/mbed tools

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:66f3b5499f7f 1 """
screamer 0:66f3b5499f7f 2 mbed SDK
screamer 0:66f3b5499f7f 3 Copyright (c) 2011-2013 ARM Limited
screamer 0:66f3b5499f7f 4
screamer 0:66f3b5499f7f 5 Licensed under the Apache License, Version 2.0 (the "License");
screamer 0:66f3b5499f7f 6 you may not use this file except in compliance with the License.
screamer 0:66f3b5499f7f 7 You may obtain a copy of the License at
screamer 0:66f3b5499f7f 8
screamer 0:66f3b5499f7f 9 http://www.apache.org/licenses/LICENSE-2.0
screamer 0:66f3b5499f7f 10
screamer 0:66f3b5499f7f 11 Unless required by applicable law or agreed to in writing, software
screamer 0:66f3b5499f7f 12 distributed under the License is distributed on an "AS IS" BASIS,
screamer 0:66f3b5499f7f 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
screamer 0:66f3b5499f7f 14 See the License for the specific language governing permissions and
screamer 0:66f3b5499f7f 15 limitations under the License.
screamer 0:66f3b5499f7f 16 """
screamer 22:9e85236d8716 17 from argparse import ArgumentParser
screamer 0:66f3b5499f7f 18 from tools.toolchains import TOOLCHAINS
screamer 0:66f3b5499f7f 19 from tools.targets import TARGET_NAMES
screamer 22:9e85236d8716 20 from utils import argparse_force_uppercase_type, argparse_lowercase_hyphen_type, argparse_many
screamer 0:66f3b5499f7f 21
screamer 13:ab47a20b66f0 22 def get_default_options_parser(add_clean=True, add_options=True):
screamer 22:9e85236d8716 23 parser = ArgumentParser()
screamer 0:66f3b5499f7f 24
screamer 0:66f3b5499f7f 25 targetnames = TARGET_NAMES
screamer 0:66f3b5499f7f 26 targetnames.sort()
screamer 0:66f3b5499f7f 27 toolchainlist = list(TOOLCHAINS)
screamer 0:66f3b5499f7f 28 toolchainlist.sort()
screamer 0:66f3b5499f7f 29
screamer 22:9e85236d8716 30 parser.add_argument("-m", "--mcu",
screamer 22:9e85236d8716 31 help="build for the given MCU (%s)" % ', '.join(targetnames),
screamer 22:9e85236d8716 32 metavar="MCU",
screamer 22:9e85236d8716 33 type=argparse_many(argparse_force_uppercase_type(targetnames, "MCU")))
screamer 0:66f3b5499f7f 34
screamer 22:9e85236d8716 35 parser.add_argument("-t", "--tool",
screamer 22:9e85236d8716 36 help="build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist),
screamer 22:9e85236d8716 37 metavar="TOOLCHAIN",
screamer 22:9e85236d8716 38 type=argparse_many(argparse_force_uppercase_type(toolchainlist, "toolchain")))
screamer 22:9e85236d8716 39
screamer 22:9e85236d8716 40 parser.add_argument("--color",
screamer 22:9e85236d8716 41 help="print Warnings, and Errors in color",
screamer 22:9e85236d8716 42 action="store_true", default=False)
screamer 0:66f3b5499f7f 43
screamer 13:ab47a20b66f0 44 if add_clean:
screamer 22:9e85236d8716 45 parser.add_argument("-c", "--clean", action="store_true", default=False,
screamer 13:ab47a20b66f0 46 help="clean the build directory")
screamer 0:66f3b5499f7f 47
screamer 13:ab47a20b66f0 48 if add_options:
screamer 22:9e85236d8716 49 parser.add_argument("-o", "--options", action="append",
screamer 22:9e85236d8716 50 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")',
screamer 22:9e85236d8716 51 type=argparse_lowercase_hyphen_type(['save-asm', 'debug-info', 'analyze'], "build option"))
screamer 0:66f3b5499f7f 52
screamer 0:66f3b5499f7f 53 return parser