소스 검색

Add optional build script for `protoc-rust`

Johannes Hofmann 7 년 전
부모
커밋
57dcd3b8d3
1개의 변경된 파일25개의 추가작업 그리고 0개의 파일을 삭제
  1. 25
    0
      build_proto.rs

+ 25
- 0
build_proto.rs 파일 보기

@@ -0,0 +1,25 @@
1
+//! To regenerate *.rs files in `src/proto/` rename this file to `build.rs`
2
+//! and add this to `Cargo.toml`:
3
+//! ```
4
+//! [build-dependencies]
5
+//! protoc-rust = "2.0"
6
+//! ```
7
+
8
+extern crate protoc_rust;
9
+
10
+fn main() {
11
+    let proto_files = ["src/proto/fileformat.proto", "src/proto/osmformat.proto"];
12
+
13
+    for path in &proto_files {
14
+        println!("cargo:rerun-if-changed={}", path);
15
+    }
16
+
17
+    protoc_rust::run(protoc_rust::Args {
18
+        out_dir: "src/proto",
19
+        input: &proto_files,
20
+        customize: protoc_rust::Customize {
21
+            ..Default::default()
22
+        },
23
+        includes: &[],
24
+    }).expect("protoc");
25
+}