-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(network): remove protoc from prerequisites on papyrus readme (#492)
* docs(network): remove protoc installation from documentation * build(protobuf): build proto files without protoc
- Loading branch information
1 parent
530c04e
commit c771d67
Showing
6 changed files
with
99 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,20 @@ | ||
use std::env; | ||
use std::io::{Error, ErrorKind, Result}; | ||
use std::process::Command; | ||
use std::io::Result; | ||
|
||
fn main() -> Result<()> { | ||
println!("Building"); | ||
let protoc = env::var("PROTOC").unwrap_or("protoc".to_string()); | ||
|
||
let protoc_version = String::from_utf8_lossy( | ||
&Command::new(protoc).arg("--version").output().expect("Protoc is not installed.").stdout, | ||
) | ||
.to_string(); | ||
|
||
let parts: Vec<&str> = protoc_version.split_whitespace().collect(); | ||
let protoc_version_str = parts.get(1).expect("Failed to determine protoc version"); | ||
let mut protoc_version_parts = protoc_version_str | ||
.split('.') | ||
.map(|part| part.parse::<u32>().expect("Error parsing protoc version")); | ||
let major = protoc_version_parts.next().expect("Protoc version did not have a major number"); | ||
let minor = protoc_version_parts.next().unwrap_or_default(); | ||
|
||
if major < 3 || (major == 3 && minor < 15) { | ||
Err(Error::new( | ||
ErrorKind::Other, | ||
"protoc version is too old. version 3.15.x or greater is needed.", | ||
)) | ||
} else { | ||
prost_build::compile_protos( | ||
&[ | ||
"src/proto/p2p/proto/class.proto", | ||
"src/proto/p2p/proto/event.proto", | ||
"src/proto/p2p/proto/header.proto", | ||
"src/proto/p2p/proto/state.proto", | ||
"src/proto/p2p/proto/transaction.proto", | ||
"src/proto/p2p/proto/consensus.proto", | ||
], | ||
&["src/proto/"], | ||
)?; | ||
Ok(()) | ||
} | ||
let (protoc_bin, _) = protoc_prebuilt::init("27.0").unwrap(); | ||
env::set_var("PROTOC", protoc_bin); | ||
prost_build::compile_protos( | ||
&[ | ||
"src/proto/p2p/proto/class.proto", | ||
"src/proto/p2p/proto/event.proto", | ||
"src/proto/p2p/proto/header.proto", | ||
"src/proto/p2p/proto/state.proto", | ||
"src/proto/p2p/proto/transaction.proto", | ||
"src/proto/p2p/proto/consensus.proto", | ||
], | ||
&["src/proto/"], | ||
)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters