2016-02-09 15:08:54 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <google/protobuf/compiler/plugin.h>
|
2008-08-22 20:38:05 +00:00
|
|
|
#include <google/protobuf/compiler/command_line_interface.h>
|
2013-11-16 17:11:48 -05:00
|
|
|
#include <protoc-c/c_generator.h>
|
2008-08-22 20:38:05 +00:00
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
google::protobuf::compiler::c::CGenerator c_generator;
|
2013-11-19 00:11:05 -08:00
|
|
|
|
2016-02-09 15:08:54 +01:00
|
|
|
std::string invocation_name = argv[0];
|
|
|
|
std::string invocation_basename = invocation_name.substr(invocation_name.find_last_of("/") + 1);
|
2018-09-02 18:03:48 -04:00
|
|
|
const std::string standalone_name = "protoc-c";
|
2016-02-09 15:08:54 +01:00
|
|
|
|
2018-09-02 18:03:48 -04:00
|
|
|
if (invocation_basename == standalone_name) {
|
2016-02-09 15:08:54 +01:00
|
|
|
google::protobuf::compiler::CommandLineInterface cli;
|
|
|
|
cli.RegisterGenerator("--c_out", &c_generator, "Generate C/H files.");
|
|
|
|
cli.SetVersionInfo(PACKAGE_STRING);
|
|
|
|
return cli.Run(argc, argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return google::protobuf::compiler::PluginMain(argc, argv, &c_generator);
|
2008-08-22 20:38:05 +00:00
|
|
|
}
|