42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
extern crate git2;
|
|
extern crate prost_build;
|
|
|
|
use git2::Repository;
|
|
use prost_build::compile_protos;
|
|
use std::path::Path;
|
|
|
|
fn update_repo(path: &Path) -> Result<(), git2::Error> {
|
|
let repo = Repository::open(path)?;
|
|
let mut remote = repo.find_remote("origin")?;
|
|
let refspecs: [&str; 0] = [];
|
|
remote.fetch(&refspecs, None, None)
|
|
}
|
|
|
|
fn main() {
|
|
let repo = "https://github.com/meshtastic/protobufs.git";
|
|
let path = Path::new("protobufs");
|
|
|
|
if path.exists() {
|
|
if let Err(e) = update_repo(path) {
|
|
eprintln!("Error could not update meshtastic protobuf repo");
|
|
eprintln!("{e}");
|
|
std::process::exit(1);
|
|
}
|
|
} else {
|
|
if let Err(e) = Repository::clone(repo, path) {
|
|
eprintln!("Error could not clone meshtastic protobuf repo");
|
|
eprintln!("{e}");
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
|
|
let protos = &["protobufs/meshtastic/mesh.proto"];
|
|
let includes = &["protobufs"];
|
|
|
|
if let Err(e) = compile_protos(protos, includes) {
|
|
eprintln!("Error could not compile protobufs");
|
|
eprintln!("{e}");
|
|
std::process::exit(1);
|
|
}
|
|
}
|