The parser and flatc now allow include directories to be specified.

Bug: 17139854
Change-Id: I0eac65d054951e00a8811ad1d80ba8c37012dbf0
Tested: on Linux.
This commit is contained in:
Wouter van Oortmerssen
2014-09-11 17:13:21 -07:00
parent cb58fc6fa1
commit e57b86bb9f
10 changed files with 77 additions and 35 deletions

View File

@@ -2,7 +2,7 @@
Usage:
flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -S ] FILES...
flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
[ -- FILES...]
The files are read and parsed in order, and can contain either schemas
@@ -32,6 +32,11 @@ be generated for each file processed:
current directory. PATH should end in your systems path separator,
e.g. `/` or `\`.
- `-I PATH` : when encountering `include` statements, attempt to load the
files from this path. Paths will be tried in the order given, and if all
fail (or none are specified) it will try to load relative to the path of
the schema file being parsed.
- `-S` : Generate strict JSON (field names are enclosed in quotes).
By default, no quotes are generated.

View File

@@ -249,6 +249,10 @@ reference definitions in earlier files. Typically this means you first
load a schema file (which populates `Parser` with definitions), followed
by one or more JSON files.
As optional argument to `Parse`, you may specify a null-terminated list of
include paths. If not specified, any include statements try to resolve from
the current directory.
If there were any parsing errors, `Parse` will return `false`, and
`Parser::err` contains a human readable error string with a line number
etc, which you should present to the creator of that file.