meson: skip gitweb build when Perl is disabled

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@pyret.net> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Dec 20, 2024 at 17:30 UTC 7d549fe317f8c4eea25f5212bc9f8e73b4b2608e
2 files changed +13 -2
meson.build
+11 -2
@@ -740,7 +740,7 @@ endif
740 # features. It is optional if you want to neither execute tests nor use any of
741 # these optional features.
742 perl_required = get_option('perl')
743 -if get_option('tests')
743 +if get_option('tests') or get_option('gitweb').enabled()
744 perl_required = true
745 endif
746
@@ -1874,7 +1874,15 @@ if intl.found()
1874 subdir('po')
1875 endif
1876 subdir('contrib')
1877 -subdir('gitweb')
1877 +
1878 +# Gitweb requires Perl, so we disable the auto-feature if Perl was not found.
1879 +# We make sure further up that Perl is required in case the gitweb option is
1880 +# enabled.
1881 +gitweb_option = get_option('gitweb').disable_auto_if(not perl.found())
1882 +if gitweb_option.enabled()
1883 + subdir('gitweb')
1884 +endif
1885 +
1886 subdir('templates')
1887
1888 # Everything but the bin-wrappers need to come before this target such that we
@@ -1893,6 +1901,7 @@ summary({
1901 'curl': curl.found(),
1902 'expat': expat.found(),
1903 'gettext': intl.found(),
1904 + 'gitweb': gitweb_option.enabled(),
1905 'https': https_backend,
1906 'iconv': iconv.found(),
1907 'pcre2': pcre2.found(),
meson_options.txt
+2
@@ -23,6 +23,8 @@ option('expat', type: 'feature', value: 'enabled',
23 description: 'Build helpers used to push to remotes with the HTTP transport.')
24 option('gettext', type: 'feature', value: 'auto',
25 description: 'Build translation files.')
26 +option('gitweb', type: 'feature', value: 'auto',
27 + description: 'Build Git web interface. Requires Perl.')
28 option('iconv', type: 'feature', value: 'auto',
29 description: 'Support reencoding strings with different encodings.')
30 option('pcre2', type: 'feature', value: 'enabled',