| Crates.io | protoweld |
| lib.rs | protoweld |
| version | 0.1.2 |
| created_at | 2026-01-05 05:18:16.487288+00 |
| updated_at | 2026-01-05 05:43:41.189874+00 |
| description | A tool for automating Protocol Buffer compilation across multiple projects and programming languages |
| homepage | https://github.com/XACMJudge/protoweld |
| repository | https://github.com/XACMJudge/protoweld |
| max_upload_size | |
| id | 2023128 |
| size | 118,607 |
Protoweld is a powerful command-line tool designed to automate the compilation of Protocol Buffer (.proto) files into language-specific code for multiple projects. It simplifies the process of managing and generating protobuf code across different programming languages and projects, making it ideal for microservices architectures and multi-language codebases.
.proto files to Go, .NET (C#), and RustProtoweld is available on crates.io and can be installed using Cargo:
cargo install protoweld
After installation, the protoweld binary will be available in your $HOME/.cargo/bin directory (make sure it's in your PATH).
Protoweld requires the following tools to be installed on your system:
cargo install. Install Rustprotoc) - Required for compiling proto files. Installation GuideIf you prefer to build from source or want to use the latest development version:
git clone https://github.com/XACMJudge/protoweld.git
cd protoweld
cargo build --release
target/release/protoweldgo install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
cargo install protoc-gen-tonic
cargo install protoc-gen-prost
Protoweld uses a YAML configuration file to define projects and their compilation settings. The configuration file structure is as follows:
active_projects:
- path: <project-name>
lang: <GoLang|DotNet|Rust>
associated_proto_files:
- <path-to-proto-file-1>
- <path-to-proto-file-2>
compiled_proto_folder: "<output-folder-path>"
plugin_path: "<optional-plugin-path>"
compile_options:
"<option-key>": "<option-value>"
"<option-key>": ""
path (string): A unique identifier for the projectlang (string): Target programming language. Must be one of: GoLang, DotNet, or Rustassociated_proto_files (array of strings): List of paths to .proto files to compilecompiled_proto_folder (string): Output directory where generated code will be placedplugin_path (string): Path to a custom gRPC plugin (required for .NET projects)compile_options (map): Additional compilation options passed to protocThe compile_options field allows you to pass custom flags to the Protocol Buffers compiler. Common options include:
-I or --proto_path: Specify import paths for proto files--descriptor_set_out: Generate a descriptor set file--include_imports: Include all imported files in the descriptor set--experimental_allow_proto3_optional: Enable proto3 optional fieldsNote: The output flags (--go_out, --csharp_out, --prost_out, etc.) are automatically handled by Protoweld and should not be specified in compile_options.
Run Protoweld with the path to your configuration file:
protoweld -f <path-to-config.yaml>
Or using the short form:
protoweld -f config.yaml
protoweld -f input/example.yaml
Here's a complete example configuration file (input/example.yaml):
active_projects:
- path: database-server
associated_proto_files:
- ./entities/protos/database-server/operations.proto
compiled_proto_folder: "./database-server/"
lang: GoLang
compile_options:
"-I": entities
- path: security
lang: DotNet
associated_proto_files:
- ./entities/protos/security/users.proto
- ./entities/protos/security/auth.proto
- ./entities/protos/schemas/security.proto
- ./entities/protos/database-server/operations.proto
compiled_proto_folder: "./security/Protos"
plugin_path: /home/user/.nuget/packages/grpc.tools/2.72.0/tools/linux_x64/grpc_csharp_plugin
compile_options:
"-I": entities
"--descriptor_set_out": ./security/descriptors.pb
"--include_imports": ""
"--experimental_allow_proto3_optional": ""
- path: judge-server
lang: Rust
associated_proto_files:
- ./entities/protos/database-server/operations.proto
compiled_proto_folder: "./judge-server/protos"
compile_options:
"-I": entities
Protoweld compiles .proto files to Go code using:
protoc-gen-go for message typesprotoc-gen-go-grpc for gRPC service definitionsGenerated Output: Go source files in the specified compiled_proto_folder
Protoweld compiles .proto files to C# code using:
protoc with --csharp_out for message typesgrpc_csharp_plugin for gRPC service definitionsRequirements:
plugin_path pointing to the grpc_csharp_plugin executable~/.nuget/packages/grpc.tools/<version>/tools/<platform>/grpc_csharp_pluginGenerated Output: C# source files in the specified compiled_proto_folder
Protoweld compiles .proto files to Rust code using:
protoc-gen-prost for message types (Prost)protoc-gen-tonic for gRPC service definitions (Tonic)Special Features:
mod.rs files for each packageGenerated Output:
compiled_proto_foldermod.rs structurepackage declarationsprotoc command with language-specific flagscompiled_proto_folder for each projectProtoweld applies extensive transformations to the Rust-generated files mainly to ensure a smooth developer experience with tools like rust-analyzer and to make the generated code ready for ongoing development, not just for one-off code generation.
By default, when the gRPC plugins (protoc-gen-prost for message types and protoc-gen-tonic for services) generate Rust code from .proto files, they output raw .rs files that closely mirror the original proto package and file structure. However, these raw files often lack a module structure compatible with how Rust and its tooling (such as rust-analyzer and cargo) expect code to be organized. For example, there may be missing mod.rs files, incorrect or missing module imports, and file names that don't align with idiomatic Rust conventions.
Why does Protoweld reorganize these files?
mod.rs files or the new directory-as-module conventions. The flat file structure output by the plugins does not provide this, making IDE navigation, auto-completion, and refactoring much less effective.mod declarations entirely, which can break module imports or make it difficult to include generated code in your own crate.mod.rs files, renaming files to valid Rust identifiers, and setting up imports and visibility declarations.Summary: Protoweld's file transformations are primarily driven by the needs of real-world Rust development, ensuring that generated Protobuf code is both compiler- and IDE-friendly, resulting in a much smoother workflow for developers.
protoweld/
├── Cargo.toml # Rust project configuration
├── README.md # This file
├── LICENSE # License file
├── input/ # Example configuration files
│ └── example.yaml # Example YAML configuration
└── src/ # Source code
├── main.rs # Entry point
├── lib.rs # Library root
├── types/ # Type definitions
│ ├── mod.rs
│ └── cli.rs # CLI argument parsing
├── parser/ # YAML configuration parser
│ ├── mod.rs
│ ├── protoweld_parser.rs
│ └── types.rs # Parser types and structures
├── executor/ # Code generation executor
│ ├── mod.rs
│ └── protoweld_executor.rs
├── compilers/ # Language-specific compilers
│ ├── mod.rs
│ ├── protobuf_compiler.rs # Base compiler trait
│ ├── shared.rs # Compiler factory
│ └── langs_compilers/
│ ├── mod.rs
│ ├── compiler_types.rs
│ ├── go_compiler.rs
│ ├── dotnet_compiler.rs
│ └── rust_compiler.rs
└── os/ # OS abstraction layer
├── mod.rs
├── types.rs # OS manager trait
├── shared.rs # OS manager factory
└── unix_manager.rs
Protoweld provides clear error messages for common issues:
package declarationsprotoc error messagesEnsure all required tools for your target language are installed and available in your PATH:
protoc-gen-go and protoc-gen-go-grpcdotnet and protocprotoc-gen-tonic and protoc-gen-prostYour .proto file must include a package declaration. Example:
syntax = "proto3";
package mypackage;
message MyMessage {
// ...
}
This is specially required for Rust projects.
For .NET projects, you must specify the plugin_path to the grpc_csharp_plugin executable. Find it in your NuGet packages folder or install gRPC Tools.
Protoweld is actively being developed with the following features planned:
associated_proto_files to automatically discover and include proto files (e.g., ./protos/**/*.proto or ./entities/**/*.proto)grpcio-tools)protoc-gen-java and protoc-gen-grpc-java)protoc-gen-ts and @grpc/proto-loader)protoc-gen-cpp)protoc-gen-php)grpc-tools)protoc-gen-swift)$HOME/.cargo/bin, $HOME/.local/bin, NuGet packages, npm global packages) to reduce manual configurationcargo watch or file system watchersContributions are welcome! If you'd like to help implement any of these features or have other ideas, please feel free to submit a Pull Request or open an issue to discuss.
See the LICENSE file for details.
Protoweld is built to simplify Protocol Buffer compilation workflows in multi-language projects, particularly useful for microservices architectures and distributed systems.