Makefile: wire up build option for deprecated features

With 57ec9254eb (docs: introduce document to announce breaking changes, 2024-06-14), we have introduced a new document that tracks upcoming breaking changes in the Git project. In 2454970930 (BreakingChanges: early adopter option, 2024-10-11) we have amended the document a bit to mention that any introduced breaking changes must be accompanied by logic that allows us to enable the breaking change at compile-time. While we already have two breaking changes lined up, neither of them has such a switch because they predate those instructions. Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and wire it up with both our Makefiles and Meson. This does not yet wire up the build flag for existing deprecations. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 22, 2025 at 12:31 UTC c5bc9a7f94a41c3e719afebf4a6c3e04cba82e4d
6 files changed +19
GIT-BUILD-OPTIONS.in
+1
@@ -45,3 +45,4 @@ GITWEBDIR=@GITWEBDIR@
45 USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
46 LOCALEDIR=@LOCALEDIR@
47 BROKEN_PATH_FIX=@BROKEN_PATH_FIX@
48 +WITH_BREAKING_CHANGES=@WITH_BREAKING_CHANGES@
Makefile
+5
@@ -2230,6 +2230,10 @@ ifdef FSMONITOR_OS_SETTINGS
2230 COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
2231 endif
2232
2233 +ifdef WITH_BREAKING_CHANGES
2234 + BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
2235 +endif
2236 +
2237 ifeq ($(TCLTK_PATH),)
2238 NO_TCLTK = NoThanks
2239 endif
@@ -3187,6 +3191,7 @@ GIT-BUILD-OPTIONS: FORCE
3191 -e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
3192 -e "s|@LOCALEDIR@|\'$(localedir_SQ)\'|" \
3193 -e "s!@BROKEN_PATH_FIX@!\'$(BROKEN_PATH_FIX)\'!" \
3194 + -e "s|@WITH_BREAKING_CHANGES@|\'$(WITH_BREAKING_CHANGES)\'|" \
3195 GIT-BUILD-OPTIONS.in >$@+
3196 @if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
3197 @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
contrib/buildsystems/CMakeLists.txt
+1
@@ -1198,6 +1198,7 @@ string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_opt
1198 string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
1199 string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
1200 string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
1201 +string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
1202 if(USE_VCPKG)
1203 string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
1204 endif()
meson.build
+6
@@ -644,6 +644,12 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
644 build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
645 build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
646
647 +if get_option('breaking_changes')
648 + build_options_config.set('WITH_BREAKING_CHANGES', 'YesPlease')
649 +else
650 + build_options_config.set('WITH_BREAKING_CHANGES', '')
651 +endif
652 +
653 if get_option('sane_tool_path') != ''
654 build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
655 else
meson_options.txt
+2
@@ -43,6 +43,8 @@ option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt',
43 description: 'The backend used for hashing objects with the SHA256 object format')
44
45 # Build tweaks.
46 +option('breaking_changes', type: 'boolean', value: false,
47 + description: 'Enable upcoming breaking changes.')
48 option('macos_use_homebrew_gettext', type: 'boolean', value: true,
49 description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
50
t/test-lib.sh
+4
@@ -1864,6 +1864,10 @@ test_lazy_prereq CURL '
1864 curl --version
1865 '
1866
1867 +test_lazy_prereq WITHOUT_BREAKING_CHANGES '
1868 + test -z "$WITH_BREAKING_CHANGES"
1869 +'
1870 +
1871 # SHA1 is a test if the hash algorithm in use is SHA-1. This is both for tests
1872 # which will not work with other hash algorithms and tests that work but don't
1873 # test anything meaningful (e.g. special values which cause short collisions).