Subject: Re: [PATCH v2 06/11] meson: wire up generation of distribution archive

From: Toon Claes <[email-masked]>
Date: Tue, 21 Jan 2025 13:37:23 +0100

Patrick Steinhardt <[email-masked]> writes:

> 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 adapt it to honor the "MESON_DIST_ROOT" environment variable.

I failed to understand why you couldn't pass the absolute path of the
output file to GIT-VERSION-GEN. So I looked at the previous version of
this patch, and it seems you explain better over there.

I was testing things locally and tried this line for the last argument
to the script:

  run_command(shell, '-c', 'echo $MESON_DIST_ROOT', capture: true, check: true).stdout().strip() / 'version',

And I think I understand it better now. Meson does not execute this when
you run `meson dist`, but when it (re)generates it's build files. At
that stage $MESON_DIST_ROOT is not set.

It's unfortunate we have to learn GIT-VERSION-GEN about the
$MESON_DIST_ROOT environment variable, but I don't see any other way.

--
Toon