Skip to content

Commit 8b3ada2

Browse files
authored
feat: Add vendored support (#411)
* feat: Add vendored support Signed-off-by: Xuanwo <github@xuanwo.io> * Use diff=false instead Signed-off-by: Xuanwo <github@xuanwo.io> * try fix Signed-off-by: Xuanwo <github@xuanwo.io> * Fix typo Signed-off-by: Xuanwo <github@xuanwo.io> * Use vendor by default Signed-off-by: Xuanwo <github@xuanwo.io> * Add check Signed-off-by: Xuanwo <github@xuanwo.io> --------- Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 2761270 commit 8b3ada2

34 files changed

+12722
-17
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/generated/ diff=false

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
uses: Swatinem/rust-cache@v1.4.0
2222
- name: make check
2323
run: make check
24+
- name: Catch unexpected changes in the generated code
25+
run: |
26+
git diff --exit-code
2427
2528
unit-test:
2629
name: unit test

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ integration-tests = []
1717
[lib]
1818
name = "tikv_client"
1919

20+
[workspace]
21+
members = [
22+
".",
23+
"proto-build",
24+
]
25+
2026
[dependencies]
2127
async-recursion = "0.3"
2228
async-trait = "0.1"
@@ -39,7 +45,6 @@ tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] }
3945
tonic = { version = "0.9", features = ["tls"] }
4046

4147
[dev-dependencies]
42-
tempfile = "3.6"
4348
clap = "2"
4449
env_logger = "0.10"
4550
fail = { version = "0.4", features = ["failpoints"] }
@@ -51,14 +56,9 @@ reqwest = { version = "0.11", default-features = false, features = [
5156
serde_json = "1"
5257
serial_test = "0.5.0"
5358
simple_logger = "1"
59+
tempfile = "3.6"
5460
tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] }
5561

56-
[build-dependencies]
57-
glob = "0.3"
58-
tonic-build = "0.9"
59-
# Suppress doctest bug (https://stackoverflow.com/questions/66074003/how-to-turn-off-cargo-doc-test-and-compile-for-a-specific-module-in-rust)
60-
tonic-disable-doctest = "0.1.0"
61-
6262
[[test]]
6363
name = "failpoint_tests"
6464
path = "tests/failpoint_tests.rs"

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ INTEGRATION_TEST_ARGS := --features "integration-tests"
1111

1212
default: check
1313

14-
check:
14+
generate:
15+
cargo run -p tikv-client-proto-build
16+
17+
check: generate
1518
cargo check --all --all-targets --features "${ALL_FEATURES}"
1619
cargo fmt -- --check
1720
cargo clippy --all-targets --features "${ALL_FEATURES}" -- -D clippy::all
1821

19-
unit-test:
22+
unit-test: generate
2023
cargo test --all --no-default-features
2124

22-
integration-test:
25+
integration-test: generate
2326
cargo test txn_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
2427
cargo test raw_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
2528
cargo test misc_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
@@ -32,7 +35,7 @@ doc:
3235
tiup:
3336
tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config $(shell pwd)/config/tikv.toml --pd.config $(shell pwd)/config/pd.toml &
3437

35-
all: check doc test
38+
all: generate check doc test
3639

3740
clean:
3841
cargo clean

proto-build/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "tikv-client-proto-build"
3+
version = "0.0.0"
4+
publish = false
5+
6+
keywords = ["TiKV", "KV", "distributed-systems"]
7+
license = "Apache-2.0"
8+
authors = ["The TiKV Project Authors"]
9+
repository = "https://github.com/tikv/client-rust"
10+
description = "The Rust language implementation of TiKV client."
11+
edition = "2021"
12+
13+
[dependencies]
14+
glob = "0.3"
15+
tonic-build = "0.9"
16+
# Suppress doctest bug (https://stackoverflow.com/questions/66074003/how-to-turn-off-cargo-doc-test-and-compile-for-a-specific-module-in-rust)
17+
tonic-disable-doctest = "0.1.0"

build.rs renamed to proto-build/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
2-
3-
use tonic_disable_doctest::BuilderEx;
1+
// Copyright 2023 TiKV Project Authors. Licensed under Apache-2.0.
42

53
fn main() {
4+
use tonic_disable_doctest::BuilderEx;
5+
66
tonic_build::configure()
77
.disable_doctests_for_types([".google.api.HttpRule"])
8+
.emit_rerun_if_changed(false)
89
.build_server(false)
910
.include_file("mod.rs")
11+
.out_dir("src/generated")
1012
.compile(
1113
&glob::glob("proto/*.proto")
1214
.unwrap()

0 commit comments

Comments
 (0)