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

sui: limit when the build script needs to be run #2026

Merged
merged 1 commit into from
May 18, 2022

Conversation

bmwill
Copy link
Contributor

@bmwill bmwill commented May 18, 2022

Support for embedding the git revision inside the wallet cli was added
back in 96611e0 (wallet: log git revision on start, 2022-04-22). This
was done by using a build.rs file to run a few git commands to query for
the git revision of HEAD and if the working directory was dirty or not.

The addition of this feature had the unintended consequence of causing
a ton of code to be re-build anytime any file in the sui crate was
changed. This is due to the fact that, by default, a build.rs file is
re-run anytime any file anywhere in the crate (integration tests and
examples included) [1].

This patch fixes this by only having cargo re-run the build script when
the build.rs file is changed.

[1] https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorerun-if-changedpath

Support for embedding the git revision inside the wallet cli was added
back in 96611e0 (wallet: log git revision on start, 2022-04-22). This
was done by using a build.rs file to run a few git commands to query for
the git revision of HEAD and if the working directory was dirty or not.

The addition of this feature had the unintended consequence of causing
a ton of code to be re-build anytime any file in the `sui` crate was
changed. This is due to the fact that, by default, a build.rs file is
re-run anytime any file anywhere in the crate (integration tests and
examples included) [1].

This patch fixes this by only having cargo re-run the build script when
the build.rs file is changed.

[1] https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorerun-if-changedpath
@bmwill bmwill requested a review from mystenmark May 18, 2022 00:07
@bmwill bmwill enabled auto-merge (rebase) May 18, 2022 00:08
@bmwill bmwill disabled auto-merge May 18, 2022 00:10
@bmwill bmwill enabled auto-merge (squash) May 18, 2022 00:10
@mystenmark
Copy link
Contributor

Hmm, but that's not what we want, is it? We want build.rs to always run in order to fetch the current git revision, right?

@mystenmark
Copy link
Contributor

Hmm, ok, for release builds (which are clean) this shouldn't impact anything. I think this could potentially cause us to get a bad git rev in a build but that's hardly the end of the world.

@bmwill
Copy link
Contributor Author

bmwill commented May 18, 2022

yeah its really hard to do this is completely fool-proof way. I suppose another option would be to use a proc-macro like https://docs.rs/git-version/latest/git_version/ instead of a build script and query it just from the binary (that way when the binary is recompiled it properly picks up the correct version.

@bmwill bmwill merged commit acb2b97 into MystenLabs:main May 18, 2022
@bmwill bmwill deleted the fix-test-compilation branch May 28, 2022 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants