Skip to content

Commit 88d4bff

Browse files
pks-tgitster
authored andcommitted
meson: wire up generation of distribution archive
Meson knows to generate distribution archives via `meson dist`. In addition to generating the archive itself, this target also knows to compile and execute tests from that archive, which helps to ensure that the result is an adequate drop-in replacement for the versioned project. While this already works as-is, one omission is that we don't propagate the commit that this is built from into the resulting archive. This can be fixed though by adding a distribution script that propagates the version into the "version" file, which GIT-VERSION-GEN knows to read if present. Use GIT-VERSION-GEN to populate that file. As the script is executed in the build directory, not in the directory where we generate the archive, we have to use a shell to resolve the "MESON_DIST_ROOT" environment variable. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d0cf6b commit 88d4bff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

meson.build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,19 @@ devenv.set('GIT_BUILD_DIR', meson.current_build_dir())
19471947
devenv.prepend('PATH', meson.current_build_dir() / 'bin-wrappers')
19481948
meson.add_devenv(devenv)
19491949

1950+
# Generate the 'version' file in the distribution tarball. This is used via
1951+
# `meson dist -C <builddir>` to populate the source archive with the Git
1952+
# version that the archive is being generated from.
1953+
meson.add_dist_script(
1954+
shell,
1955+
'-c',
1956+
'"$1" "$2" "$3" --format="@GIT_VERSION@" "$MESON_DIST_ROOT/version"',
1957+
'GIT-VERSION-GEN',
1958+
shell,
1959+
meson.current_source_dir() / 'GIT-VERSION-GEN',
1960+
meson.current_source_dir(),
1961+
)
1962+
19501963
summary({
19511964
'curl': curl.found(),
19521965
'expat': expat.found(),

0 commit comments

Comments
 (0)