Skip to content

Commit 41f5706

Browse files
authored
refactor: Remove dependency built (#38)
1 parent 103d584 commit 41f5706

File tree

4 files changed

+28
-240
lines changed

4 files changed

+28
-240
lines changed

Cargo.lock

Lines changed: 1 addition & 211 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@ env_logger = "0.9"
1616
walkdir = "2.3"
1717
itertools = "0.10"
1818

19-
[build-dependencies]
20-
built = { version = "0.4", features = ["git2"] }
21-
2219
[profile.release]
2320
lto = true

build.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
use std::path::{ Path, PathBuf };
2-
use built::Options;
1+
use std::process::Command;
32

43
fn main() {
5-
let mut default: Options = Options::default();
6-
let options = default
7-
.set_compiler(true)
8-
.set_cfg(true)
9-
.set_ci(false)
10-
.set_dependencies(false)
11-
.set_git(true)
12-
.set_env(true)
13-
.set_features(true);
4+
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string());
5+
let profile = std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_string());
6+
println!("cargo:rustc-env=BUILD_TARGET={target}");
7+
println!("cargo:rustc-env=BUILD_PROFILE={profile}");
148

15-
let src: PathBuf = std::env::var("CARGO_MANIFEST_DIR").unwrap().into();
16-
let dst: PathBuf = Path::new(&std::env::var("OUT_DIR").unwrap()).join("built.rs");
9+
let git_commit = Command::new("git")
10+
.args(["describe", "--always", "--dirty"])
11+
.output()
12+
.ok()
13+
.and_then(|o| String::from_utf8(o.stdout).ok())
14+
.map(|s| s.trim().to_string())
15+
.unwrap_or_else(|| "unknown".to_string());
16+
println!("cargo:rustc-env=BUILD_GIT_COMMIT={git_commit}");
1717

18-
built::write_built_file_with_opts(&options, &src, &dst).expect("Failed to acquire build-time information");
19-
}
18+
let rustc_version = Command::new("rustc")
19+
.arg("--version")
20+
.output()
21+
.ok()
22+
.and_then(|o| String::from_utf8(o.stdout).ok())
23+
.map(|s| s.trim().to_string())
24+
.unwrap_or_else(|| "unknown".to_string());
25+
println!("cargo:rustc-env=BUILD_RUSTC_VERSION={rustc_version}");
26+
}

src/dbg.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@ use structopt::clap::crate_version;
22

33
pub fn dbg_info() -> String {
44
format!(
5-
"Crate version {}.\nBuilt from commit {} by {} for target {} with profile '{}' and features = {:?}.",
5+
"Crate version {}.\nBuilt from commit {} by {} for target {} with profile '{}'.",
66
crate_version!(),
7-
built_info::GIT_VERSION.unwrap(),
8-
built_info::RUSTC_VERSION,
9-
built_info::TARGET,
10-
built_info::PROFILE,
11-
built_info::FEATURES
7+
env!("BUILD_GIT_COMMIT"),
8+
env!("BUILD_RUSTC_VERSION"),
9+
env!("BUILD_TARGET"),
10+
env!("BUILD_PROFILE"),
1211
)
1312
}
14-
15-
#[allow(dead_code)]
16-
mod built_info {
17-
include!(concat!(env!("OUT_DIR"), "/built.rs"));
18-
}

0 commit comments

Comments
 (0)