mirror of https://github.com/encounter/objdiff.git
Try even harder to recover from protoc missing
This commit is contained in:
parent
faebddbc5e
commit
3710b6a91e
|
@ -1,4 +1,4 @@
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let output = std::process::Command::new("git")
|
let output = std::process::Command::new("git")
|
||||||
|
@ -28,15 +28,29 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut config = prost_build::Config::new();
|
fn prost_config(descriptor_path: &Path, run_protoc: bool) -> prost_build::Config {
|
||||||
config.file_descriptor_set_path(&descriptor_path);
|
let mut config = prost_build::Config::new();
|
||||||
// If our cached descriptor is up-to-date, we don't need to run protoc.
|
config.file_descriptor_set_path(descriptor_path);
|
||||||
// This is helpful so that users don't need to have protoc installed
|
// If our cached descriptor is up-to-date, we don't need to run protoc.
|
||||||
// unless they're updating the protos.
|
// This is helpful so that users don't need to have protoc installed
|
||||||
if !run_protoc {
|
// unless they're updating the protos.
|
||||||
config.skip_protoc_run();
|
if !run_protoc {
|
||||||
|
config.skip_protoc_run();
|
||||||
|
}
|
||||||
|
config
|
||||||
|
}
|
||||||
|
if let Err(e) =
|
||||||
|
prost_config(&descriptor_path, run_protoc).compile_protos(&proto_files, &[root.as_path()])
|
||||||
|
{
|
||||||
|
if e.kind() == std::io::ErrorKind::NotFound && e.to_string().contains("protoc") {
|
||||||
|
eprintln!("protoc not found, skipping protobuf compilation");
|
||||||
|
prost_config(&descriptor_path, false)
|
||||||
|
.compile_protos(&proto_files, &[root.as_path()])
|
||||||
|
.expect("Failed to compile protos");
|
||||||
|
} else {
|
||||||
|
panic!("Failed to compile protos: {e:?}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
config.compile_protos(&proto_files, &[root]).expect("Failed to compile protos");
|
|
||||||
|
|
||||||
let descriptor_set = std::fs::read(descriptor_path).expect("Failed to read descriptor set");
|
let descriptor_set = std::fs::read(descriptor_path).expect("Failed to read descriptor set");
|
||||||
pbjson_build::Builder::new()
|
pbjson_build::Builder::new()
|
||||||
|
|
Loading…
Reference in New Issue