GIT-BUILD-OPTIONS: wire up NO_GITWEB option

Building our "gitweb" interface is optional in our Makefile and in Meson and not wired up at all with CMake, but disabling it causes a couple of tests in the t950* range that pull in "t/lib-gitweb.sh". This is because the test library knows to execute gitweb-tests based on whether or not Perl is available, but we may have Perl available and still end up not building gitweb e.g. with `make test NO_GITWEB=YesPlease`. Fix this issue by wiring up a new "NO_GITWEB" build option so that we can skip these tests in case gitweb is not built. Note that this new build option requires us to move the configuration of GIT-BUILD-OPTIONS to a later point in our Meson build instructions. But as that file is only consumed by our tests at runtime this change does not cause any issues. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Dec 27, 2024 at 13:10 UTC cbcc2f79117ded0161b012dc5107f181b5d87b09
6 files changed +40 -28
GIT-BUILD-OPTIONS.in
+1
@@ -24,6 +24,7 @@ LOCALEDIR=@LOCALEDIR@
24 NO_CURL=@NO_CURL@
25 NO_EXPAT=@NO_EXPAT@
26 NO_GETTEXT=@NO_GETTEXT@
27 +NO_GITWEB=@NO_GITWEB@
28 NO_ICONV=@NO_ICONV@
29 NO_PERL=@NO_PERL@
30 NO_PERL_CPAN_FALLBACKS=@NO_PERL_CPAN_FALLBACKS@
Makefile
+1
@@ -3171,6 +3171,7 @@ GIT-BUILD-OPTIONS: FORCE
3171 -e "s|@NO_CURL@|\'$(NO_CURL)\'|" \
3172 -e "s|@NO_EXPAT@|\'$(NO_EXPAT)\'|" \
3173 -e "s|@NO_GETTEXT@|\'$(NO_GETTEXT)\'|" \
3174 + -e "s|@NO_GITWEB@|\'$(NO_GITWEB)\'|" \
3175 -e "s|@NO_ICONV@|\'$(NO_ICONV)\'|" \
3176 -e "s|@NO_PERL@|\'$(NO_PERL)\'|" \
3177 -e "s|@NO_PERL_CPAN_FALLBACKS@|\'$(NO_PERL_CPAN_FALLBACKS_SQ)\'|" \
contrib/buildsystems/CMakeLists.txt
+1
@@ -1184,6 +1184,7 @@ string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_opt
1184 string(REPLACE "@NO_CURL@" "${NO_CURL}" git_build_options "${git_build_options}")
1185 string(REPLACE "@NO_EXPAT@" "${NO_EXPAT}" git_build_options "${git_build_options}")
1186 string(REPLACE "@NO_GETTEXT@" "${NO_GETTEXT}" git_build_options "${git_build_options}")
1187 +string(REPLACE "@NO_GITWEB@" "1" git_build_options "${git_build_options}")
1188 string(REPLACE "@NO_ICONV@" "${NO_ICONV}" git_build_options "${git_build_options}")
1189 string(REPLACE "@NO_PERL@" "${NO_PERL}" git_build_options "${git_build_options}")
1190 string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" git_build_options "${git_build_options}")
meson.build
+31 -28
@@ -1456,34 +1456,6 @@ else
1456 build_options_config.set('RUNTIME_PREFIX', 'false')
1457 endif
1458
1459 -foreach key, value : {
1460 - 'DIFF': diff.full_path(),
1461 - 'GIT_TEST_CMP': diff.full_path() + ' -u',
1462 - 'GIT_TEST_GITPERLLIB': meson.project_build_root() / 'perl',
1463 - 'GIT_TEST_MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
1464 - 'GIT_TEST_POPATH': meson.project_source_root() / 'po',
1465 - 'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
1466 - 'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
1467 - 'PAGER_ENV': get_option('pager_environment'),
1468 - 'PERL_PATH': perl.found() ? perl.full_path() : '',
1469 - 'PYTHON_PATH': python.found () ? python.full_path() : '',
1470 - 'SHELL_PATH': shell.full_path(),
1471 - 'TAR': tar.full_path(),
1472 - 'TEST_OUTPUT_DIRECTORY': test_output_directory,
1473 - 'TEST_SHELL_PATH': shell.full_path(),
1474 -}
1475 - if value != '' and cygpath.found()
1476 - value = run_command(cygpath, value, check: true).stdout().strip()
1477 - endif
1478 - build_options_config.set_quoted(key, value)
1479 -endforeach
1480 -
1481 -configure_file(
1482 - input: 'GIT-BUILD-OPTIONS.in',
1483 - output: 'GIT-BUILD-OPTIONS',
1484 - configuration: build_options_config,
1485 -)
1486 -
1459 git_version_file = custom_target(
1460 command: [
1461 shell,
@@ -1893,6 +1865,9 @@ subdir('contrib')
1865 gitweb_option = get_option('gitweb').disable_auto_if(not perl.found())
1866 if gitweb_option.enabled()
1867 subdir('gitweb')
1868 + build_options_config.set('NO_GITWEB', '')
1869 +else
1870 + build_options_config.set('NO_GITWEB', '1')
1871 endif
1872
1873 subdir('templates')
@@ -1909,6 +1884,34 @@ if get_option('docs') != []
1884 subdir('Documentation')
1885 endif
1886
1887 +foreach key, value : {
1888 + 'DIFF': diff.full_path(),
1889 + 'GIT_TEST_CMP': diff.full_path() + ' -u',
1890 + 'GIT_TEST_GITPERLLIB': meson.project_build_root() / 'perl',
1891 + 'GIT_TEST_MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
1892 + 'GIT_TEST_POPATH': meson.project_source_root() / 'po',
1893 + 'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
1894 + 'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
1895 + 'PAGER_ENV': get_option('pager_environment'),
1896 + 'PERL_PATH': perl.found() ? perl.full_path() : '',
1897 + 'PYTHON_PATH': python.found () ? python.full_path() : '',
1898 + 'SHELL_PATH': shell.full_path(),
1899 + 'TAR': tar.full_path(),
1900 + 'TEST_OUTPUT_DIRECTORY': test_output_directory,
1901 + 'TEST_SHELL_PATH': shell.full_path(),
1902 +}
1903 + if value != '' and cygpath.found()
1904 + value = run_command(cygpath, value, check: true).stdout().strip()
1905 + endif
1906 + build_options_config.set_quoted(key, value)
1907 +endforeach
1908 +
1909 +configure_file(
1910 + input: 'GIT-BUILD-OPTIONS.in',
1911 + output: 'GIT-BUILD-OPTIONS',
1912 + configuration: build_options_config,
1913 +)
1914 +
1915 summary({
1916 'curl': curl.found(),
1917 'expat': expat.found(),
t/lib-gitweb.sh
+5
@@ -105,6 +105,11 @@ if ! test_have_prereq PERL; then
105 test_done
106 fi
107
108 +if ! test_have_prereq GITWEB; then
109 + skip_all='skipping gitweb tests, gitweb not available'
110 + test_done
111 +fi
112 +
113 perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
114 skip_all='skipping gitweb tests, perl version is too old'
115 test_done
t/test-lib.sh
+1
@@ -1687,6 +1687,7 @@ esac
1687
1688 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
1689 test -z "$NO_CURL" && test_set_prereq LIBCURL
1690 +test -z "$NO_GITWEB" && test_set_prereq GITWEB
1691 test -z "$NO_ICONV" && test_set_prereq ICONV
1692 test -z "$NO_PERL" && test_set_prereq PERL
1693 test -z "$NO_PTHREADS" && test_set_prereq PTHREADS