Add a --conform-includes flag to specify include path for the conform schema

(mirrored from cl 133146933)

Change-Id: I61385289728777cae83139fef0229001d92382ca
parent 09ee46a8
......@@ -133,6 +133,8 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) {
" --schema Serialize schemas instead of JSON (use with -b)\n"
" --conform FILE Specify a schema the following schemas should be\n"
" an evolution of. Gives errors if not.\n"
" --conform-includes Include path for the schema given with --conform\n"
" PATH \n"
"FILEs may be schemas, or JSON files (conforming to preceding schema)\n"
"FILEs after the -- must be binary flatbuffer format files.\n"
"Output files are named using the base file name of the input,\n"
......@@ -169,6 +171,7 @@ int main(int argc, const char *argv[]) {
bool schema_binary = false;
std::vector<std::string> filenames;
std::vector<const char *> include_directories;
std::vector<const char *> conform_include_directories;
size_t binary_files_from = std::numeric_limits<size_t>::max();
std::string conform_to_schema;
for (int argi = 1; argi < argc; argi++) {
......@@ -185,6 +188,9 @@ int main(int argc, const char *argv[]) {
} else if(arg == "--conform") {
if (++argi >= argc) Error("missing path following" + arg, true);
conform_to_schema = argv[argi];
} else if (arg == "--conform-includes") {
if (++argi >= argc) Error("missing path following" + arg, true);
conform_include_directories.push_back(argv[argi]);
} else if(arg == "--strict-json") {
opts.strict_json = true;
} else if(arg == "--allow-non-utf8") {
......@@ -265,7 +271,8 @@ int main(int argc, const char *argv[]) {
std::string contents;
if (!flatbuffers::LoadFile(conform_to_schema.c_str(), true, &contents))
Error("unable to load schema: " + conform_to_schema);
ParseFile(conform_parser, conform_to_schema, contents, include_directories);
ParseFile(conform_parser, conform_to_schema, contents,
conform_include_directories);
}
// Now process the files:
......
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