Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature vendored, to auto build protoc. #43

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
matrix:
features:
- ""
- "--features vendored"
- "--all-features"
runs-on: ubuntu-20.04
steps:
Expand All @@ -83,6 +84,7 @@ jobs:
submodules: 'recursive'
- name: Install protoc
run: sudo apt-get install -y protobuf-compiler=3.6.1.3-2ubuntu5
if: ${{ matrix.features != '--features vendored' }}
- name: Install Rust toolchain
run: rustup toolchain install stable --component clippy
- name: Run check
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ homepage = "https://skywalking.apache.org/"
repository = "https://github.com/apache/skywalking-rust"

[features]
vendored = ["protobuf-src"]
mock = [] # For internal integration testing only, do not use.

[dependencies]
Expand All @@ -52,6 +53,7 @@ tracing = "0.1.36"
uuid = { version = "1.1.2", features = ["serde", "v4"] }

[build-dependencies]
protobuf-src = { version = "1.0.5", optional = true }
tonic-build = "0.8.0"

[dev-dependencies]
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,40 @@ Using `cargo build` generates a library. If you'd like to verify the behavior, w
use `cargo run --example simple_trace_report`
which outputs executable, then run it.

## NOTICE

This crate automatically generates protobuf related code, which requires `protoc` before compile.

Please choose one of the ways to install `protoc`.

1. Using your OS package manager.

For Debian-base system:

```shell
sudo apt install protobuf-compiler
```

For MacOS:

```shell
brew install protobuf
```

2. Auto compile `protoc` in the crate build script, just by adding the feature `vendored` in the `Cargo.toml`:

```shell
cargo add skywalking --features vendored
```

3. Build from [source](https://github.com/protocolbuffers/protobuf). If `protc` isn't install inside $PATH, the env value `PROTOC` should be set.

```shell
PROTOC=/the/path/of/protoc
```

For details, please refer to [prost-build:sourcing-protoc](https://docs.rs/prost-build/latest/prost_build/index.html#sourcing-protoc).

# Release

The SkyWalking committer(PMC included) could follow [this doc](Release-guide.md) to release an official version.
Expand Down
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
//

fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "vendored")]
std::env::set_var("PROTOC", protobuf_src::protoc());

tonic_build::configure()
.build_server(false)
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
Expand Down