From e20c115cded0ab125e7bb34a535d7264b321ca37 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sun, 21 Apr 2024 12:34:57 +0200 Subject: [PATCH] chore: separate prost `Cargo.toml` workspace and crate declaration Removes the need to always specify append `--workspace` in the common cargo commands. `rust-analyser` seems to get confused and locks the workspace longer than needed under the previous structure. (Lots of `Blocking waiting for file lock on build directory` waiting.) Unable to find an issue mentioning this. Goals it to then make repo to more easily managed. Examples: * Consolidate crate package metadata, dependency versions and clippy lints in the workspace `Cargo.toml` * Placing all crates in a `crates/` for automatic workspace member inclucion. --- .github/workflows/ci.yml | 8 ++--- Cargo.toml | 46 ++-------------------------- conformance/Cargo.toml | 2 +- prost-build/Cargo.toml | 2 +- prost-types/Cargo.toml | 2 +- prost/Cargo.toml | 44 ++++++++++++++++++++++++++ {benches => prost/benches}/varint.rs | 0 {src => prost/src}/encoding.rs | 0 {src => prost/src}/error.rs | 0 {src => prost/src}/lib.rs | 2 +- {src => prost/src}/message.rs | 0 {src => prost/src}/name.rs | 0 {src => prost/src}/types.rs | 0 protobuf/Cargo.toml | 2 +- tests-2015/Cargo.toml | 2 +- tests-no-std/Cargo.toml | 2 +- tests/Cargo.toml | 2 +- tests/single-include/Cargo.toml | 2 +- 18 files changed, 59 insertions(+), 57 deletions(-) create mode 100644 prost/Cargo.toml rename {benches => prost/benches}/varint.rs (100%) rename {src => prost/src}/encoding.rs (100%) rename {src => prost/src}/error.rs (100%) rename {src => prost/src}/lib.rs (98%) rename {src => prost/src}/message.rs (100%) rename {src => prost/src}/name.rs (100%) rename {src => prost/src}/types.rs (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ca8d776b..3a0905234 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,12 +74,12 @@ jobs: uses: ./.github/actions/setup-ninja - uses: Swatinem/rust-cache@v2 - name: test - run: cargo test --workspace --all-targets + run: cargo test --all-targets - name: test no-default-features run: cargo test -p prost-build -p prost-derive -p prost-types --all-targets --no-default-features # Run doc tests separately: https://github.com/rust-lang/cargo/issues/6669 - name: test doc - run: cargo test --workspace --doc + run: cargo test --doc - name: test doc no-default-features run: cargo test -p prost-build -p prost-derive -p prost-types --doc --no-default-features @@ -91,7 +91,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@cargo-hack - uses: taiki-e/install-action@cargo-minimal-versions - - run: cargo minimal-versions --no-private check --workspace --all-features + - run: cargo minimal-versions --no-private check --all-features kani: runs-on: ubuntu-latest @@ -128,7 +128,7 @@ jobs: with: crate: cargo-no-std-check - name: prost cargo-no-std-check - run: cargo no-std-check --manifest-path Cargo.toml --no-default-features + run: cargo no-std-check --manifest-path prost/Cargo.toml --no-default-features - name: prost-types cargo-no-std-check run: cargo no-std-check --manifest-path prost-types/Cargo.toml --no-default-features # prost-build depends on prost with --no-default-features, but when diff --git a/Cargo.toml b/Cargo.toml index f93ae8156..0792412ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,25 +1,7 @@ -[package] -name = "prost" -version = "0.12.4" -authors = [ - "Dan Burkert ", - "Lucio Franco ", - "Casper Meijn ", - "Tokio Contributors ", -] -license = "Apache-2.0" -repository = "https://github.com/tokio-rs/prost" -documentation = "https://docs.rs/prost" -readme = "README.md" -description = "A Protocol Buffers implementation for the Rust Language." -keywords = ["protobuf", "serialization"] -categories = ["encoding"] -edition = "2021" -rust-version = "1.70" - [workspace] members = [ "conformance", + "prost", "prost-build", "prost-derive", "prost-types", @@ -38,31 +20,7 @@ exclude = [ "afl", ] -[lib] -# https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options -bench = false - -[features] -default = ["derive", "std"] -derive = ["dep:prost-derive"] -prost-derive = ["derive"] # deprecated, please use derive feature instead -no-recursion-limit = [] -std = [] - -[dependencies] -bytes = { version = "1", default-features = false } -prost-derive = { version = "0.12.4", path = "prost-derive", optional = true } - -[dev-dependencies] -criterion = { version = "0.4", default-features = false } -env_logger = { version = "0.10", default-features = false } -log = "0.4" -proptest = "1" -rand = "0.8" +resolver = "2" [profile.bench] debug = true - -[[bench]] -name = "varint" -harness = false diff --git a/conformance/Cargo.toml b/conformance/Cargo.toml index 5333b64fa..4bf97de0e 100644 --- a/conformance/Cargo.toml +++ b/conformance/Cargo.toml @@ -11,6 +11,6 @@ edition = "2018" [dependencies] bytes = "1" env_logger = { version = "0.10", default-features = false } -prost = { path = ".." } +prost = { path = "../prost" } protobuf = { path = "../protobuf" } tests = { path = "../tests" } diff --git a/prost-build/Cargo.toml b/prost-build/Cargo.toml index aaf6698d7..809828be5 100644 --- a/prost-build/Cargo.toml +++ b/prost-build/Cargo.toml @@ -27,7 +27,7 @@ itertools = { version = ">=0.10, <=0.12", default-features = false, features = [ log = "0.4.4" multimap = { version = ">=0.8, <=0.10", default-features = false } petgraph = { version = "0.6", default-features = false } -prost = { version = "0.12.4", path = "..", default-features = false } +prost = { version = "0.12.4", path = "../prost", default-features = false } prost-types = { version = "0.12.4", path = "../prost-types", default-features = false } tempfile = "3" once_cell = "1.17.1" diff --git a/prost-types/Cargo.toml b/prost-types/Cargo.toml index cfd645435..28f0ddb32 100644 --- a/prost-types/Cargo.toml +++ b/prost-types/Cargo.toml @@ -23,7 +23,7 @@ default = ["std"] std = ["prost/std"] [dependencies] -prost = { version = "0.12.4", path = "..", default-features = false, features = ["prost-derive"] } +prost = { version = "0.12.4", path = "../prost", default-features = false, features = ["prost-derive"] } [dev-dependencies] proptest = "1" diff --git a/prost/Cargo.toml b/prost/Cargo.toml new file mode 100644 index 000000000..965505733 --- /dev/null +++ b/prost/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "prost" +version = "0.12.4" +authors = [ + "Dan Burkert ", + "Lucio Franco ", + "Casper Meijn ", + "Tokio Contributors ", +] +license = "Apache-2.0" +repository = "https://github.com/tokio-rs/prost" +documentation = "https://docs.rs/prost" +readme = "../README.md" +description = "A Protocol Buffers implementation for the Rust Language." +keywords = ["protobuf", "serialization"] +categories = ["encoding"] +edition = "2021" +rust-version = "1.70" + +[lib] +# https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options +bench = false + +[features] +default = ["derive", "std"] +derive = ["dep:prost-derive"] +prost-derive = ["derive"] # deprecated, please use derive feature instead +no-recursion-limit = [] +std = [] + +[dependencies] +bytes = { version = "1", default-features = false } +prost-derive = { version = "0.12.4", path = "../prost-derive", optional = true } + +[dev-dependencies] +criterion = { version = "0.4", default-features = false } +env_logger = { version = "0.10", default-features = false } +log = "0.4" +proptest = "1" +rand = "0.8" + +[[bench]] +name = "varint" +harness = false diff --git a/benches/varint.rs b/prost/benches/varint.rs similarity index 100% rename from benches/varint.rs rename to prost/benches/varint.rs diff --git a/src/encoding.rs b/prost/src/encoding.rs similarity index 100% rename from src/encoding.rs rename to prost/src/encoding.rs diff --git a/src/error.rs b/prost/src/error.rs similarity index 100% rename from src/error.rs rename to prost/src/error.rs diff --git a/src/lib.rs b/prost/src/lib.rs similarity index 98% rename from src/lib.rs rename to prost/src/lib.rs index 756e5afbc..32b36f5cf 100644 --- a/src/lib.rs +++ b/prost/src/lib.rs @@ -1,6 +1,6 @@ #![doc(html_root_url = "https://docs.rs/prost/0.12.2")] #![cfg_attr(not(feature = "std"), no_std)] -#![doc = include_str!("../README.md")] +#![doc = include_str!("../../README.md")] // Re-export the alloc crate for use within derived code. #[doc(hidden)] diff --git a/src/message.rs b/prost/src/message.rs similarity index 100% rename from src/message.rs rename to prost/src/message.rs diff --git a/src/name.rs b/prost/src/name.rs similarity index 100% rename from src/name.rs rename to prost/src/name.rs diff --git a/src/types.rs b/prost/src/types.rs similarity index 100% rename from src/types.rs rename to prost/src/types.rs diff --git a/protobuf/Cargo.toml b/protobuf/Cargo.toml index 682f17285..c2d4fd6c7 100644 --- a/protobuf/Cargo.toml +++ b/protobuf/Cargo.toml @@ -9,7 +9,7 @@ publish = false edition = "2018" [dependencies] -prost = { path = ".." } +prost = { path = "../prost" } prost-types = { path = "../prost-types" } [build-dependencies] diff --git a/tests-2015/Cargo.toml b/tests-2015/Cargo.toml index cdb48cabf..cbdd181ca 100644 --- a/tests-2015/Cargo.toml +++ b/tests-2015/Cargo.toml @@ -23,7 +23,7 @@ std = [] anyhow = "1.0.1" bytes = "1" cfg-if = "1" -prost = { path = ".." } +prost = { path = "../prost" } prost-types = { path = "../prost-types" } protobuf = { path = "../protobuf" } diff --git a/tests-no-std/Cargo.toml b/tests-no-std/Cargo.toml index d8fc10d64..aeb1626ca 100644 --- a/tests-no-std/Cargo.toml +++ b/tests-no-std/Cargo.toml @@ -24,7 +24,7 @@ path = "../tests/src/lib.rs" anyhow = { version = "1.0.45", default-features = false } bytes = { version = "1", default-features = false } cfg-if = "1" -prost = { path = "..", default-features = false, features = ["derive"] } +prost = { path = "../prost", default-features = false, features = ["derive"] } prost-types = { path = "../prost-types", default-features = false } protobuf = { path = "../protobuf" } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index edc2fa86e..3735ee660 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -18,7 +18,7 @@ std = [] anyhow = "1.0.1" # bytes = "1" cfg-if = "1" -prost = { path = ".." } +prost = { path = "../prost" } prost-types = { path = "../prost-types" } protobuf = { path = "../protobuf" } diff --git a/tests/single-include/Cargo.toml b/tests/single-include/Cargo.toml index d95c9852c..63a9b86cb 100644 --- a/tests/single-include/Cargo.toml +++ b/tests/single-include/Cargo.toml @@ -7,7 +7,7 @@ publish = false license = "MIT" [dependencies] -prost = { path = "../.." } +prost = { path = "../../prost" } [build-dependencies] prost-build = { path = "../../prost-build" }