Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

storage-proto: Rework source generation (backport #18577) #18584

Merged
merged 1 commit into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion storage-proto/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion storage-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
26 changes: 9 additions & 17 deletions storage-proto/build.rs
Original file line number Diff line number Diff line change
@@ -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])
}
8 changes: 4 additions & 4 deletions storage-proto/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
));
}

Expand Down