17
17
from argparse import ArgumentParser
18
18
from tools .toolchains import TOOLCHAINS
19
19
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
21
22
22
23
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
+ """
23
30
parser = ArgumentParser ()
24
31
25
32
targetnames = TARGET_NAMES
@@ -28,26 +35,47 @@ def get_default_options_parser(add_clean=True, add_options=True):
28
35
toolchainlist .sort ()
29
36
30
37
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" )))
34
44
35
45
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" )))
39
52
40
53
parser .add_argument ("--color" ,
41
54
help = "print Warnings, and Errors in color" ,
42
55
action = "store_true" , default = False )
43
56
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
+
44
66
if add_clean :
45
67
parser .add_argument ("-c" , "--clean" , action = "store_true" , default = False ,
46
- help = "clean the build directory" )
68
+ help = "clean the build directory" )
47
69
48
70
if add_options :
49
71
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" ))
52
80
53
81
return parser
0 commit comments