def parseArguments():
"Argument parser for standalone hdlcc"
if ('--version' in sys.argv[1:]) or ('-V' in sys.argv[1:]): # pragma: no cover
print(hdlcc.__version__)
sys.exit(0)
parser = argparse.ArgumentParser()
# Options
parser.add_argument('--version', action='store_true',
help="Shows hdlcc version and exit")
parser.add_argument('--verbose', '-v', action='append_const', const=1,
help="""Increases verbose level. Use multiple times to
increase more""")
parser.add_argument('--clean', '-c', action='store_true',
help="Cleans the project before building")
parser.add_argument('--sources', '-s', action='append', nargs='*', default=[],
help="""Source(s) file(s) to build individually""") \
.completer = _fileExtentensionCompleter('vhd')
parser.add_argument('--debug-print-sources', action='store_true')
parser.add_argument('--debug-parse-source-file', action='store_true')
parser.add_argument('--debug-run-static-check', action='store_true')
parser.add_argument('--debug-profiling', action='store', nargs='?',
metavar='OUTPUT_FILENAME', const='hdlcc.pstats')
# Mandatory arguments
parser.add_argument('project_file', action='store', nargs=1,
help="""Configuration file that defines what should be
built (lists sources, libraries, build flags and so on""")
if _HAS_ARGCOMPLETE: # pragma: no cover
argcomplete.autocomplete(parser)
args = parser.parse_args()
# PYTHON_ARGCOMPLETE_OK
args.project_file = args.project_file[0]
args.log_level = logging.FATAL
if args.verbose:
if len(args.verbose) == 1:
args.log_level = logging.WARNING
elif len(args.verbose) == 2:
args.log_level = logging.INFO
else:
args.log_level = logging.DEBUG
# Planify source list if supplied
if args.sources:
args.sources = [source for sublist in args.sources for source in sublist]
return args
评论列表
文章目录