first commit
This commit is contained in:
commit
ec42a139a4
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
/protobufs
|
||||||
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "meshtastic-protobuf"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bytes = "1.5.0"
|
||||||
|
prost = "0.12.3"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
git2 = "0.18.1"
|
||||||
|
prost-build = "0.12.3"
|
||||||
41
build.rs
Normal file
41
build.rs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/lib.rs
Normal file
3
src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub mod meshtastic {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/meshtastic.rs"));
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user