Skip to content

Commit af5d35d

Browse files
theotherjimmy0xc0170
authored andcommitted
Format and document options.py
1 parent b12ad8e commit af5d35d

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

tools/options.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@
1717
from argparse import ArgumentParser
1818
from tools.toolchains import TOOLCHAINS
1919
from tools.targets import TARGET_NAMES
20-
from utils import argparse_force_uppercase_type, argparse_lowercase_hyphen_type, argparse_many
20+
from tools.utils import argparse_force_uppercase_type, \
21+
argparse_lowercase_hyphen_type, argparse_many
2122

2223
def get_default_options_parser(add_clean=True, add_options=True):
24+
"""Create a new options parser with the default compiler options added
25+
26+
Keyword arguments:
27+
add_clean - add the clean argument?
28+
add_options - add the options argument?
29+
"""
2330
parser = ArgumentParser()
2431

2532
targetnames = TARGET_NAMES
@@ -28,26 +35,47 @@ def get_default_options_parser(add_clean=True, add_options=True):
2835
toolchainlist.sort()
2936

3037
parser.add_argument("-m", "--mcu",
31-
help="build for the given MCU (%s)" % ', '.join(targetnames),
32-
metavar="MCU",
33-
type=argparse_many(argparse_force_uppercase_type(targetnames, "MCU")))
38+
help=("build for the given MCU (%s)" %
39+
', '.join(targetnames)),
40+
metavar="MCU",
41+
type=argparse_many(
42+
argparse_force_uppercase_type(
43+
targetnames, "MCU")))
3444

3545
parser.add_argument("-t", "--tool",
36-
help="build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist),
37-
metavar="TOOLCHAIN",
38-
type=argparse_many(argparse_force_uppercase_type(toolchainlist, "toolchain")))
46+
help=("build using the given TOOLCHAIN (%s)" %
47+
', '.join(toolchainlist)),
48+
metavar="TOOLCHAIN",
49+
type=argparse_many(
50+
argparse_force_uppercase_type(
51+
toolchainlist, "toolchain")))
3952

4053
parser.add_argument("--color",
4154
help="print Warnings, and Errors in color",
4255
action="store_true", default=False)
4356

57+
parser.add_argument("--cflags", default=[], action="append",
58+
help="Extra flags to provide to the C compiler")
59+
60+
parser.add_argument("--asmflags", default=[], action="append",
61+
help="Extra flags to provide to the assembler")
62+
63+
parser.add_argument("--ldflags", default=[], action="append",
64+
help="Extra flags to provide to the linker")
65+
4466
if add_clean:
4567
parser.add_argument("-c", "--clean", action="store_true", default=False,
46-
help="clean the build directory")
68+
help="clean the build directory")
4769

4870
if add_options:
4971
parser.add_argument("-o", "--options", action="append",
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")',
51-
type=argparse_lowercase_hyphen_type(['save-asm', 'debug-info', 'analyze'], "build option"))
72+
help=('Add a build argument ("save-asm": save the '
73+
'asm generated by the compiler, "debug-info":'
74+
' generate debugging information, "analyze": '
75+
'run Goanna static code analyzer")'),
76+
type=argparse_lowercase_hyphen_type(['save-asm',
77+
'debug-info',
78+
'analyze'],
79+
"build option"))
5280

5381
return parser

0 commit comments

Comments
 (0)