Add BUILD_VERSION to lib.rs

In CMake this used a `version` file in the CARGO_MANIFEST_DIR, but
relying on that is problematic due to change-detection, as if we add
`cargo-rerun-if-changed:version`, cargo would rerun every time if the file does
not exist, since cargo would expect the file to be generated by the
build-script. We could generate it, but that relies on the output of `git
describe`, whose dependencies we can only limit to anything in the
`.git`-folder, again causing unnecessary build-script runs.

Instead, this reads the `FISH_BUILD_VERSION`-env-variable at compile time
instead of the `version`-file, and falls back to calling git-describe through
the `git_version`-proc-macro. We thus do not need to deal with extraneous
build-script running.
This commit is contained in:
Henrik Hørlück Berg
2023-08-20 15:48:41 +02:00
committed by Fabian Boehm
parent 360ba46660
commit e7f8fb04cc
4 changed files with 37 additions and 2 deletions

View File

@@ -60,6 +60,7 @@ rand = { version = "0.8.5", features = ["small_rng"] }
unixstring = "0.2.7"
widestring = "1.0.2"
rand_pcg = "0.3.1"
git-version = "0.3"
[build-dependencies]
autocxx-build = "0.23.1"
@@ -80,4 +81,4 @@ fish-ffi-tests = ["inventory"]
# The following features are auto-detected by the build-script and should not be enabled manually.
asan = []
bsd = []
bsd = []