Subject: Re: [PATCH] meson: skip gitweb build when Perl is disabled

From: Patrick Steinhardt <[email-masked]>
Date: Fri, 20 Dec 2024 16:18:01 +0100

On Fri, Dec 20, 2024 at 07:03:23AM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> > -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.

Yup.

> 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.

I don't think it's incorrect. The Perl features are those that the Git
distribution itself uses, including all the Perl modules in "perl/". The
gitweb subsystem, as far as I can see, uses none of those functions and
thus the data we configure in case `perl_features_enabled` is true is
irrelevant for gitweb.

Now I don't disagree with your statement that there are too many
Perl-related variables, but it simply reflects the fact that Git uses it
for multiple different things: testing, git-instaweb, the Perl library,
several Perl-based commands and gitweb. And I think it's not entirely
unreasonable to let users configure these independently of one another,
and that brings some complexity with it.

That being said I'd also be okay to not introduce the separate "gitweb"
option and instead just use the existing "perl" option for it. I don't
mind it all that much.

> > +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".

Oh, yes, indeed. I'll wait a bit for your opinion on the above before
sending a simple typo fix for this.

Patrick