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
|
The `solana-storage-proto` structs used in `src/convert.rs` and elsewhere are
|
||||||
auto-generated from protobuf definitions on build. To update these structs,
|
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> {
|
fn main() -> Result<(), std::io::Error> {
|
||||||
let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let proto_base_path = std::path::PathBuf::from("proto");
|
||||||
|
let proto_files = ["confirmed_block.proto", "transaction_by_addr.proto"];
|
||||||
let out_dir = manifest_dir.join("proto");
|
let mut protos = Vec::new();
|
||||||
let proto_files = manifest_dir.join("src");
|
for proto_file in &proto_files {
|
||||||
|
let proto = proto_base_path.join(proto_file);
|
||||||
std::fs::create_dir_all(out_dir.clone())?;
|
println!("cargo::rerun-if-changed={}", proto.display());
|
||||||
|
protos.push(proto);
|
||||||
println!("Protobuf directory: {}", proto_files.display());
|
}
|
||||||
println!("output directory: {}", out_dir.display());
|
|
||||||
|
|
||||||
tonic_build::configure()
|
tonic_build::configure()
|
||||||
.build_client(true)
|
.build_client(true)
|
||||||
.build_server(false)
|
.build_server(false)
|
||||||
.format(true)
|
.format(true)
|
||||||
.out_dir(&out_dir)
|
.compile(&protos, &[proto_base_path])
|
||||||
.compile(
|
|
||||||
&[
|
|
||||||
proto_files.join("confirmed_block.proto"),
|
|
||||||
proto_files.join("transaction_by_addr.proto"),
|
|
||||||
],
|
|
||||||
&[proto_files],
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,15 +23,15 @@ use {
|
||||||
|
|
||||||
pub mod generated {
|
pub mod generated {
|
||||||
include!(concat!(
|
include!(concat!(
|
||||||
env!("CARGO_MANIFEST_DIR"),
|
env!("OUT_DIR"),
|
||||||
concat!("/proto/solana.storage.confirmed_block.rs")
|
"/solana.storage.confirmed_block.rs"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod tx_by_addr {
|
pub mod tx_by_addr {
|
||||||
include!(concat!(
|
include!(concat!(
|
||||||
env!("CARGO_MANIFEST_DIR"),
|
env!("OUT_DIR"),
|
||||||
concat!("/proto/solana.storage.transaction_by_addr.rs")
|
"/solana.storage.transaction_by_addr.rs"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue