Code Generation
Generate serialization code from proto files using the struct-frame command-line tool.
Basic Usage
# Generate Python codepython -m struct_frame messages.proto --build_py
# Generate C codepython -m struct_frame messages.proto --build_c
# Generate multiple languagespython -m struct_frame messages.proto --build_c --build_cpp --build_py --build_tsLanguage Flags
| Flag | Language | Output |
|---|---|---|
--build_c | C | <name>.structframe.h |
--build_cpp | C++ | <name>.structframe.hpp |
--build_ts | TypeScript | <name>.structframe.ts |
--build_py | Python | <name>.py (in struct_frame/generated/) |
--build_js | JavaScript | <name>.structframe.js |
--build_csharp | C# | <PackageName>/Messages/*.cs, <PackageName>/Enums/*.cs |
--build_gql | GraphQL | <name>.structframe.graphql |
Output Paths
Default output is generated/<language>/. Customize with path options:
# Custom C outputpython -m struct_frame messages.proto --build_c --c_path src/generated/
# Multiple languages, different pathspython -m struct_frame messages.proto \ --build_c --c_path firmware/generated/ \ --build_py --py_path server/generated/Common Patterns
Single Language
python -m struct_frame robot.proto --build_cpp --cpp_path include/Embedded + Server
python -m struct_frame messages.proto \ --build_c --c_path embedded/messages/ \ --build_py --py_path server/messages/Frontend + Backend
python -m struct_frame api.proto \ --build_ts --ts_path frontend/src/generated/ \ --build_py --py_path backend/generated/All Languages
python -m struct_frame messages.proto \ --build_c --build_cpp --build_ts --build_py --build_js --build_csharp --build_gqlGenerated Files
Each language generates:
- Message/struct definitions
- Serialization code (where applicable)
- Frame parsing utilities (if using framing)
- SDK files (if
--sdkflag used)
See CLI Reference for complete details.