mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-24 11:11:02 -07:00 
			
		
		
		
	Better support for repeated fields in the config language. Add a helper
for showing all config fields in a proto.
This commit is contained in:
		| @@ -5,13 +5,14 @@ encoders = {} | ||||
|  | ||||
|  | ||||
| @Rule | ||||
| def protoencode_single(self, name, srcs: Targets, proto, symbol): | ||||
| def protoencode_single(self, name, srcs: Targets, proto, include, symbol): | ||||
|     if proto not in encoders: | ||||
|         r = cxxprogram( | ||||
|             name="protoencode_" + proto, | ||||
|             srcs=["scripts/protoencode.cc"], | ||||
|             cflags=["-DPROTO=" + proto], | ||||
|             cflags=["-DPROTO=" + proto, "-DINCLUDE="+include], | ||||
|             deps=[ | ||||
|                 "lib/core", | ||||
|                 "lib/config+proto_lib", | ||||
|                 "lib/fluxsource+proto_lib", | ||||
|                 "lib/fluxsink+proto_lib", | ||||
| @@ -41,12 +42,13 @@ def protoencode_single(self, name, srcs: Targets, proto, symbol): | ||||
|  | ||||
|  | ||||
| @Rule | ||||
| def protoencode(self, name, proto, srcs: TargetsMap, symbol): | ||||
| def protoencode(self, name, proto, include,srcs: TargetsMap, symbol): | ||||
|     encoded = [ | ||||
|         protoencode_single( | ||||
|             name=f"{k}_cc", | ||||
|             srcs=[v], | ||||
|             proto=proto, | ||||
|             include=include, | ||||
|             symbol=f"{symbol}_{k}_pb", | ||||
|         ) | ||||
|         for k, v in srcs.items() | ||||
|   | ||||
| @@ -3,12 +3,13 @@ | ||||
| #include <google/protobuf/io/zero_copy_stream_impl.h> | ||||
| #include <fstream> | ||||
| #include "fmt/format.h" | ||||
| #include "lib/core/globals.h" | ||||
| #include "tests/testproto.pb.h" | ||||
| #include "lib/config/config.pb.h" | ||||
| #include <sstream> | ||||
| #include <locale> | ||||
|  | ||||
| #define STRINGIFY(s) #s | ||||
| const std::string protoname = STRINGIFY(PROTO); | ||||
|  | ||||
| static uint32_t readu8(std::string::iterator& it, std::string::iterator end) | ||||
| { | ||||
| @@ -125,6 +126,7 @@ int main(int argc, const char* argv[]) | ||||
|  | ||||
|     output << "#include \"lib/core/globals.h\"\n" | ||||
|            << "#include \"lib/config/proto.h\"\n" | ||||
|            << "#include \"" STRINGIFY(INCLUDE) "\"\n" | ||||
|            << "#include <string_view>\n" | ||||
|            << "static const uint8_t " << name << "_rawData[] = {"; | ||||
|  | ||||
| @@ -143,11 +145,11 @@ int main(int argc, const char* argv[]) | ||||
|     output << "\n};\n"; | ||||
|     output << "extern const std::string_view " << name << "_data;\n"; | ||||
|     output << "const std::string_view " << name | ||||
|            << "_data = std::string_view((const char*)" << name << "_rawData, " << data.size() | ||||
|            << ");\n"; | ||||
|     output << "extern const ConfigProto " << name << ";\n"; | ||||
|     output << "const ConfigProto " << name << " = parseConfigBytes(" | ||||
|            << argv[3] << "_data);\n"; | ||||
|            << "_data = std::string_view((const char*)" << name << "_rawData, " | ||||
|            << data.size() << ");\n"; | ||||
|     output << "extern const " << protoname << " " << name << ";\n"; | ||||
|     output << "const " << protoname << " " << name << " = parseProtoBytes<" | ||||
|            << protoname << ">(" << argv[3] << "_data);\n"; | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user