Rust lib for fetching official protoc (Protocol Buffer compiler) releases

Overview

protoc-fetcher

Rust library for fetching official Protocol Buffer compiler (protoc) releases, pegged to a specific version.

protoc-fetcher downloads an official release of the protobuf compiler (protoc) and returns the path to it.

use std::env;
use std::path::Path;

// From within build.rs...
let protoc_version = "21.5";
let out_dir = env::var("OUT_DIR").unwrap();
let protoc_path = protoc_fetcher::protoc(protoc_version, Path::new(&out_dir));

The release archive matching the given version will be downloaded, and the protoc binary will be extracted into a subdirectory of out_dir. You can choose a version from the release page, for example "21.5". Don't prefix it with a "v".

out_dir can be anywhere you want, but if calling this function from a build script, you should probably use the OUT_DIR env var (which is set by Cargo automatically for build scripts).

A previously downloaded protoc binary of the correct version will be reused if already present in out_dir.

Usage with Tonic or Prost

If you are using tonic-build (or prost-build), you can instruct it to use the fetched protoc binary by setting the PROTOC env var.

use std::env;
use std::path::Path;

let out_dir = env::var("OUT_DIR").unwrap();
let path_to_my_protos = Path::new("a/b/c");
let protoc_path = protoc_fetcher::protoc("21.2", Path::new(&out_dir)).unwrap();
env::set_var("PROTOC", &protoc_path);
tonic_build::compile_protos(path_to_my_protos);
You might also like...
P523 is a classic compiler course taught by R. Kent Dybvig.

P523 is a classic compiler course taught by R. Kent Dybvig. This repo implements the course using Rust, provides a framework to help you master P523.

Bril: A Compiler Intermediate Representation for Learning

Bril: A Compiler Intermediate Representation for Learning Bril (the Big Red Intermediate Language) is a compiler IR made for teaching CS 6120, a grad

The first cesil transpiler/compiler in 50 years!
The first cesil transpiler/compiler in 50 years!

CesilC CESIL, or Computer Education in Schools Instruction Language, is a programming language designed to introduce pupils in British secondary schoo

ArbOS operating system, to run at Layer 2 on Arbitrum chains. Also a compiler for Mini, the language in which ArbOS is written.

ArbOS and Mini compiler ArbOS is the "operating system" that runs at Layer 2 on an Arbitrum chain, to manage the chain's operation, maintain security,

A tool & library to help you with the compiler course.

Compiler Course Helper Support: eliminate left recursion (require grammar with no cycles or ϵ-production) calculate nullable, first sets, follow, sets

Harvest Moon: (More) Friends of Mineral Town event script compiler

mary This is a script compiler for Harvest Moon: Friends of Mineral Town and Harvest Moon: More Friends of Mineral Town for the GBA. The end goal is f

The compiler for Gera, a statically typed and garbage collected programming language.

Gera The compiler for Gera, a satically typed and garbage collected programming language. Currently WIP (Work in progress). Progress This is a rough o

Rust bindings to the Wolfram Symbolic Transport Protocol (WSTP)

wstp Bindings to the Wolfram Symbolic Transfer Protocol (WSTP) library. This crate provides a set of safe and ergonomic bindings to the WSTP library,

Rust libraries for Bluesky's AT Protocol services. NOT STABLE (yet)

ATrium ATrium is a collection of Rust libraries designed to work with the AT Protocol, providing a versatile and coherent ecosystem for developers. Th

Comments
  • Windows target support

    Windows target support

    Thanks for the crate, that's exactly what I was looking for!

    It is possible to add Windows targets support?

    Also I used cfg in this PR instead of ENV variables to explicitly define platforms supported by protoc.

    opened by aleasims 0
Owner
Arcanyx Technical Wizardry LLC
Arcanyx open source projects
Arcanyx Technical Wizardry LLC
The api for interacting with `libinput_macros.nro`, along with the releases of the plugin.

Input Macros Plugin and API This plugin and related API implements a mechanism of assigning a complex series of button inputs and stick positions to a

null 5 Aug 24, 2023
Uma lib para a API do Brasil API (para o Rust)

Uma lib para a API do BrasilAPI (para o Rust) Features CEP (Zip code) DDD Bank CNPJ IBGE Feriados Nacionais Tabela FIPE ISBN Registros de domínios br

Pedro Augusto 6 Dec 13, 2022
A tiny Rust std-lib for Linux x86_64 and aarch64

Tiny std Like a bad, probably buggy, tiny standard library for Linux. When it's appropriate If you are actually trying to do something solid, checkout

null 4 Dec 17, 2022
Powerful math lib for Vector, Matrix and Quaternion operations

An opinionated, powerful math lib for Vector2, Vector3, Matrix and Quaternion operations Vector2 Add, Sub, Div, Mul, Eq Distance Move towards target a

O(ʒ) 4 Mar 28, 2022
Powerful math lib for Vector, Matrix and Quaternion operations

An opinionated, powerful math lib for Vector2, Vector3, Matrix and Quaternion operations Vector2 Add, Sub, Div, Mul, Eq Distance Move towards target a

O(ʒ) 4 Mar 28, 2022
🚃 lib for CLI utilities, printing, and error handling

axocli Common code for setting up a CLI App and handling errors/printing. Example See examples/axoapp.rs for a walkthrough/example. Some various inter

axo 5 Apr 4, 2023
The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language.

rcc The Rust Compiler Collection is a collection of compilers for various languages, written with The Rust Programming Language. Compilers Language Co

null 2 Jan 17, 2022
A additional Rust compiler pass to detect memory safe bugs of Rust programs.

SafeDrop A additional Rust compiler pass to detect memory safe bugs of Rust programs. SafeDrop performs path-sensitive and field-sensitive inter-proce

Artisan-Lab  (Fn*) 5 Nov 25, 2022
Take your first step in writing a compiler. Implemented in Rust.

first-step-rust Take your first step in writing a compiler, using Rust. Building from Source Make sure the Rust toolchain is installed on your compute

PKU Compiler Course 13 Aug 28, 2022
A rust version of "the super tiny compiler"

The (Rust) super tiny compiler This project is a rust version of the super tiny compiler (the original one (JS) was created by Jamie Kyle). The output

Eduardo Stuart 6 Dec 25, 2022