Skip to content

Commit

Permalink
rust: Remove build dependency on protoc (#104)
Browse files Browse the repository at this point in the history
The protobuf project does not publish `protoc` binaries for 32-bit ARM
hosts, which complicates our compilation tooling for ARM. This problem
can be avoided completely by committing the generated interface
bindings so that crates that depend on `linkerd2-proxy-api` don't need
any build dependencies.

This change removes the `client`, `server`, and `transport` features.
Client and server bindings are now always generated for gRPC services.
The `transport` feature is removed, since it cannot be optional if the
generated code is stored in the repo. We don't want to require tonic's
transport feature because it pulls in many dependencies that we don't
really need.

Signed-off-by: Oliver Gould <[email protected]>
  • Loading branch information
olix0r authored Apr 10, 2022
1 parent 7af892a commit ee612d7
Show file tree
Hide file tree
Showing 18 changed files with 2,016 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Gopkg.lock linguist-generated=false
go/**/*.pb.go linguist-generated=true
src/gen/*.rs linguist-generated=true
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ jobs:
container:
image: docker://rust:1.59.0-buster
steps:
- run: rustup component add clippy
- uses: actions/checkout@v3
- run: rustup component add rustfmt # Needed for the rustfmt feature.
- run: make rs
- run: make fetch
- run: make clippy

rust_audit:
name: Rust audit
Expand All @@ -31,15 +32,6 @@ jobs:
with:
command: check ${{ matrix.checks }}

rust_lint:
name: Rust lint
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup component add clippy rustfmt
- run: make clippy

go_build:
name: Go build
timeout-minutes: 5
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# `linkerd2-proxy-api` changes

## v0.5.0

* Rust: Remove the build-time dependency on `protoc`
* Rust: Remove the `client`, `server`, and `transport` features

## v0.4.0

* Go: Update `google.golang.org/protobuf` to v1.28
Expand Down
29 changes: 14 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linkerd2-proxy-api"
version = "0.4.0"
version = "0.5.0"
authors = ["Linkerd Developers <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
Expand All @@ -14,22 +14,15 @@ rust-version = "1.59"
[features]
default = []

# Generate code that is compatible with Tonic's `transport` module.
transport = ["tonic-build/transport", "tonic/transport"]

# Enable generation of arbitrary protos with quickcheck.
arbitrary = ["quickcheck"]

# Determines whether clients or servers are built
client = ["transport"]
server = ["transport"]

destination = ["http_types", "net", "prost-types"]
destination = ["http_types", "net", "prost-types", "tonic/codegen"]
http_types = ["http", "thiserror"]
identity = ["prost-types"]
inbound = ["net", "prost-types"]
identity = ["prost-types", "tonic/codegen"]
inbound = ["net", "prost-types", "tonic/codegen"]
net = ["ipnet", "thiserror"]
tap = ["h2", "http_types", "net", "prost-types"]
tap = ["h2", "http_types", "net", "prost-types", "tonic/codegen"]

[dependencies]
h2 = { version = "0.3", optional = true }
Expand All @@ -39,7 +32,13 @@ prost = "0.10"
prost-types = { version = "0.10", optional = true }
quickcheck = { version = "1", default-features = false, optional = true }
thiserror = { version = "1", optional = true }
tonic = { version = "0.7", default-features = false, features = ["prost", "codegen"] }

[build-dependencies]
tonic-build = { version = "0.7", default-features = false, features = ["prost"] }
[dependencies.tonic]
version = "0.7"
default-features = false
features = ["prost"]

[dev-dependencies.tonic-build]
version = "0.7"
default-features = false
features = ["prost"]
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ fetch: Cargo.toml

.PHONY: rs
rs: fetch $(PROTOC)
cargo test --test=bootstrap
cargo check --all-features --frozen $(RELEASE)

.PHONY: clippy
clippy: fetch $(PROTOC)
clippy: rs
for api in destination http_types identity inbound net tap ; do \
for kind in arbitrary client server ; do \
$(CARGO) clippy --frozen $(RELEASE) --features=$$api,$$kind --all-targets ; \
done ; \
$(CARGO) clippy --frozen $(RELEASE) --features=$$api,arbitrary --all-targets ; \
done

.PHONY: go
Expand Down
49 changes: 0 additions & 49 deletions build.rs

This file was deleted.

23 changes: 0 additions & 23 deletions src/gen.rs

This file was deleted.

Loading

0 comments on commit ee612d7

Please sign in to comment.