Skip to content

Commit 59ae65b

Browse files
committed
try using protobuf-codegen
1 parent 56b5a56 commit 59ae65b

File tree

5 files changed

+93
-13
lines changed

5 files changed

+93
-13
lines changed

lazer/Cargo.lock

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/sdk/js/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ dist/
2222
tsconfig.tsbuildinfo
2323

2424
# Types generated for .proto files
25-
src/generated/*
25+
src/generated/

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ rust_decimal = "1.36.0"
1818
base64 = "0.22.1"
1919
prost = "0.13.5"
2020
prost-types = "0.13.5"
21+
protobuf = "3.7.2"
2122

2223
[dev-dependencies]
2324
bincode = "1.3.3"
@@ -29,3 +30,4 @@ alloy-primitives = "0.8.19"
2930

3031
[build-dependencies]
3132
prost-build = "0.13.5"
33+
protobuf-codegen = "3.7.2"

lazer/sdk/rust/protocol/build.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ use std::io::Result;
55
/// Both JS and Rust SDKs read the proto files for generating types.
66
fn main() -> Result<()> {
77
// Tell cargo to recompile if any .proto files change
8-
println!("cargo:rerun-if-changed=proto/");
8+
println!("cargo:rerun-if-changed=../../proto/");
99

10-
// Selects proto files to be read for compiling
11-
let proto_files = vec![
12-
"../../proto/pyth_lazer_transaction.proto",
13-
"../../proto/publisher_update.proto",
14-
];
15-
16-
// Compiles protos and generates Rust types
17-
// Generated types are present in the output folder
18-
prost_build::compile_protos(&proto_files, &["../../proto"])
19-
.expect("Failed to compile protos and generate types");
10+
protobuf_codegen::Codegen::new()
11+
.pure()
12+
.include("../../proto")
13+
.input("../../proto/publisher_update.proto")
14+
.input("../../proto/pyth_lazer_transaction.proto")
15+
.cargo_out_dir("protobuf")
16+
.run_from_script();
2017

2118
Ok(())
2219
}

lazer/sdk/rust/protocol/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ mod serde_price_as_i64;
1010
mod serde_str;
1111
pub mod subscription;
1212
pub mod symbol_state;
13+
//pub mod transaction {
14+
// include!(concat!(env!("OUT_DIR"), "/pyth_lazer_transaction.rs"));
15+
//}
1316
pub mod transaction {
14-
include!(concat!(env!("OUT_DIR"), "/pyth_lazer_transaction.rs"));
17+
pub use crate::protobuf::pyth_lazer_transaction::*;
18+
}
19+
20+
mod protobuf {
21+
include!(concat!(env!("OUT_DIR"), "/protobuf/mod.rs"));
1522
}
1623

1724
#[test]

0 commit comments

Comments
 (0)