|
35 | 35 | from tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library
|
36 | 36 | from tools.build_api import print_build_results
|
37 | 37 | from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
|
38 |
| -from utils import argparse_filestring_type |
39 | 38 |
|
40 | 39 | if __name__ == '__main__':
|
41 | 40 | start = time()
|
42 | 41 |
|
43 | 42 | # Parse Options
|
44 | 43 | parser = get_default_options_parser()
|
45 | 44 |
|
46 |
| - parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, |
47 |
| - default=None, help="The source (input) directory", nargs="*") |
| 45 | + parser.add_option("--source", dest="source_dir", |
| 46 | + default=None, help="The source (input) directory", action="append") |
48 | 47 |
|
49 |
| - parser.add_argument("--build", dest="build_dir", type=argparse_filestring_type, |
| 48 | + parser.add_option("--build", dest="build_dir", |
50 | 49 | default=None, help="The build (output) directory")
|
51 | 50 |
|
52 |
| - parser.add_argument("--no-archive", dest="no_archive", action="store_true", |
| 51 | + parser.add_option("--no-archive", dest="no_archive", action="store_true", |
53 | 52 | default=False, help="Do not produce archive (.ar) file, but rather .o")
|
54 | 53 |
|
55 | 54 | # Extra libraries
|
56 |
| - parser.add_argument("-r", "--rtos", |
| 55 | + parser.add_option("-r", "--rtos", |
57 | 56 | action="store_true",
|
58 | 57 | dest="rtos",
|
59 | 58 | default=False,
|
60 | 59 | help="Compile the rtos")
|
61 | 60 |
|
62 |
| - parser.add_argument("--rpc", |
| 61 | + parser.add_option("--rpc", |
63 | 62 | action="store_true",
|
64 | 63 | dest="rpc",
|
65 | 64 | default=False,
|
66 | 65 | help="Compile the rpc library")
|
67 | 66 |
|
68 |
| - parser.add_argument("-e", "--eth", |
| 67 | + parser.add_option("-e", "--eth", |
69 | 68 | action="store_true", dest="eth",
|
70 | 69 | default=False,
|
71 | 70 | help="Compile the ethernet library")
|
72 | 71 |
|
73 |
| - parser.add_argument("-U", "--usb_host", |
| 72 | + parser.add_option("-U", "--usb_host", |
74 | 73 | action="store_true",
|
75 | 74 | dest="usb_host",
|
76 | 75 | default=False,
|
77 | 76 | help="Compile the USB Host library")
|
78 | 77 |
|
79 |
| - parser.add_argument("-u", "--usb", |
| 78 | + parser.add_option("-u", "--usb", |
80 | 79 | action="store_true",
|
81 | 80 | dest="usb",
|
82 | 81 | default=False,
|
83 | 82 | help="Compile the USB Device library")
|
84 | 83 |
|
85 |
| - parser.add_argument("-d", "--dsp", |
| 84 | + parser.add_option("-d", "--dsp", |
86 | 85 | action="store_true",
|
87 | 86 | dest="dsp",
|
88 | 87 | default=False,
|
89 | 88 | help="Compile the DSP library")
|
90 | 89 |
|
91 |
| - parser.add_argument("-F", "--fat", |
| 90 | + parser.add_option("-F", "--fat", |
92 | 91 | action="store_true",
|
93 | 92 | dest="fat",
|
94 | 93 | default=False,
|
95 | 94 | help="Compile FS and SD card file system library")
|
96 | 95 |
|
97 |
| - parser.add_argument("-b", "--ublox", |
| 96 | + parser.add_option("-b", "--ublox", |
98 | 97 | action="store_true",
|
99 | 98 | dest="ublox",
|
100 | 99 | default=False,
|
101 | 100 | help="Compile the u-blox library")
|
102 | 101 |
|
103 |
| - parser.add_argument( "--cpputest", |
| 102 | + parser.add_option("", "--cpputest", |
104 | 103 | action="store_true",
|
105 | 104 | dest="cpputest_lib",
|
106 | 105 | default=False,
|
107 | 106 | help="Compiles 'cpputest' unit test library (library should be on the same directory level as mbed repository)")
|
108 | 107 |
|
109 |
| - parser.add_argument("-D", |
110 |
| - nargs="*", |
| 108 | + parser.add_option("-D", "", |
| 109 | + action="append", |
111 | 110 | dest="macros",
|
112 | 111 | help="Add a macro definition")
|
113 | 112 |
|
114 |
| - parser.add_argument("-S", "--supported-toolchains", |
| 113 | + parser.add_option("-S", "--supported-toolchains", |
115 | 114 | action="store_true",
|
116 | 115 | dest="supported_toolchains",
|
117 | 116 | default=False,
|
118 | 117 | help="Displays supported matrix of MCUs and toolchains")
|
119 | 118 |
|
120 |
| - parser.add_argument('-f', '--filter', |
| 119 | + parser.add_option('-f', '--filter', |
121 | 120 | dest='general_filter_regex',
|
122 | 121 | default=None,
|
123 | 122 | help='For some commands you can use filter to filter out results')
|
124 | 123 |
|
125 |
| - parser.add_argument("--cppcheck", |
| 124 | + parser.add_option("", "--cppcheck", |
126 | 125 | action="store_true",
|
127 | 126 | dest="cppcheck_validation",
|
128 | 127 | default=False,
|
129 | 128 | help="Forces 'cppcheck' static code analysis")
|
130 | 129 |
|
131 |
| - parser.add_argument("-j", "--jobs", type=int, dest="jobs", |
| 130 | + parser.add_option("-j", "--jobs", type="int", dest="jobs", |
132 | 131 | default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
|
133 |
| - parser.add_argument("-N", "--artifact-name", dest="artifact_name", |
| 132 | + parser.add_option("-N", "--artifact-name", dest="artifact_name", |
134 | 133 | default=None, help="The built project's name")
|
135 | 134 |
|
136 |
| - parser.add_argument("-v", "--verbose", |
| 135 | + parser.add_option("-v", "--verbose", |
137 | 136 | action="store_true",
|
138 | 137 | dest="verbose",
|
139 | 138 | default=False,
|
140 | 139 | help="Verbose diagnostic output")
|
141 | 140 |
|
142 |
| - parser.add_argument("--silent", |
| 141 | + parser.add_option("--silent", |
143 | 142 | action="store_true",
|
144 | 143 | dest="silent",
|
145 | 144 | default=False,
|
146 | 145 | help="Silent diagnostic output (no copy, compile notification)")
|
147 | 146 |
|
148 |
| - parser.add_argument("-x", "--extra-verbose-notifications", |
| 147 | + parser.add_option("-x", "--extra-verbose-notifications", |
149 | 148 | action="store_true",
|
150 | 149 | dest="extra_verbose_notify",
|
151 | 150 | default=False,
|
152 | 151 | help="Makes compiler more verbose, CI friendly.")
|
153 | 152 |
|
154 |
| - options = parser.parse_args() |
| 153 | + (options, args) = parser.parse_args() |
155 | 154 |
|
156 | 155 | # Only prints matrix of supported toolchains
|
157 | 156 | if options.supported_toolchains:
|
158 | 157 | print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
|
159 | 158 | exit(0)
|
160 | 159 |
|
161 | 160 | # Get target list
|
162 |
| - targets = options.mcu if options.mcu else TARGET_NAMES |
| 161 | + if options.mcu: |
| 162 | + mcu_list = (options.mcu).split(",") |
| 163 | + for mcu in mcu_list: |
| 164 | + if mcu not in TARGET_NAMES: |
| 165 | + print "Given MCU '%s' not into the supported list:\n%s" % (mcu, TARGET_NAMES) |
| 166 | + sys.exit(1) |
| 167 | + targets = mcu_list |
| 168 | + else: |
| 169 | + targets = TARGET_NAMES |
163 | 170 |
|
164 | 171 | # Get toolchains list
|
165 |
| - toolchains = options.tool if options.tool else TOOLCHAINS |
| 172 | + if options.tool: |
| 173 | + toolchain_list = (options.tool).split(",") |
| 174 | + for tc in toolchain_list: |
| 175 | + if tc not in TOOLCHAINS: |
| 176 | + print "Given toolchain '%s' not into the supported list:\n%s" % (tc, TOOLCHAINS) |
| 177 | + sys.exit(1) |
| 178 | + toolchains = toolchain_list |
| 179 | + else: |
| 180 | + toolchains = TOOLCHAINS |
166 | 181 |
|
167 | 182 | # Get libraries list
|
168 | 183 | libraries = []
|
|
0 commit comments