Clone of official tools
options.py@30:f12ce67666d0, 2016-08-29 (annotated)
- Committer:
- screamer
- Date:
- Mon Aug 29 11:56:59 2016 +0100
- Revision:
- 30:f12ce67666d0
- Parent:
- 29:1210849dba19
- Child:
- 31:8ea194f6145b
Update tools from the mbed OS 5.1.2 release (instead of master)
Who changed what in which revision?
User | Revision | Line number | New 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 | 29:1210849dba19 | 20 | from tools.utils import argparse_force_uppercase_type, \ |
screamer | 29:1210849dba19 | 21 | argparse_lowercase_hyphen_type, argparse_many |
screamer | 0:66f3b5499f7f | 22 | |
screamer | 13:ab47a20b66f0 | 23 | def get_default_options_parser(add_clean=True, add_options=True): |
screamer | 29:1210849dba19 | 24 | """Create a new options parser with the default compiler options added |
screamer | 29:1210849dba19 | 25 | |
screamer | 29:1210849dba19 | 26 | Keyword arguments: |
screamer | 29:1210849dba19 | 27 | add_clean - add the clean argument? |
screamer | 29:1210849dba19 | 28 | add_options - add the options argument? |
screamer | 29:1210849dba19 | 29 | """ |
screamer | 22:9e85236d8716 | 30 | parser = ArgumentParser() |
screamer | 0:66f3b5499f7f | 31 | |
screamer | 0:66f3b5499f7f | 32 | targetnames = TARGET_NAMES |
screamer | 0:66f3b5499f7f | 33 | targetnames.sort() |
screamer | 0:66f3b5499f7f | 34 | toolchainlist = list(TOOLCHAINS) |
screamer | 0:66f3b5499f7f | 35 | toolchainlist.sort() |
screamer | 0:66f3b5499f7f | 36 | |
screamer | 22:9e85236d8716 | 37 | parser.add_argument("-m", "--mcu", |
screamer | 29:1210849dba19 | 38 | help=("build for the given MCU (%s)" % |
screamer | 29:1210849dba19 | 39 | ', '.join(targetnames)), |
screamer | 29:1210849dba19 | 40 | metavar="MCU", |
screamer | 29:1210849dba19 | 41 | type=argparse_many( |
screamer | 29:1210849dba19 | 42 | argparse_force_uppercase_type( |
screamer | 29:1210849dba19 | 43 | targetnames, "MCU"))) |
screamer | 0:66f3b5499f7f | 44 | |
screamer | 22:9e85236d8716 | 45 | parser.add_argument("-t", "--tool", |
screamer | 29:1210849dba19 | 46 | help=("build using the given TOOLCHAIN (%s)" % |
screamer | 29:1210849dba19 | 47 | ', '.join(toolchainlist)), |
screamer | 29:1210849dba19 | 48 | metavar="TOOLCHAIN", |
screamer | 29:1210849dba19 | 49 | type=argparse_many( |
screamer | 29:1210849dba19 | 50 | argparse_force_uppercase_type( |
screamer | 29:1210849dba19 | 51 | toolchainlist, "toolchain"))) |
screamer | 22:9e85236d8716 | 52 | |
screamer | 22:9e85236d8716 | 53 | parser.add_argument("--color", |
screamer | 22:9e85236d8716 | 54 | help="print Warnings, and Errors in color", |
screamer | 22:9e85236d8716 | 55 | action="store_true", default=False) |
screamer | 0:66f3b5499f7f | 56 | |
screamer | 29:1210849dba19 | 57 | parser.add_argument("--cflags", default=[], action="append", |
screamer | 29:1210849dba19 | 58 | help="Extra flags to provide to the C compiler") |
screamer | 29:1210849dba19 | 59 | |
screamer | 29:1210849dba19 | 60 | parser.add_argument("--asmflags", default=[], action="append", |
screamer | 29:1210849dba19 | 61 | help="Extra flags to provide to the assembler") |
screamer | 29:1210849dba19 | 62 | |
screamer | 29:1210849dba19 | 63 | parser.add_argument("--ldflags", default=[], action="append", |
screamer | 29:1210849dba19 | 64 | help="Extra flags to provide to the linker") |
screamer | 29:1210849dba19 | 65 | |
screamer | 13:ab47a20b66f0 | 66 | if add_clean: |
screamer | 22:9e85236d8716 | 67 | parser.add_argument("-c", "--clean", action="store_true", default=False, |
screamer | 29:1210849dba19 | 68 | help="clean the build directory") |
screamer | 0:66f3b5499f7f | 69 | |
screamer | 13:ab47a20b66f0 | 70 | if add_options: |
screamer | 22:9e85236d8716 | 71 | parser.add_argument("-o", "--options", action="append", |
screamer | 29:1210849dba19 | 72 | help=('Add a build argument ("save-asm": save the ' |
screamer | 29:1210849dba19 | 73 | 'asm generated by the compiler, "debug-info":' |
screamer | 29:1210849dba19 | 74 | ' generate debugging information, "analyze": ' |
screamer | 29:1210849dba19 | 75 | 'run Goanna static code analyzer")'), |
screamer | 29:1210849dba19 | 76 | type=argparse_lowercase_hyphen_type(['save-asm', |
screamer | 29:1210849dba19 | 77 | 'debug-info', |
screamer | 30:f12ce67666d0 | 78 | 'analyze'], |
screamer | 29:1210849dba19 | 79 | "build option")) |
screamer | 0:66f3b5499f7f | 80 | |
screamer | 0:66f3b5499f7f | 81 | return parser |