Skip to content

Commit

Permalink
Move build time file to out dir (#133)
Browse files Browse the repository at this point in the history
* move build_time.rs file to OUT_DIR

* update CHANGELOG.md
  • Loading branch information
piakushin authored Oct 2, 2021
1 parent 720dc5d commit 7520cc0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Pearl changelog

#### Changed
- Rebuild corrupted index automatically during startup (#94)
- Move build_time.rs file to OUT_DIR.

#### Fixed
- Create corrupted directory only when needed (#94)
Expand Down
5 changes: 1 addition & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ fn main() {
"pub(crate) const BUILD_TIME: &str = \"{}\";",
time.format("%d-%m-%Y %H:%M:%S")
);
let path = format!(
"{}/src/build_info/build_time.rs",
env!("CARGO_MANIFEST_DIR")
);
let path = format!("{}/build_time.rs", std::env::var("OUT_DIR").unwrap());
if let Err(e) = std::fs::write(path, content) {
println!("failed to write build time: {}", e);
}
Expand Down
4 changes: 2 additions & 2 deletions src/build_info/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::{Display, Formatter, Result as FmtResult};

mod build_time;
include!(concat!(env!("OUT_DIR"), "/build_time.rs"));

/// Contains info about current build:
/// name, version, commit and build time (if built with `--release` flag).
Expand All @@ -20,7 +20,7 @@ impl BuildInfo {
name: env!("CARGO_PKG_NAME"),
version: env!("CARGO_PKG_VERSION"),
commit: option_env!("PEARL_COMMIT_HASH").unwrap_or("hash-undefined"),
build_time: build_time::BUILD_TIME,
build_time: BUILD_TIME,
}
}

Expand Down

0 comments on commit 7520cc0

Please sign in to comment.