Made GRPC generator missing into a warning.

Change-Id: Iceb1f5b78cff6227905b8a23eb70e9ef6ce909ed
This commit is contained in:
Wouter van Oortmerssen 2016-12-14 10:32:44 -08:00
parent 2a7a44be33
commit ccba2edb7c
1 changed files with 13 additions and 6 deletions

View File

@ -95,9 +95,14 @@ const Generator generators[] = {
const char *g_program_name = nullptr; const char *g_program_name = nullptr;
flatbuffers::Parser *g_parser = nullptr; flatbuffers::Parser *g_parser = nullptr;
static void Warn(const std::string &warn, bool show_exe_name = true) {
if (show_exe_name) printf("%s: ", g_program_name);
printf("warning: %s\n", warn.c_str());
}
static void Error(const std::string &err, bool usage, bool show_exe_name) { static void Error(const std::string &err, bool usage, bool show_exe_name) {
if (show_exe_name) printf("%s: ", g_program_name); if (show_exe_name) printf("%s: ", g_program_name);
printf("%s\n", err.c_str()); printf("error: %s\n", err.c_str());
if (usage) { if (usage) {
printf("usage: %s [OPTION]... FILE... [-- FILE...]\n", g_program_name); printf("usage: %s [OPTION]... FILE... [-- FILE...]\n", g_program_name);
for (size_t i = 0; i < sizeof(generators) / sizeof(generators[0]); ++i) for (size_t i = 0; i < sizeof(generators) / sizeof(generators[0]); ++i)
@ -139,6 +144,7 @@ static void Error(const std::string &err, bool usage, bool show_exe_name) {
" --raw-binary Allow binaries without file_indentifier to be read.\n" " --raw-binary Allow binaries without file_indentifier to be read.\n"
" This may crash flatc given a mismatched schema.\n" " This may crash flatc given a mismatched schema.\n"
" --proto Input is a .proto, translate to .fbs.\n" " --proto Input is a .proto, translate to .fbs.\n"
" --grpc Generate GRPC interfaces for the specified languages\n"
" --schema Serialize schemas instead of JSON (use with -b)\n" " --schema Serialize schemas instead of JSON (use with -b)\n"
" --conform FILE Specify a schema the following schemas should be\n" " --conform FILE Specify a schema the following schemas should be\n"
" an evolution of. Gives errors if not.\n" " an evolution of. Gives errors if not.\n"
@ -373,13 +379,14 @@ int main(int argc, const char *argv[]) {
} }
if (grpc_enabled) { if (grpc_enabled) {
if (generators[i].generateGRPC != nullptr) { if (generators[i].generateGRPC != nullptr) {
if (!generators[i].generateGRPC(*g_parser, output_path, filebase)) { if (!generators[i].generateGRPC(*g_parser, output_path,
Error(std::string("Unable to generate GRPC interface for") + filebase)) {
generators[i].lang_name); Error(std::string("Unable to generate GRPC interface for") +
generators[i].lang_name);
} }
} else { } else {
Error(std::string("GRPC interface generator not implemented for ") + Warn(std::string("GRPC interface generator not implemented for ")
generators[i].lang_name); + generators[i].lang_name);
} }
} }
} }