mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.47k stars 1.59k forks source link

Subprojects are not included in tarball, when behind a disabled option #11081

Open evelikov opened 1 year ago

evelikov commented 1 year ago

Describe the bug

Consider a project where you have a handful of options, that pull in subprojects as dependencies. Some of those options are disabled by default.

Unless one explicitly enables all relevant options, meson dist --include-subprojects (with or w/o --no-tests) will not bundle some of the subprojects in the distribution tarball.

One can audit and enable each option during meson setup -D foo=true -D bar=enabled, although that is not always possible.

Consider the following example: The project builds on Linux, MacOS, Windows, etc and you are creating the tarball on one platform. Yet running meson setup -D windows=true -D linux=true -D macos=true fails, since not all the required dependencies are available. Hence you cannot create complete, self-contained distribution tarball.

To Reproduce

Note that my reproducer is a little less convoluted than the one described. It merely guards the tests (and hence cmocka subproject) behind a build-tests bool option.

Expected behavior

system parameters

xclaesse commented 1 year ago

I guess we could keep --include-subprojects with no extra argument to only include subprojects that have been used for current setup, and extend the syntax to --include-subprojects foo,bar to only include foo and bar regardless of which subprojects have been used for the setup?

xclaesse commented 1 year ago

Note that the original use-case for --include-subprojects is to make a specific build reproductible. For example when configuring GStreamer for a specific device we want to be able to ship the source code of exactly what is being used on that device. It is for example required for legal reason.

evelikov commented 1 year ago

Thanks Xavier.

Is there a reason why meson cannot traverse across the subprojects directory and add them all?

AFAICT meson subprojects foreach already knows how to do that and is not limited solely to the subprojects pulled in as dependencies.

As you pointed out - this new functionality could be under a new name or toggle. Be that --include-subprojects --all or anything else the meson team is happy with.

xclaesse commented 1 year ago

@evelikov I guess we can add --include-subprojects * or all. PR welcome ;-)