Patrick Steinhardt <ps@xxxxxx> writes: > It is possible to configure a Git build without Perl when disabling both > our test suite and all Perl-based features. In Meson, this can be > achieved with `meson setup -Dperl=disabled -Dtests=false`. > > It was reported by a user that this breaks the Meson build because > gitweb gets built even if Perl was not discovered in such a build: > > $ meson setup .. -Dtests=false -Dperl=disabled > ... > ../gitweb/meson.build:2:43: ERROR: Unable to get the path of a not-found external program > > Fix this issue by introducing a new feature-option that allows the user > to configure whether or not to build Gitweb. The feature is set to > 'auto' by default and will be disabled automatically in case Perl was > not found on the system. > > Reported-by: Daniel Engberg <daniel.engberg.lists@xxxxxxxxx> > Signed-off-by: Patrick Steinhardt <ps@xxxxxx> > --- > Hi, > > I received an off-list mail from a user interested in the new Meson > build system who has done a bit of testing of it on FreeBSD. They found > an issue when configuring the build without Perl enabled, which can be > achieved by both disabling tests and Perl-based features. This patch > here fixes the issue. > > Thanks! Thanks, Patrick and Daniel. > -if get_option('tests') > +if get_option('tests') or get_option('gitweb').enabled() > perl_required = true > endif OK, so we use "perl_required" to keep track of the fact that something else wants Perl to be usable. > +# Gitweb requires Perl, so we disable the auto-feature if Perl was not found. > +# We make sure further up that Perl is required in case the gitweb option is > +# enabled. > +gitweb_option = get_option('gitweb').disable_auto_if(not perl.found()) Hopefully before we reach this point, we would have figured out if perl is avialable, to allow us do this. There seem to be too many "perl" related variables, interaction among which smells way too complex for their worth. For example, perl = find_program('perl', ..., required: perl_required); perl_features_enabled = perl.found() and get_option('perl').allowed() and only when the latter is true, we'd do further configuration to make perl usable. Does that mean the condition you wrote above to automatically disable gitweb somewhat incorrect? Even if we may have found perl, the builder may deliberately have disallowed use of it, in which case we just know perl is there without figuring out what other things (like where the localedir is) that are needed to use it correctly. > +if gitweb_option.enabled() > + subdir('gitweb') > +endif > + > subdir('templates') OK, we used to do the subdir() thing unconditionally, but now, if we decide that we shouldn't or cannot do gitweb, we do not do that,which sounds good. > +option('gitweb', type: 'feature', value: 'auto', > + description: 'Build Git web interface. Required Perl.') I do not know the convention in the meson world, but to me, this would sound more natural with "Required" -> "Requires". > option('iconv', type: 'feature', value: 'auto', > description: 'Support reencoding strings with different encodings.') > option('pcre2', type: 'feature', value: 'enabled', > > --- > base-commit: d882f382b3d939d90cfa58d17b17802338f05d66 > change-id: 20241218-b4-pks-meson-fix-gitweb-wo-perl-93379dd0ceed