mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #2393 from theotherjimmy/argument-dependencies
[tools] Prevent trace-backs from incomplete argspull/2630/head
commit
5dcd546fd5
|
@ -36,7 +36,7 @@ from tools.build_api import mcu_toolchain_matrix
|
||||||
from tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library
|
from tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library
|
||||||
from tools.build_api import print_build_results
|
from tools.build_api import print_build_results
|
||||||
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
|
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
|
||||||
from utils import argparse_filestring_type
|
from utils import argparse_filestring_type, args_error
|
||||||
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
|
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
|
||||||
from utils import argparse_filestring_type, argparse_dir_not_parent
|
from utils import argparse_filestring_type, argparse_dir_not_parent
|
||||||
|
|
||||||
|
@ -167,6 +167,9 @@ if __name__ == '__main__':
|
||||||
# Get toolchains list
|
# Get toolchains list
|
||||||
toolchains = options.tool if options.tool else TOOLCHAINS
|
toolchains = options.tool if options.tool else TOOLCHAINS
|
||||||
|
|
||||||
|
if options.source_dir and not options.build_dir:
|
||||||
|
args_error(parser, "argument --build is required by argument --source")
|
||||||
|
|
||||||
if options.color:
|
if options.color:
|
||||||
# This import happens late to prevent initializing colorization when we don't need it
|
# This import happens late to prevent initializing colorization when we don't need it
|
||||||
import colorize
|
import colorize
|
||||||
|
|
|
@ -37,7 +37,7 @@ except:
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Parse Options
|
# Parse Options
|
||||||
parser = get_default_options_parser(add_clean=False, add_options=False)
|
parser = get_default_options_parser(add_clean=False, add_options=False)
|
||||||
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
|
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, required=True,
|
||||||
default=[], help="The source (input) directory", action="append")
|
default=[], help="The source (input) directory", action="append")
|
||||||
parser.add_argument("--prefix", dest="prefix", action="append",
|
parser.add_argument("--prefix", dest="prefix", action="append",
|
||||||
default=[], help="Restrict listing to parameters that have this prefix")
|
default=[], help="Restrict listing to parameters that have this prefix")
|
||||||
|
@ -48,12 +48,12 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Target
|
# Target
|
||||||
if options.mcu is None :
|
if options.mcu is None :
|
||||||
args_error(parser, "[ERROR] You should specify an MCU")
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
target = options.mcu[0]
|
target = options.mcu[0]
|
||||||
|
|
||||||
# Toolchain
|
# Toolchain
|
||||||
if options.tool is None:
|
if options.tool is None:
|
||||||
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
|
args_error(parser, "argument -t/--toolchain is required")
|
||||||
toolchain = options.tool[0]
|
toolchain = options.tool[0]
|
||||||
|
|
||||||
options.prefix = options.prefix or [""]
|
options.prefix = options.prefix or [""]
|
||||||
|
|
|
@ -207,14 +207,20 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Target
|
# Target
|
||||||
if options.mcu is None :
|
if options.mcu is None :
|
||||||
args_error(parser, "[ERROR] You should specify an MCU")
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
mcu = options.mcu[0]
|
mcu = options.mcu[0]
|
||||||
|
|
||||||
# Toolchain
|
# Toolchain
|
||||||
if options.tool is None:
|
if options.tool is None:
|
||||||
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
|
args_error(parser, "argument -t/--tool is required")
|
||||||
toolchain = options.tool[0]
|
toolchain = options.tool[0]
|
||||||
|
|
||||||
|
if (options.program is None) and (not options.source_dir):
|
||||||
|
args_error(parser, "one of -p, -n, or --source is required")
|
||||||
|
|
||||||
|
if options.source_dir and not options.build_dir:
|
||||||
|
args_error(parser, "argument --build is required when argument --source is provided")
|
||||||
|
|
||||||
if options.color:
|
if options.color:
|
||||||
# This import happens late to prevent initializing colorization when we don't need it
|
# This import happens late to prevent initializing colorization when we don't need it
|
||||||
import colorize
|
import colorize
|
||||||
|
|
|
@ -13,7 +13,7 @@ from tools.tests import TESTS, TEST_MAP
|
||||||
from tools.tests import test_known, test_name_known
|
from tools.tests import test_known, test_name_known
|
||||||
from tools.targets import TARGET_NAMES
|
from tools.targets import TARGET_NAMES
|
||||||
from tools.libraries import LIBRARIES
|
from tools.libraries import LIBRARIES
|
||||||
from utils import argparse_filestring_type, argparse_many
|
from utils import argparse_filestring_type, argparse_many, args_error
|
||||||
from utils import argparse_force_lowercase_type, argparse_force_uppercase_type, argparse_dir_not_parent
|
from utils import argparse_force_lowercase_type, argparse_force_uppercase_type, argparse_dir_not_parent
|
||||||
from project_api import setup_project, perform_export, print_results, get_lib_symbols
|
from project_api import setup_project, perform_export, print_results, get_lib_symbols
|
||||||
|
|
||||||
|
@ -131,6 +131,16 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# source_dir = use relative paths, otherwise sources are copied
|
# source_dir = use relative paths, otherwise sources are copied
|
||||||
sources_relative = True if options.source_dir else False
|
sources_relative = True if options.source_dir else False
|
||||||
|
# Target
|
||||||
|
if not options.mcu:
|
||||||
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
|
|
||||||
|
# Toolchain
|
||||||
|
if not options.ide:
|
||||||
|
args_error(parser, "argument -i is required")
|
||||||
|
|
||||||
|
if (options.program is None) and (not options.source_dir):
|
||||||
|
args_error(parser, "one of -p, -n, or --source is required")
|
||||||
|
|
||||||
for mcu in options.mcu:
|
for mcu in options.mcu:
|
||||||
# Program Number or name
|
# Program Number or name
|
||||||
|
|
|
@ -107,12 +107,12 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Target
|
# Target
|
||||||
if options.mcu is None :
|
if options.mcu is None :
|
||||||
args_error(parser, "[ERROR] You should specify an MCU")
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
mcu = options.mcu[0]
|
mcu = options.mcu[0]
|
||||||
|
|
||||||
# Toolchain
|
# Toolchain
|
||||||
if options.tool is None:
|
if options.tool is None:
|
||||||
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
|
args_error(parser, "argument -t/--tool is required")
|
||||||
toolchain = options.tool[0]
|
toolchain = options.tool[0]
|
||||||
|
|
||||||
# Find all tests in the relevant paths
|
# Find all tests in the relevant paths
|
||||||
|
@ -152,8 +152,7 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
# Build all tests
|
# Build all tests
|
||||||
if not options.build_dir:
|
if not options.build_dir:
|
||||||
print "[ERROR] You must specify a build path"
|
args_error(parser, "argument --build is required")
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
base_source_paths = options.source_dir
|
base_source_paths = options.source_dir
|
||||||
|
|
||||||
|
|
|
@ -282,9 +282,8 @@ def args_error(parser, message):
|
||||||
parser - the ArgumentParser object that parsed the command line
|
parser - the ArgumentParser object that parsed the command line
|
||||||
message - what went wrong
|
message - what went wrong
|
||||||
"""
|
"""
|
||||||
print "\n\n%s\n\n" % message
|
parser.error(message)
|
||||||
parser.print_help()
|
sys.exit(2)
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
def construct_enum(**enums):
|
def construct_enum(**enums):
|
||||||
|
|
Loading…
Reference in New Issue