From 013218194d719406146075ec80cf0b491284519e Mon Sep 17 00:00:00 2001 From: sword-jin Date: Fri, 12 Jul 2024 08:22:22 +0000 Subject: [PATCH] remove strip --- .github/workflows/release.yaml | 29 ++++++++++------------------- .gitignore | 3 ++- Cargo.lock | 28 ++++++++++++++++++++++++++++ tunneld-pkg/Cargo.toml | 2 +- tunneld-protocol/Cargo.toml | 1 + tunneld-protocol/build.rs | 22 +++++++++++++++++++--- tunneld-protocol/src/lib.rs | 2 +- 7 files changed, 62 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a7b8dff..92469a1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -104,6 +104,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install packages (Ubuntu) # Because openssl doesn't work on musl by default, we resort to max-pure. And that won't need any dependency, so we can skip this.continue-on-error @@ -111,6 +116,10 @@ jobs: if: matrix.os == 'ubuntu-latest-disabled' run: | sudo apt-get update && sudo apt-get install -y --no-install-recommends xz-utils liblz4-tool musl-tools + + - name: compile protobuf + run: | + protoc --descriptor_set_out=./tunneld-protocol/src/message.bin --proto_path=tunneld-protocol/src message.proto - name: Install Rust uses: dtolnay/rust-toolchain@master @@ -126,11 +135,6 @@ jobs: echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV - - name: Install Protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Show command used for Cargo run: | echo "cargo command is: ${{ env.CARGO }}" @@ -156,26 +160,13 @@ jobs: - name: Build release binary run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }} - - name: Strip release binary (linux and macos) - if: matrix.build == 'linux' || matrix.build == 'macos' - run: strip target/${{ matrix.target }}/release/${{ env.EXE_NAME }} target/${{ matrix.target }}/release/gix - - - name: Strip release binary (arm) - if: matrix.build == 'linux-arm' - run: | - docker run --rm -v \ - "$PWD/target:/target:Z" \ - rustembedded/cross:arm-unknown-linux-gnueabihf \ - arm-linux-gnueabihf-strip \ - /target/arm-unknown-linux-gnueabihf/release/${{ env.EXE_NAME }} \ - /target/arm-unknown-linux-gnueabihf/release/gix - name: Build archive shell: bash run: | staging="tunneld-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" mkdir -p "$staging" - cp {README.md,LICENSE-*,CHANGELOG.md} "$staging/" + cp {README.md,LICENSE} "$staging/" if [ "${{ matrix.os }}" = "windows-latest" ]; then cp target/release/${{ env.EXE_NAME }}.exe target/release/gix.exe "$staging/" diff --git a/.gitignore b/.gitignore index d8bd773..2633021 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -*.txt \ No newline at end of file +*.txt +*.bin \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c5d276b..6533c24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -670,6 +670,15 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.12" @@ -2017,6 +2026,7 @@ dependencies = [ "prost", "tonic", "tonic-build", + "which", ] [[package]] @@ -2204,6 +2214,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +dependencies = [ + "either", + "home", + "rustix", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2375,6 +2397,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "wiremock" version = "0.6.0" diff --git a/tunneld-pkg/Cargo.toml b/tunneld-pkg/Cargo.toml index 99cfbe4..d03ba23 100644 --- a/tunneld-pkg/Cargo.toml +++ b/tunneld-pkg/Cargo.toml @@ -17,4 +17,4 @@ futures = "0.3.30" bytes = "1.6.0" [features] -debug=[] \ No newline at end of file +debug=[] diff --git a/tunneld-protocol/Cargo.toml b/tunneld-protocol/Cargo.toml index 5f18cb7..b000af4 100644 --- a/tunneld-protocol/Cargo.toml +++ b/tunneld-protocol/Cargo.toml @@ -14,3 +14,4 @@ prost = "0.12.6" [build-dependencies] tonic-build = "0.11.0" +which = "6.0.1" diff --git a/tunneld-protocol/build.rs b/tunneld-protocol/build.rs index b10786d..8f43e83 100644 --- a/tunneld-protocol/build.rs +++ b/tunneld-protocol/build.rs @@ -1,8 +1,24 @@ use std::io::Result; +use which::which; + fn main() -> Result<()> { - tonic_build::configure() - .protoc_arg("--experimental_allow_proto3_optional") - .compile(&["src/message.proto"], &["src/"])?; + let builder = tonic_build::configure().protoc_arg("--experimental_allow_proto3_optional"); + + match which("protoc") { + Ok(_) => { + println!("found protoc"); + builder.compile(&["src/message.proto"], &["src/"])?; + } + Err(_) => { + println!("since there is no protoc in the path, we skip the protoc run"); + println!("protoc --descriptor_set_out=message.bin --proto_path=. message.proto"); + builder + .skip_protoc_run() + .file_descriptor_set_path("src/message.bin") + .compile(&["src/message.bin"], &["src/"])?; + } + } + Ok(()) } diff --git a/tunneld-protocol/src/lib.rs b/tunneld-protocol/src/lib.rs index 36a8cf8..fef4910 100644 --- a/tunneld-protocol/src/lib.rs +++ b/tunneld-protocol/src/lib.rs @@ -1,5 +1,5 @@ pub mod pb { - tonic::include_proto!("message"); + tonic::include_proto!("message"); } // before connectrpc releases rust version, we validate the message by ourselves