From 2ee29356d1331c98c478b3bdfc49dad40eb48d9d Mon Sep 17 00:00:00 2001
From: Mike Rostecki <vadorovsky@protonmail.com>
Date: Mon, 17 Jul 2023 22:17:56 +0200
Subject: [PATCH] cargo: Define dependencies on the workspace level

This way we will avoid version mismatches and make differences in
features across our crates clearer.
---
 Cargo.toml                       | 37 ++++++++++++++++++++++++++++++++
 aya-bpf-macros/Cargo.toml        |  8 +++----
 aya-log-common/Cargo.toml        |  2 +-
 aya-log-ebpf-macros/Cargo.toml   | 10 ++++-----
 aya-log-parser/Cargo.toml        |  2 +-
 aya-log/Cargo.toml               | 16 +++++++-------
 aya-obj/Cargo.toml               | 18 ++++++++--------
 aya-tool/Cargo.toml              | 10 ++++-----
 aya/Cargo.toml                   | 28 ++++++++++++------------
 test/integration-test/Cargo.toml | 26 ++++++++++------------
 xtask/Cargo.toml                 | 18 ++++++++--------
 11 files changed, 104 insertions(+), 71 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 580e0a48..ebd00c92 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -40,6 +40,43 @@ default-members = [
     # CARGO_CFG_BPF_TARGET_ARCH={x86_64,aarch64,arm,riscv64}
 ]
 
+[workspace.dependencies]
+anyhow = "1"
+assert_matches = "1.5.0"
+async-io = { version = "1.3" }
+aya = { path = "aya", version = "0.11.0", features=["async_tokio"] }
+aya-bpf = { path = "bpf/aya-bpf" }
+aya-log = { path = "aya-log" }
+aya-log-common = { path = "aya-log-common", version = "0.1.13" }
+aya-log-parser = { path = "aya-log-parser" }
+aya-obj = { path = "aya-obj", version = "0.1.0" }
+aya-tool = { path = "aya-tool" }
+bindgen = "0.66"
+bitflags = "2.2.1"
+bytes = "1"
+cargo_metadata = { version = "0.15.4", default-features = true }
+clap = { version = "4", features = ["derive"] }
+core-error = "0.0.0"
+env_logger = "0.10"
+futures = { version = "0.3.12", default-features = false, features = ["std"] }
+hashbrown = "0.14"
+indoc = "2.0"
+lazy_static = "1"
+libc = { version = "0.2.105" }
+log = "0.4"
+num_enum = { version = "0.6", default-features = false }
+object = { version = "0.31", default-features = false }
+parking_lot = { version = "0.12.0", features = ["send_guard"] }
+proc-macro2 = "1"
+quote = "1"
+rbpf = "0.2.0"
+syn = "2"
+tempfile = "3"
+testing_logger = "0.1.1"
+thiserror = "1"
+tokio = { version = "1.24.0" }
+which = { version = "4.4.0", default-features = false }
+
 [profile.dev]
 panic = "abort"
 
diff --git a/aya-bpf-macros/Cargo.toml b/aya-bpf-macros/Cargo.toml
index 8d7ee76d..dd94bb9d 100644
--- a/aya-bpf-macros/Cargo.toml
+++ b/aya-bpf-macros/Cargo.toml
@@ -8,9 +8,9 @@ edition = "2021"
 proc-macro = true
 
 [dependencies]
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = { version = "2.0", features = ["full"] }
+proc-macro2 = { workspace = true }
+quote = { workspace = true }
+syn = { workspace = true, features = ["full"] }
 
 [dev-dependencies]
-aya-bpf = { path = "../bpf/aya-bpf" }
+aya-bpf = { workspace = true }
diff --git a/aya-log-common/Cargo.toml b/aya-log-common/Cargo.toml
index 3f757f7a..041ed15b 100644
--- a/aya-log-common/Cargo.toml
+++ b/aya-log-common/Cargo.toml
@@ -10,7 +10,7 @@ documentation = "https://docs.rs/aya-log"
 edition = "2021"
 
 [dependencies]
-num_enum = { version = "0.6", default-features = false }
+num_enum = { workspace = true }
 
 [lib]
 path = "src/lib.rs"
diff --git a/aya-log-ebpf-macros/Cargo.toml b/aya-log-ebpf-macros/Cargo.toml
index 88f5d550..daaf6955 100644
--- a/aya-log-ebpf-macros/Cargo.toml
+++ b/aya-log-ebpf-macros/Cargo.toml
@@ -4,11 +4,11 @@ version = "0.1.0"
 edition = "2021"
 
 [dependencies]
-aya-log-common = { path = "../aya-log-common" }
-aya-log-parser = { path = "../aya-log-parser" }
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = "2.0"
+aya-log-common = { workspace = true }
+aya-log-parser = { workspace = true }
+proc-macro2 = { workspace = true }
+quote = { workspace = true }
+syn = { workspace = true }
 
 [lib]
 proc-macro = true
diff --git a/aya-log-parser/Cargo.toml b/aya-log-parser/Cargo.toml
index f47cb9f3..1cd9786d 100644
--- a/aya-log-parser/Cargo.toml
+++ b/aya-log-parser/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.1.11-dev.0"
 edition = "2021"
 
 [dependencies]
-aya-log-common = { path = "../aya-log-common" }
+aya-log-common = { workspace = true }
 
 [lib]
 path = "src/lib.rs"
diff --git a/aya-log/Cargo.toml b/aya-log/Cargo.toml
index a4064b4a..07a79f34 100644
--- a/aya-log/Cargo.toml
+++ b/aya-log/Cargo.toml
@@ -11,16 +11,16 @@ documentation = "https://docs.rs/aya-log"
 edition = "2021"
 
 [dependencies]
-aya = { path = "../aya", version = "0.11.0", features = ["async_tokio"] }
-aya-log-common = { path = "../aya-log-common", version = "0.1.13" }
-thiserror = "1"
-log = "0.4"
-bytes = "1.1"
-tokio = { version = "1.24" }
+aya = { workspace = true }
+aya-log-common = { workspace = true }
+bytes = { workspace = true }
+log = { workspace = true }
+thiserror = { workspace = true }
+tokio = { workspace = true, features = ["rt"] }
 
 [dev-dependencies]
-env_logger = "0.10"
-testing_logger = "0.1.1"
+env_logger = { workspace = true }
+testing_logger = { workspace = true }
 
 [lib]
 path = "src/lib.rs"
diff --git a/aya-obj/Cargo.toml b/aya-obj/Cargo.toml
index 305e6008..0d642a21 100644
--- a/aya-obj/Cargo.toml
+++ b/aya-obj/Cargo.toml
@@ -11,19 +11,19 @@ documentation = "https://docs.rs/aya-obj"
 edition = "2021"
 
 [dependencies]
-bytes = "1"
-log = "0.4"
-object = { version = "0.31", default-features = false, features = [
+bytes = { workspace = true }
+core-error = { workspace = true }
+hashbrown = { workspace = true }
+log = { workspace = true }
+object = { workspace = true, default-features = false, features = [
     "elf",
-    "read_core",
+    "read_core"
 ] }
-hashbrown = { version = "0.14" }
-thiserror = { version = "1", default-features = false }
-core-error = { version = "0.0.0" }
+thiserror = { workspace = true, default-features = false }
 
 [dev-dependencies]
-assert_matches = "1.5.0"
-rbpf = "0.2.0"
+assert_matches = { workspace = true }
+rbpf = { workspace = true }
 
 [features]
 std = []
diff --git a/aya-tool/Cargo.toml b/aya-tool/Cargo.toml
index e8f98567..d70cca16 100644
--- a/aya-tool/Cargo.toml
+++ b/aya-tool/Cargo.toml
@@ -5,8 +5,8 @@ authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
 edition = "2021"
 
 [dependencies]
-bindgen = "0.66"
-clap = { version = "4", features = ["derive"] }
-anyhow = "1"
-thiserror = "1"
-tempfile = "3"
+bindgen = { workspace = true }
+clap = { workspace = true }
+anyhow = { workspace = true }
+thiserror = { workspace = true }
+tempfile = { workspace = true }
diff --git a/aya/Cargo.toml b/aya/Cargo.toml
index d2a39a77..9adf07c0 100644
--- a/aya/Cargo.toml
+++ b/aya/Cargo.toml
@@ -11,26 +11,26 @@ documentation = "https://docs.rs/aya"
 edition = "2021"
 
 [dependencies]
-async-io = { version = "1.3", optional = true }
-aya-obj = { path = "../aya-obj", version = "0.1.0", features = ["std"] }
-bitflags = "2.2.1"
-bytes = "1"
-lazy_static = "1"
-libc = { version = "0.2.105" }
-log = "0.4"
-object = { version = "0.31", default-features = false, features = [
+async-io = { workspace = true, optional = true }
+aya-obj = { workspace = true, features = ["std"] }
+bitflags = { workspace = true }
+bytes = { workspace = true }
+lazy_static = { workspace = true }
+libc = { workspace = true }
+log = { workspace = true }
+object = { workspace = true, default-features = false, features = [
     "elf",
     "read_core",
     "std",
 ] }
-parking_lot = { version = "0.12.0", features = ["send_guard"] }
-thiserror = "1"
-tokio = { version = "1.24.0", features = ["rt"], optional = true }
+parking_lot = { workspace = true }
+thiserror = { workspace = true }
+tokio = { workspace = true, features = ["rt"], optional = true }
 
 [dev-dependencies]
-assert_matches = "1.5.0"
-futures = { version = "0.3.12", default-features = false, features = ["std"] }
-tempfile = "3"
+assert_matches = { workspace = true }
+futures = { workspace = true }
+tempfile = { workspace = true }
 
 [features]
 default = []
diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml
index 298757c1..a48db995 100644
--- a/test/integration-test/Cargo.toml
+++ b/test/integration-test/Cargo.toml
@@ -6,23 +6,19 @@ publish = false
 
 [dependencies]
 anyhow = "1"
-assert_matches = "1.5.0"
-aya = { path = "../../aya" }
-aya-log = { path = "../../aya-log" }
-aya-obj = { path = "../../aya-obj" }
-libc = { version = "0.2.105" }
-log = "0.4"
-object = { version = "0.31", default-features = false, features = [
-    "elf",
-    "read_core",
-    "std",
-] }
-rbpf = "0.2.0"
-tokio = { version = "1.24", default-features = false, features = [
+assert_matches = { workspace = true }
+aya = { workspace = true }
+aya-log = { workspace = true }
+aya-obj = { workspace = true }
+libc = { workspace = true }
+log = { workspace = true }
+object = { workspace = true }
+rbpf = { workspace = true }
+tokio = { workspace = true, default-features = false, features = [
     "macros",
     "time",
 ] }
 
 [build-dependencies]
-cargo_metadata = { version = "0.15.4", default-features = false }
-which = { version = "4.4.0", default-features = false }
+cargo_metadata = { workspace = true }
+which = { workspace = true }
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index 6610e982..0a5d2286 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -5,12 +5,12 @@ authors = ["Alessandro Decina <alessandro.d@gmail.com>"]
 edition = "2021"
 
 [dependencies]
-anyhow = "1"
-aya-tool = { path = "../aya-tool" }
-cargo_metadata = "0.15.4"
-clap = { version = "4", features = ["derive"] }
-indoc = "2.0"
-proc-macro2 = "1"
-quote = "1"
-syn = "2"
-tempfile = "3"
+anyhow = { workspace = true }
+aya-tool = { workspace = true }
+cargo_metadata = { workspace = true }
+clap = { workspace = true }
+indoc = { workspace = true }
+proc-macro2 = { workspace = true }
+quote = { workspace = true }
+syn = { workspace = true }
+tempfile = { workspace = true }