parser.add_argument('-f', dest='list_fields', action='store_true', default=False, help='Output a list of structs and fields for the given headers.')
parser.add_argument('-p', dest='pretty_print', action='store_true', default=False, help='Pretty print the outputted JSON.')
parser.add_argument('-o', dest='output', metavar='path', default=None, help='Path to the JSON file that will be written. If omitted, the generated data will be printed to stdout.')
parser.add_argument('-I', dest='includes', metavar='dir', action='append', default=[], help='Add directory to include search path')
parser.add_argument('-D', dest='defines', metavar='define', action='append', default=[], help='Pass a define to the preprocessor')
parser.add_argument('-U', dest='undefines', metavar='undefine', action='append', default=[], help='Pass an undefine to the preprocessor')
args=parser.parse_args(args)
QUIET=args.quiet
# Avoid parsing problems due to gcc specifc syntax.
cpp_opts= ['-D_GNU_SOURCE']
# Add the user options to the list as well.
forpathinargs.includes:
cpp_opts.append('-I'+path)
forarginargs.defines:
cpp_opts.append('-D'+arg)
forarginargs.undefines:
cpp_opts.append('-U'+arg)
ifargs.list_fields:
# Just parse the given headers and output the result.
data= []
forpathinargs.headers:
ifpath[-5:] =='.json':
show('WARN: Skipping "'+path+'" because it\'s already a JSON file!')