Skip to content

Commit 9a9248c

Browse files
author
Hui Zhu
authored
Merge pull request #41 from Tim-Zhang/move-ttrpc-rs
Move generated file ttrpc.rs to OUT_DIR
2 parents e32f9d9 + 5cdcda5 commit 9a9248c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
use std::env;
2+
use std::fs;
3+
use std::path::PathBuf;
4+
15
fn main() {
6+
let out_dir = env::var("OUT_DIR").unwrap();
7+
let path: PathBuf = [out_dir.clone(), "mod.rs".to_string()].iter().collect();
8+
fs::write(path, "pub mod ttrpc;").unwrap();
9+
210
protobuf_codegen_pure::Codegen::new()
3-
.out_dir("src")
11+
.out_dir(out_dir)
412
.inputs(&["src/ttrpc.proto"])
513
.include("src")
614
.run()

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ pub mod error;
2020
#[macro_use]
2121
pub mod common;
2222
#[allow(clippy::type_complexity, clippy::too_many_arguments)]
23-
pub mod ttrpc;
23+
pub mod compiled {
24+
include!(concat!(env!("OUT_DIR"), "/mod.rs"));
25+
}
26+
pub use compiled::ttrpc;
2427

2528
pub use crate::common::MessageHeader;
2629
pub use crate::error::{get_status, Error, Result};

0 commit comments

Comments
 (0)