From aa333e962bfa4bba7d19f501296a4f8cc043bd53 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Fri, 29 Jul 2022 16:09:27 -0600 Subject: [PATCH] Build protoc from source --- Cargo.lock | 19 ++++++++++++++++++ programs/bpf/Cargo.lock | 19 ++++++++++++++++++ storage-bigtable/build-proto/Cargo.lock | 25 ++++++++++++++++++++++++ storage-bigtable/build-proto/Cargo.toml | 1 + storage-bigtable/build-proto/src/main.rs | 5 +++++ storage-proto/Cargo.toml | 1 + storage-proto/build.rs | 5 +++++ 7 files changed, 75 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c435f796de54c7..af19891e87c1a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,6 +265,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "autotools" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8138adefca3e5d2e73bfba83bd6eeaf904b26a7ac1b4a19892cfe16cc7e1701" +dependencies = [ + "cc", +] + [[package]] name = "axum" version = "0.5.1" @@ -3524,6 +3533,15 @@ dependencies = [ "prost 0.11.0", ] +[[package]] +name = "protobuf-src" +version = "1.0.5+3.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe57f68bf9767f48f8cbcbceb5da21524e2b1330a821c1c2502c447d8043f078" +dependencies = [ + "autotools", +] + [[package]] name = "qstring" version = "0.7.2" @@ -6253,6 +6271,7 @@ dependencies = [ "bs58", "enum-iterator", "prost 0.11.0", + "protobuf-src", "serde", "solana-account-decoder", "solana-sdk 1.11.5", diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index ed17a9c797443c..4049f7d0d59968 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -251,6 +251,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +[[package]] +name = "autotools" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8138adefca3e5d2e73bfba83bd6eeaf904b26a7ac1b4a19892cfe16cc7e1701" +dependencies = [ + "cc", +] + [[package]] name = "axum" version = "0.5.3" @@ -3192,6 +3201,15 @@ dependencies = [ "prost 0.11.0", ] +[[package]] +name = "protobuf-src" +version = "1.0.5+3.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe57f68bf9767f48f8cbcbceb5da21524e2b1330a821c1c2502c447d8043f078" +dependencies = [ + "autotools", +] + [[package]] name = "qstring" version = "0.7.2" @@ -5539,6 +5557,7 @@ dependencies = [ "bincode", "bs58", "prost 0.11.0", + "protobuf-src", "serde", "solana-account-decoder", "solana-sdk 1.11.5", diff --git a/storage-bigtable/build-proto/Cargo.lock b/storage-bigtable/build-proto/Cargo.lock index 12bfee987d28b2..015ad69ca3d283 100644 --- a/storage-bigtable/build-proto/Cargo.lock +++ b/storage-bigtable/build-proto/Cargo.lock @@ -14,6 +14,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +[[package]] +name = "autotools" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8138adefca3e5d2e73bfba83bd6eeaf904b26a7ac1b4a19892cfe16cc7e1701" +dependencies = [ + "cc", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -26,6 +35,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + [[package]] name = "cfg-if" version = "1.0.0" @@ -206,9 +221,19 @@ dependencies = [ name = "proto" version = "1.11.5" dependencies = [ + "protobuf-src", "tonic-build", ] +[[package]] +name = "protobuf-src" +version = "1.0.5+3.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe57f68bf9767f48f8cbcbceb5da21524e2b1330a821c1c2502c447d8043f078" +dependencies = [ + "autotools", +] + [[package]] name = "quote" version = "1.0.7" diff --git a/storage-bigtable/build-proto/Cargo.toml b/storage-bigtable/build-proto/Cargo.toml index 74acdef788289f..9388e4f4bc4a97 100644 --- a/storage-bigtable/build-proto/Cargo.toml +++ b/storage-bigtable/build-proto/Cargo.toml @@ -12,4 +12,5 @@ version = "1.11.5" [workspace] [dependencies] +protobuf-src = "1.0.5" tonic-build = "0.8.0" diff --git a/storage-bigtable/build-proto/src/main.rs b/storage-bigtable/build-proto/src/main.rs index 4aa408937239fe..6d81497a55613f 100644 --- a/storage-bigtable/build-proto/src/main.rs +++ b/storage-bigtable/build-proto/src/main.rs @@ -1,4 +1,9 @@ fn main() -> Result<(), std::io::Error> { + const PROTOC_ENVAR: &str = "PROTOC"; + if std::env::var(PROTOC_ENVAR).is_err() { + std::env::set_var("PROTOC", protobuf_src::protoc()); + } + let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); let out_dir = manifest_dir.join("../proto"); diff --git a/storage-proto/Cargo.toml b/storage-proto/Cargo.toml index a876533e16bcc1..e5963d5c15e936 100644 --- a/storage-proto/Cargo.toml +++ b/storage-proto/Cargo.toml @@ -29,4 +29,5 @@ name = "solana_storage_proto" targets = ["x86_64-unknown-linux-gnu"] [build-dependencies] +protobuf-src = "1.0.5" tonic-build = "0.8.0" diff --git a/storage-proto/build.rs b/storage-proto/build.rs index b1ea9903d4fb11..c5d1d632734c1d 100644 --- a/storage-proto/build.rs +++ b/storage-proto/build.rs @@ -1,4 +1,9 @@ fn main() -> Result<(), std::io::Error> { + const PROTOC_ENVAR: &str = "PROTOC"; + if std::env::var(PROTOC_ENVAR).is_err() { + std::env::set_var("PROTOC", protobuf_src::protoc()); + } + let proto_base_path = std::path::PathBuf::from("proto"); let proto_files = ["confirmed_block.proto", "transaction_by_addr.proto"]; let mut protos = Vec::new();