Skip to content

Commit 163fa59

Browse files
committed
Prevent traceback
1 parent a0c8a09 commit 163fa59

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

tools/build.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library
3737
from tools.build_api import print_build_results
3838
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
39-
from utils import argparse_filestring_type
39+
from utils import argparse_filestring_type, args_error
4040
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
4141
from utils import argparse_filestring_type, argparse_dir_not_parent
4242

@@ -167,6 +167,9 @@
167167
# Get toolchains list
168168
toolchains = options.tool if options.tool else TOOLCHAINS
169169

170+
if options.source_dir and not options.build_dir:
171+
args_error(parser, "argument --build is required by argument --source")
172+
170173
if options.color:
171174
# This import happens late to prevent initializing colorization when we don't need it
172175
import colorize

tools/make.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,15 @@
212212

213213
# Toolchain
214214
if options.tool is None:
215-
args_error(parser, "argument -t/--toolchain is required")
215+
args_error(parser, "argument -t/--tool is required")
216216
toolchain = options.tool[0]
217217

218+
if (options.program is None) and (not options.source_dir):
219+
args_error(parser, "one of -p, -n, or --source is required")
220+
221+
if options.source_dir and not options.build_dir:
222+
args_error(parser, "argument --build is required when argument --source is provided")
223+
218224
if options.color:
219225
# This import happens late to prevent initializing colorization when we don't need it
220226
import colorize

tools/project.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from tools.tests import test_known, test_name_known
1414
from tools.targets import TARGET_NAMES
1515
from tools.libraries import LIBRARIES
16-
from utils import argparse_filestring_type, argparse_many
16+
from utils import argparse_filestring_type, argparse_many, args_error
1717
from utils import argparse_force_lowercase_type, argparse_force_uppercase_type, argparse_dir_not_parent
1818
from project_api import setup_project, perform_export, print_results, get_lib_symbols
1919

@@ -131,6 +131,16 @@
131131

132132
# source_dir = use relative paths, otherwise sources are copied
133133
sources_relative = True if options.source_dir else False
134+
# Target
135+
if not options.mcu:
136+
args_error(parser, "argument -m/--mcu is required")
137+
138+
# Toolchain
139+
if not options.ide:
140+
args_error(parser, "argument -i is required")
141+
142+
if (options.program is None) and (not options.source_dir):
143+
args_error(parser, "one of -p, -n, or --source is required")
134144

135145
for mcu in options.mcu:
136146
# Program Number or name

tools/test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
# Toolchain
114114
if options.tool is None:
115-
args_error(parser, "argument -t/--toolchain is required")
115+
args_error(parser, "argument -t/--tool is required")
116116
toolchain = options.tool[0]
117117

118118
# Find all tests in the relevant paths
@@ -152,8 +152,7 @@
152152
else:
153153
# Build all tests
154154
if not options.build_dir:
155-
print "[ERROR] You must specify a build path"
156-
sys.exit(1)
155+
args_error(parser, "argument --build is required")
157156

158157
base_source_paths = options.source_dir
159158

0 commit comments

Comments
 (0)