{"id":18440250,"url":"https://github.com/drowzy/protobuf_generate","last_synced_at":"2025-04-07T21:33:06.034Z","repository":{"id":61965637,"uuid":"554714256","full_name":"drowzy/protobuf_generate","owner":"drowzy","description":"Protobuf code generation as a mix task","archived":false,"fork":false,"pushed_at":"2025-02-25T07:00:13.000Z","size":84,"stargazers_count":14,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T01:05:47.008Z","etag":null,"topics":["elixir","protobuf"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drowzy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-20T09:09:59.000Z","updated_at":"2025-02-25T07:00:18.000Z","dependencies_parsed_at":"2024-11-06T06:31:46.601Z","dependency_job_id":"22847e9a-7b83-46a6-b3ee-4802b7d10a91","html_url":"https://github.com/drowzy/protobuf_generate","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"9e5b885634b393458cb6444cebc6b776d38966e1"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fprotobuf_generate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fprotobuf_generate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fprotobuf_generate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drowzy%2Fprotobuf_generate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drowzy","download_url":"https://codeload.github.com/drowzy/protobuf_generate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247732798,"owners_count":20986924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","protobuf"],"created_at":"2024-11-06T06:29:12.546Z","updated_at":"2025-04-07T21:33:00.994Z","avatar_url":"https://github.com/drowzy.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Protobuf.Generate\n\n![CI](https://github.com/drowzy/protobuf_generate/actions/workflows/ci.yml/badge.svg)\n[![Hex.pm Version](https://img.shields.io/hexpm/v/protobuf_generate.svg?style=flat-square)](https://hex.pm/packages/protobuf_generate)\n\n`protobuf.generate` is a mix task that allows you to generate Elixir code using [Protobuf](https://github.com/elixir-protobuf/protobuf) without using the `protoc-gen-elixir` plugin.\n\nThe generator calls `protoc` using `descriptor_set_out` to output a `FileDescriptorSet` into a temporary file for input to [Protobuf](https://github.com/elixir-protobuf/protobuf).\n\nThe difference between `protobuf.generate` and `protoc-gen-elixir` is that `protoc-gen-elixir` is called as a plugin to `protoc` and therefor executes in a\n_global_ context while `protobuf.generate` executes in the context of the _local_ project. \n\nBy executing in the context of the local project:\n\n* Extensions that needs to be populated during code generation are picked up automatically by `Protobuf.load_extensions/0` (which is not possible when using `protoc-gen-elixir`).\n\n* Integration into the codegen by using generator plugins. See `ProtobufGenerate.Plugin`\n\n## Prerequisites\n\n* [Protoc](https://github.com/protocolbuffers/protobuf#protocol-compiler-installation) (protocol buffer compiler) is required to be installed. [Download and install](https://grpc.io/docs/protoc-installation/) the protocol buffer compiler (protoc).\n\n## Installation\n\nThis package can be installed by adding `protobuf_generate` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:protobuf_generate, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\n`mix protobuf.generate` supports the same options as [`protoc-gen-elixir`](https://github.com/elixir-protobuf/protobuf#generate-elixir-code)\n\n### Arguments\n\n  * `file` - One or more `.proto` files to compile\n\n### Required options\n\n  * `--output-path` - Path to output directory\n\n### Optional options\n\n  * `--include-path` - Specify the directory in which to search for imports. Eqvivalent to `protoc` `-I` flag.\n\n  * `--tranform-module` - Module to do custom encoding/decoding for messages. See `Protobuf.TransformModule` for details.\n\n  * `--package-prefix` - Prefix generated Elixir modules. For example prefix modules with: `MyApp.Protos` use `--package-prefix=my_app.protos`.\n\n  * `--generate-descriptors` - Includes raw descriptors in the generated modules\n\n  * `--one-file-per-module` - Changes the way files are generated into directories. This option creates a file for each generated Elixir module.\n\n  * `--include-documentation` - Controls visibility of documentation of the generated modules. Setting `true` will not  have `@moduleoc false`\n\n  * `--plugins` - Generator plugins. If you write services in protobuf, you can generate gRPC code by passing `--plugins=ProtobufGenerate.Plugins.GRPC`.\n\n\n```shell\n$ mix protobuf.generate --output-path=./lib --include-path=./priv/protos helloworld.proto\n$ mix protobuf.generate \\\n  --include-path=priv/proto \\\n  --include-path=deps/googleapis \\\n  --generate-descriptors=true \\\n  --output-path=./lib \\\n  --plugins=ProtobufGenerate.Plugins.GRPCWithOptions \\\n  google/api/annotations.proto google/api/http.proto helloworld.proto\n```\n\n## Available plugins\n\n* `ProtobufGenerate.Plugins.GRPC` - Generate [gRPC](https://github.com/elixir-grpc/grpc) services\n* `ProtobufGenerate.Plugins.GRPCWithOptions` -  Generate [gRPC](https://github.com/elixir-grpc/grpc) services with method extension options.\n\n## Extensions\n\nExtensions in the current project are loaded automatically when running `mix protobuf.generate`. However they need to be already generated in order for `Protobuf.load_extensions/0` to pick them up.\n\n## Acknowledgements\n\n* [`protox`](https://github.com/ahamez/protox) for running `protoc` with `descriptor_set_out`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrowzy%2Fprotobuf_generate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrowzy%2Fprotobuf_generate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrowzy%2Fprotobuf_generate/lists"}