| 181 | } |
| 182 | |
| 183 | int FlatCompiler::Compile(int argc, const char **argv) { |
| 184 | if (params_.generators == nullptr || params_.num_generators == 0) { |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | flatbuffers::IDLOptions opts; |
| 189 | std::string output_path; |
| 190 | |
| 191 | bool any_generator = false; |
| 192 | bool print_make_rules = false; |
| 193 | bool raw_binary = false; |
| 194 | bool schema_binary = false; |
| 195 | bool grpc_enabled = false; |
| 196 | std::vector<std::string> filenames; |
| 197 | std::list<std::string> include_directories_storage; |
| 198 | std::vector<const char *> include_directories; |
| 199 | std::vector<const char *> conform_include_directories; |
| 200 | std::vector<bool> generator_enabled(params_.num_generators, false); |
| 201 | size_t binary_files_from = std::numeric_limits<size_t>::max(); |
| 202 | std::string conform_to_schema; |
| 203 | |
| 204 | for (int argi = 0; argi < argc; argi++) { |
| 205 | std::string arg = argv[argi]; |
| 206 | if (arg[0] == '-') { |
| 207 | if (filenames.size() && arg[1] != '-') |
| 208 | Error("invalid option location: " + arg, true); |
| 209 | if (arg == "-o") { |
| 210 | if (++argi >= argc) Error("missing path following: " + arg, true); |
| 211 | output_path = flatbuffers::ConCatPathFileName( |
| 212 | flatbuffers::PosixPath(argv[argi]), ""); |
| 213 | } else if (arg == "-I") { |
| 214 | if (++argi >= argc) Error("missing path following: " + arg, true); |
| 215 | include_directories_storage.push_back( |
| 216 | flatbuffers::PosixPath(argv[argi])); |
| 217 | include_directories.push_back( |
| 218 | include_directories_storage.back().c_str()); |
| 219 | } else if (arg == "--conform") { |
| 220 | if (++argi >= argc) Error("missing path following: " + arg, true); |
| 221 | conform_to_schema = flatbuffers::PosixPath(argv[argi]); |
| 222 | } else if (arg == "--conform-includes") { |
| 223 | if (++argi >= argc) Error("missing path following: " + arg, true); |
| 224 | include_directories_storage.push_back( |
| 225 | flatbuffers::PosixPath(argv[argi])); |
| 226 | conform_include_directories.push_back( |
| 227 | include_directories_storage.back().c_str()); |
| 228 | } else if (arg == "--include-prefix") { |
| 229 | if (++argi >= argc) Error("missing path following: " + arg, true); |
| 230 | opts.include_prefix = flatbuffers::ConCatPathFileName( |
| 231 | flatbuffers::PosixPath(argv[argi]), ""); |
| 232 | } else if (arg == "--keep-prefix") { |
| 233 | opts.keep_include_path = true; |
| 234 | } else if (arg == "--strict-json") { |
| 235 | opts.strict_json = true; |
| 236 | } else if (arg == "--allow-non-utf8") { |
| 237 | opts.allow_non_utf8 = true; |
| 238 | } else if (arg == "--natural-utf8") { |
| 239 | opts.natural_utf8 = true; |
| 240 | } else if (arg == "--go-namespace") { |
nothing calls this directly
no test coverage detected