storage-proto: Rework source generation
This commit is contained in:
parent
cf9a4575ae
commit
899b09872b
|
@ -1 +0,0 @@
|
|||
proto/
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
The `solana-storage-proto` structs used in `src/convert.rs` and elsewhere are
|
||||
auto-generated from protobuf definitions on build. To update these structs,
|
||||
simply make the desired edits to `src/*.proto` files.
|
||||
simply make the desired edits to `proto/*.proto` files.
|
||||
|
|
|
@ -1,24 +1,16 @@
|
|||
fn main() -> Result<(), std::io::Error> {
|
||||
let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
let out_dir = manifest_dir.join("proto");
|
||||
let proto_files = manifest_dir.join("src");
|
||||
|
||||
std::fs::create_dir_all(out_dir.clone())?;
|
||||
|
||||
println!("Protobuf directory: {}", proto_files.display());
|
||||
println!("output directory: {}", out_dir.display());
|
||||
let proto_base_path = std::path::PathBuf::from("proto");
|
||||
let proto_files = ["confirmed_block.proto", "transaction_by_addr.proto"];
|
||||
let mut protos = Vec::new();
|
||||
for proto_file in &proto_files {
|
||||
let proto = proto_base_path.join(proto_file);
|
||||
println!("cargo::rerun-if-changed={}", proto.display());
|
||||
protos.push(proto);
|
||||
}
|
||||
|
||||
tonic_build::configure()
|
||||
.build_client(true)
|
||||
.build_server(false)
|
||||
.format(true)
|
||||
.out_dir(&out_dir)
|
||||
.compile(
|
||||
&[
|
||||
proto_files.join("confirmed_block.proto"),
|
||||
proto_files.join("transaction_by_addr.proto"),
|
||||
],
|
||||
&[proto_files],
|
||||
)
|
||||
.compile(&protos, &[proto_base_path])
|
||||
}
|
||||
|
|
|
@ -23,15 +23,15 @@ use {
|
|||
|
||||
pub mod generated {
|
||||
include!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
concat!("/proto/solana.storage.confirmed_block.rs")
|
||||
env!("OUT_DIR"),
|
||||
"/solana.storage.confirmed_block.rs"
|
||||
));
|
||||
}
|
||||
|
||||
pub mod tx_by_addr {
|
||||
include!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
concat!("/proto/solana.storage.transaction_by_addr.rs")
|
||||
env!("OUT_DIR"),
|
||||
"/solana.storage.transaction_by_addr.rs"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue