Skip to content

Commit 381ecc0

Browse files
committed
fix: ability to build with cargo install
1 parent 13708c5 commit 381ecc0

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

Cargo.lock

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bestool/build.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ fn main() {
88
windows_exe_info::versioninfo::link_cargo_env();
99
windows_exe_info::manifest(Path::new("windows-manifest.xml"));
1010

11-
build_data::set_GIT_BRANCH();
12-
build_data::set_GIT_COMMIT();
13-
build_data::set_GIT_DIRTY();
11+
if std::fs::exists("../../.git").unwrap_or(false) {
12+
build_data::set_GIT_BRANCH();
13+
build_data::set_GIT_COMMIT();
14+
build_data::set_GIT_DIRTY();
15+
}
16+
1417
build_data::set_SOURCE_TIMESTAMP();
1518
build_data::no_debug_rebuilds();
1619
}

crates/bestool/src/args.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ fn long_version() -> String {
1212

1313
#[cfg(not(docsrs))]
1414
fn long_version() -> String {
15-
format!(
16-
"{} built from branch={} commit={} dirty={} source_timestamp={}",
17-
env!("CARGO_PKG_VERSION"),
18-
env!("GIT_BRANCH"),
19-
env!("GIT_COMMIT"),
20-
env!("GIT_DIRTY"),
21-
env!("SOURCE_TIMESTAMP"),
22-
)
15+
if let (Some(branch), Some(commit), Some(dirty)) = (
16+
env_option!("GIT_BRANCH"),
17+
env_option!("GIT_COMMIT"),
18+
env_option!("GIT_DIRTY"),
19+
) {
20+
format!(
21+
"{} built from branch={branch} commit={commit} dirty={dirty} source_timestamp={}",
22+
env!("CARGO_PKG_VERSION"),
23+
env!("SOURCE_TIMESTAMP"),
24+
)
25+
} else {
26+
format!(
27+
"{} built from crate source_timestamp={}",
28+
env!("CARGO_PKG_VERSION"),
29+
env!("SOURCE_TIMESTAMP"),
30+
)
31+
}
2332
}
2433

2534
/// BES Tooling

0 commit comments

Comments
 (0)