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

build(types): Use protox instead of requiring protoc when building #402

Merged
merged 13 commits into from
Oct 7, 2024
29 changes: 0 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install wasm Rust
uses: actions-rs/toolchain@v1
Expand All @@ -38,12 +33,6 @@ jobs:
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run rustdoc check
env:
RUSTDOCFLAGS: --cfg docsrs -D warnings
Expand All @@ -65,12 +54,6 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -123,12 +106,6 @@ jobs:
cargo-${{ hashFiles('**/Cargo.lock') }}
cargo-

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -202,12 +179,6 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
version: "23.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly

Expand Down
109 changes: 109 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Install common dependencies

```bash
# install dependencies
sudo apt-get install -y build-essential curl git protobuf-compiler
sudo apt-get install -y build-essential curl git

# install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Expand Down
2 changes: 1 addition & 1 deletion proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ prost-types = "0.12.6"
serde = { version = "1.0.203", features = ["derive"] }

[build-dependencies]
anyhow = "1.0.86"
prost-build = "0.12.6"
protox = "0.6.1"
S1nus marked this conversation as resolved.
Show resolved Hide resolved

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.42"
Expand Down
44 changes: 22 additions & 22 deletions proto/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! A build script generating rust types from protobuf definitions.

use anyhow::Result;

const SERIALIZED: &str = r#"#[derive(::serde::Deserialize, ::serde::Serialize)]"#;
const SERIALIZED_DEFAULT: &str =
r#"#[derive(::serde::Deserialize, ::serde::Serialize)] #[serde(default)]"#;
Expand Down Expand Up @@ -63,7 +61,26 @@ static CUSTOM_FIELD_ATTRIBUTES: &[(&str, &str)] = &[
(".shwap.Share", BASE64STRING),
];

fn main() -> Result<()> {
fn main() {
let fds = protox::compile(
[
"vendor/celestia/da/data_availability_header.proto",
"vendor/celestia/blob/v1/tx.proto",
"vendor/header/pb/extended_header.proto",
"vendor/share/eds/byzantine/pb/share.proto",
"vendor/share/shwap/pb/shwap.proto",
"vendor/share/shwap/p2p/bitswap/pb/bitswap.proto",
"vendor/cosmos/base/v1beta1/coin.proto",
"vendor/cosmos/base/abci/v1beta1/abci.proto",
"vendor/cosmos/crypto/multisig/v1beta1/multisig.proto",
"vendor/cosmos/staking/v1beta1/query.proto",
"vendor/cosmos/tx/v1beta1/tx.proto",
"vendor/go-header/p2p/pb/header_request.proto",
],
["vendor", "vendor/nmt"],
)
.expect("protox failed to build");

let mut config = prost_build::Config::new();

for (type_path, attr) in CUSTOM_TYPE_ATTRIBUTES {
Expand All @@ -87,23 +104,6 @@ fn main() -> Result<()> {
)
// Comments in Google's protobuf are causing issues with cargo-test
.disable_comments([".google"])
.compile_protos(
&[
"vendor/celestia/da/data_availability_header.proto",
"vendor/celestia/blob/v1/tx.proto",
"vendor/header/pb/extended_header.proto",
"vendor/share/eds/byzantine/pb/share.proto",
"vendor/share/shwap/pb/shwap.proto",
"vendor/share/shwap/p2p/bitswap/pb/bitswap.proto",
"vendor/cosmos/base/v1beta1/coin.proto",
"vendor/cosmos/base/abci/v1beta1/abci.proto",
"vendor/cosmos/crypto/multisig/v1beta1/multisig.proto",
"vendor/cosmos/staking/v1beta1/query.proto",
"vendor/cosmos/tx/v1beta1/tx.proto",
"vendor/go-header/p2p/pb/header_request.proto",
],
&["vendor", "vendor/nmt"],
)?;

Ok(())
.compile_fds(fds)
.expect("prost failed");
S1nus marked this conversation as resolved.
Show resolved Hide resolved
}
Loading