Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The build::SHORT_COMMIT is not latest #95

Closed
wisarmy opened this issue Jun 25, 2022 · 5 comments
Closed

The build::SHORT_COMMIT is not latest #95

wisarmy opened this issue Jun 25, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@wisarmy
Copy link

wisarmy commented Jun 25, 2022

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"
@baoyachi baoyachi added the question Further information is requested label Jun 30, 2022
@baoyachi baoyachi self-assigned this Jun 30, 2022
@baoyachi
Copy link
Owner

baoyachi commented Jul 1, 2022

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:

@baoyachi
Copy link
Owner

baoyachi commented Jul 1, 2022

@baoyachi baoyachi closed this as completed Jul 1, 2022
@wisarmy
Copy link
Author

wisarmy commented Jul 1, 2022

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

@baoyachi
Copy link
Owner

baoyachi commented Jul 1, 2022

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

@wisarmy
Copy link
Author

wisarmy commented Jul 1, 2022

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants