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() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prost_config(descriptor_path: &Path, run_protoc: bool) -> prost_build::Config {
|
||||||
let mut config = prost_build::Config::new();
|
let mut config = prost_build::Config::new();
|
||||||
config.file_descriptor_set_path(&descriptor_path);
|
config.file_descriptor_set_path(descriptor_path);
|
||||||
// If our cached descriptor is up-to-date, we don't need to run protoc.
|
// If our cached descriptor is up-to-date, we don't need to run protoc.
|
||||||
// This is helpful so that users don't need to have protoc installed
|
// This is helpful so that users don't need to have protoc installed
|
||||||
// unless they're updating the protos.
|
// unless they're updating the protos.
|
||||||
if !run_protoc {
|
if !run_protoc {
|
||||||
config.skip_protoc_run();
|
config.skip_protoc_run();
|
||||||
}
|
}
|
||||||
config.compile_protos(&proto_files, &[root]).expect("Failed to compile protos");
|
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:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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