The build::SHORT_COMMIT is not latest
wisarmy opened this issue · 5 comments
code
use shadow_rs::shadow;
shadow!(build);
pub fn default() -> String {
format!(
"{} {}+{}+{}+{}",
build::PKG_VERSION,
build::BRANCH,
build::SHORT_COMMIT,
build::BUILD_TARGET,
build::BUILD_RUST_CHANNEL,
)
}
Details of the problem
The git latest hash is ef8195a97d0875940d591ec160aea13619a6c4d4
, but println build::SHORT_COMMIT
is an old hash ebb4cc3170d56efb7a53ae9be8ab29ba339791f2
. The build::SHORT_COMMIT
is updated only when the target directory is deleted
The command-line log is as follows:
➜ rustlab git:(main) git log -n3|cat (0s)[22-06-25 16:37:15]
commit ef8195a97d0875940d591ec160aea13619a6c4d4
Author: Wisarmy Gao <wisarmy@gmail.com>
Date: Sat Jun 25 16:00:40 2022 +0800
Update main.rs
commit b1296daa51bb1e49cccab07856439ad8f4b4fbd0
Author: Wisarmy Gao <wisarmy@gmail.com>
Date: Sat Jun 25 15:57:30 2022 +0800
Create README.md
commit ebb4cc3170d56efb7a53ae9be8ab29ba339791f2
Author: gaomingjun <wisarmy@gmail.com>
Date: Sat Jun 25 15:50:00 2022 +0800
add version
➜ rustlab git:(main) cargo run (0s)[22-06-25 16:37:19]
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/rustlab`
version: 0.1.0 main+ebb4cc31+aarch64-apple-darwin+debug
➜ rustlab git:(main) cargo build --release (0s)[22-06-25 16:37:33]
Compiling rustlab v0.1.0 (/Users/gaomingjun/Developer/Rust/labs/rustlab)
Finished release [optimized] target(s) in 0.95s
➜ rustlab git:(main) ./target/release/rustlab (1s)[22-06-25 16:37:50]
version: 0.1.0 main+ebb4cc31+aarch64-apple-darwin+release
shadow-rs version
[dependencies]
shadow-rs = "0.11.0"
[build-dependencies]
shadow-rs = "0.11.0"
Hi @wisarmy.
I tested it myself, at least it's not a bug.
The reason for this is that the rebuild is not used. The recommended way is to cargo clean first, then execute cargo build, or use the ci/cd pipeline tool to help you perform this operation.
Ref link:
Yes, But it's always inconvenient.
fn main() -> shadow_rs::SdResult<()> {
println!("cargo:rerun-if-changed=.");
shadow_rs::new()
}
Can be used as an optimization option in the future.
Thanks @baoyachi
Yes, But it's always inconvenient.
fn main() -> shadow_rs::SdResult<()> { println!("cargo:rerun-if-changed=."); shadow_rs::new() }Can be used as an optimization option in the future.
Thanks @baoyachi
Oh,println!("cargo:rerun-if-changed=.");
not adapted cargo workspace
Yes, really is not good.
I found anthor crate, It's expected. I don't know how it's done. cargo rebuilt when git is committed, only files are changed not rebuilt