Commit 0ffce3e0 authored by Sergio Costas's avatar Sergio Costas

Now allows to put blank spaces after -D, -I and -e, and the parameter itself.

parent af9dd9b9
......@@ -47,8 +47,12 @@ def get_parameters():
exclude_files = []
store_next = None
for parameter in sys.argv[1:]:
if parameter.strip() == "":
continue
if store_next is not None:
if isinstance(parameters[store_next], list):
if store_next == exclude_files:
exclude_files.append(parameter)
elif isinstance(parameters[store_next], list):
parameters[store_next].append(parameter)
else:
parameters[store_next] = parameter
......@@ -59,14 +63,20 @@ def get_parameters():
for f in files:
parameters["files"][f] = True
continue
if parameter == "-include":
if parameter == "--include":
store_next = "include_files"
continue
if parameter.startswith("-I"):
parameters["includes"].append(parameter[2:])
if parameter == "-I":
store_next = "includes"
else:
parameters["includes"].append(parameter[2:])
continue
if parameter.startswith("-D"):
parameters["defines"].append(parameter[2:])
if parameter == "-D":
store_next = "defines"
else:
parameters["defines"].append(parameter[2:])
continue
if (parameter == "-v") or (parameter == "--version"):
print("Crust version: {:s}".format(crust.version))
......@@ -74,11 +84,11 @@ def get_parameters():
if (parameter == "-h") or (parameter == "--help"):
print("CRUST {:s}".format(crust.version))
print("Usage:")
print(" crust [-Iinclude_path] [-I...] [-Ddefine] [-D...] [-include filename] [-include...] [--nowarnings] [--nocpp] [--quiet] [-eexclude_filename] [--debug1] [--debug2] file.c [file.c] ...")
print(" crust [-I include_path] [-I...] [-D define] [-D...] [--include filename] [--include...] [--nowarnings] [--nocpp] [--quiet] [-e exclude_filename] [--debug1=nline] [--debug2=nline] file.c [file.c] ...")
print()
print(" -I allows to specify paths where the C preprocessor will search for header files. Can be repeated as many times as paths have to be added")
print(" -D allows to specify #defines from command line that the C preprocessor must consider defined. Can be repeated as many times as defines are needed")
print(" -include allows to include a file in the final preprocessed code. Can be repeated as many times as defines are needed")
print(" --include allows to include a file in the final preprocessed code. Can be repeated as many times as defines are needed")
print(" --nowarnings will hide the WARNING messages, showing only ERROR and CRITICAL messages")
print(" --nocpp will pass the source code directly to the parser, instead of pass it before through the C preprocessor")
print(" --quiet will not show extra information")
......@@ -100,7 +110,10 @@ def get_parameters():
parameters["verbose"] = False
continue
if parameter.startswith("-e"):
exclude_files.append(parameter[2:])
if parameter == "-e":
store_next = exclude_files
else:
exclude_files.append(parameter[2:])
continue
if parameter.startswith("--debug1="):
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment