src/protovm/compiler/README.md
The ProtoVM Compiler is a CLI tool that compiles high-level transformation commands (CompileConfig) into low-level bytecode instructions (VmProgram) executable by the ProtoVM.
The compiler CLI (protovm_compiler) is the entry point for compilation.
protovm_compiler [-I <proto_path>] <file1.proto> [<file2.proto> ...]
.proto files that contain the definitions of the source and destination messages.-I / --proto_path: Specifies directories in which to search for imports. Multiple -I flags can be provided.stdin: The compiler reads the CompileConfig textproto from standard input.stdout: The compiler outputs the compiled binary VmProgram to standard output.stderr: Any compilation or validation errors are printed to standard error.protovm_compiler \
-I external/perfetto \
-I external/perfetto/buildtools/protobuf/src \
protos/perfetto/trace/trace_packet.proto \
protos/perfetto/trace/android/winscope_extensions_impl.proto \
<compile_config.textproto
>program.pb
The compiler is structured into three main components:
graph TD
main[main.cc - CLI Entrypoint] -->|Loads descriptors & parse compile config| Compiler[Compiler - Front-end]
Compiler -->|Delegates translation into VmInstruction| Emitter[InstructionEmitter - Back-end]
Emitter -->|Translates field IDs| Pool[DescriptorPool]
Emitter -->|Emits| Program[VmProgram Binary]
main.cc (CLI Entrypoint).proto files provided as arguments into a serialized file descriptor.CompileConfig textproto from standard input (stdin).CompilerCompiler (Front-end)CompileConfig textproto.set, del, merge, enter_scope).InstructionEmitter.InstructionEmitter (Back-end)SelectByKey, MergeByKey, etc.) into the proper sequence of low-level VmInstructions.