Skip to content

Commit

Permalink
feat(cargo workspace): unifies crates as workspace
Browse files Browse the repository at this point in the history
Combines all rust crates under a single workspace
to simplify management of rust packaging, with
the exception of ebpf which needs independent
tooling and packages to properly build.

Author: Evan Jones <[email protected]>
  • Loading branch information
EandrewJones committed Apr 19, 2024
1 parent 226f24e commit 38ca8d3
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 165 deletions.
330 changes: 231 additions & 99 deletions dataplane/Cargo.lock → Cargo.lock

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[workspace]
members = [
"dataplane/api-server",
"dataplane/common",
"dataplane/loader",
"dataplane/xtask",
"tools/udp-test-server",
]

[workspace.package]
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/kubernetes-sigs/blixt"
version = "0.3.0"

[workspace.dependencies]
anyhow = { version = "1", default-features = false }
api-server = { version = "0.3.0", path = "./dataplane/api-server" }
aya = { version = "0.12.0", default-features = false }
aya-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false }
aya-log = { version = "0.2.0", default-features = false }
aya-log-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false }
clap = { version = "4.4", default-features = true }
common = { version = "0.3.0", path = "./dataplane/common" }
env_logger = { version = "0.11", default-features = false }
libc = { version = "0.2", default-features = false }
loader = { version = "0.3.0", path = "./dataplane/loader" }
log = { version = "0.4", default-features = false }
memoffset = { version = "0.9", default-features = false }
network-types = { version = "0.0.5", default-features = false }
prost = { version = "0.12.4", default-features = false }
regex = { version = "1", default-features = false }
tokio = { version = "1.32.0", default-features = false }
tonic = { version = "0.11.0", default-features = false }
tonic-build = { version = "0.11.0", default-features = false }
tonic-health = { version = "0.11.0", default-features = false }
udp-test-server = { version = "0.3.0", path = "./tools/udp-test-server" }
xtask = { version = "0.3.0", path = "./dataplane/xtask" }

[lints]
workspace = true
21 changes: 3 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,17 @@ vet: ## Run go vet against code.
lint:
golangci-lint run

.PHONY: check.format.rust.helper
check.format.rust.helper:
@echo "Checking formatting $(DIRECTORY)..."
cargo fmt --manifest-path $(DIRECTORY)/Cargo.toml --all -- --check

.PHONY: fix.format.rust.helper
fix.format.rust.helper:
@echo "Fixing formatting $(DIRECTORY)..."
cargo fmt --manifest-path $(DIRECTORY)/Cargo.toml --all

.PHONY: fix.format.rust
fix.format.rust:
@find . -name 'Cargo.toml' -type f -exec dirname {} \; | xargs -I {} $(MAKE) fix.format.rust.helper DIRECTORY={}
cargo fmt --manifest-path Cargo.toml --all

.PHONY: check.format.rust
check.format.rust:
@find . -name 'Cargo.toml' -type f -exec dirname {} \; | xargs -I {} $(MAKE) check.format.rust.helper DIRECTORY={}

.PHONY: lint.rust.helper
lint.rust.helper:
@echo "Linting $(DIRECTORY)..."
@cd $(DIRECTORY) && cargo clippy --all -- -D warnings
cargo fmt --manifest-path Cargo.toml --all -- --check

.PHONY: lint.rust
lint.rust:
@find . -name 'Cargo.toml' -type f -exec dirname {} \; | xargs -I {} $(MAKE) lint.rust.helper DIRECTORY={}
cargo clippy --all -- -D warnings

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
Expand Down
2 changes: 0 additions & 2 deletions dataplane/Cargo.toml

This file was deleted.

30 changes: 17 additions & 13 deletions dataplane/api-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[package]
name = "api-server"
version = "0.1.0"
edition = "2021"
publish = false
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
prost = "0.12.4"
tonic = "0.11.0"
tonic-health = "0.11.0"
anyhow = "1"
log = "0.4"
aya = { version = "0.12.0", features=["async_tokio"] }
tokio = { version = "1.32", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }
common = { path = "../common", features=["user"] }
regex = "1"
libc = "0.2"
anyhow = { workspace = true }
aya = { workspace = true, features = ["async_tokio"] }
common = { workspace = true, features = ["user"] }
libc = { workspace = true }
log = { workspace = true }
prost = { workspace = true }
regex = { workspace = true, default-features = true }
tokio = { workspace = true , features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }
tonic = { workspace = true, features = ["tls"] }
tonic-health = { workspace = true }

[build-dependencies]
tonic-build = { workspace = true }
16 changes: 9 additions & 7 deletions dataplane/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[package]
name = "common"
version = "0.1.0"
edition = "2021"
publish = false
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[lib]
name = "common"
path = "src/lib.rs"

[features]
default = []
user = [ "aya" ]

[dependencies]
aya = { version = ">=0.11", optional=true }

[lib]
path = "src/lib.rs"
aya = { workspace = true, optional=true }
29 changes: 15 additions & 14 deletions dataplane/loader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[package]
name = "loader"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
aya = { version = "0.12.0", features=["async_tokio"] }
aya-log = "0.2.0"
common = { path = "../common", features=["user"] }
clap = { version = "4.4", features = ["derive"] }
env_logger = "0.11"
log = "0.4"
tokio = { version = "1.32.0", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }
api-server = { path = "../api-server" }
anyhow = "1"
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[[bin]]
name = "loader"
path = "src/main.rs"

[dependencies]
anyhow = { workspace = true }
api-server = { workspace = true }
aya = { workspace = true , features=["async_tokio"] }
aya-log = { workspace = true }
common = { workspace = true, features=["user"] }
clap = { workspace = true, features = ["derive"] }
env_logger = { workspace = true }
log = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }
20 changes: 11 additions & 9 deletions dataplane/xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[package]
name = "xtask"
version = "0.1.0"
edition = "2021"
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
anyhow = "1"
clap = { version = "4.4", features = ["derive"] }
prost = "0.12.4"
tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] }
tonic = "0.11.0"
api-server = { path = "../api-server" }
tonic-build = "0.11.0"
api-server = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true, features = ["derive"] }
prost = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tonic = { workspace = true }
tonic-build = { workspace = true, features = ["prost"] }
6 changes: 3 additions & 3 deletions tools/udp-test-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "udp-test-server"
version = "0.1.0"
edition = "2021"
edition.workspace = true
version.workspace = true
publish = false

[dependencies]
tokio = { version = "1", features = ["full"] }
tokio = { workspace = true, features = ["full"] }

0 comments on commit 38ca8d3

Please sign in to comment.