Skip to content

Commit c5bc9a7

Browse files
pks-tgitster
authored andcommitted
Makefile: wire up build option for deprecated features
With 57ec925 (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 2454970 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2187ce7 commit c5bc9a7

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

GIT-BUILD-OPTIONS.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ GITWEBDIR=@GITWEBDIR@
4545
USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
4646
LOCALEDIR=@LOCALEDIR@
4747
BROKEN_PATH_FIX=@BROKEN_PATH_FIX@
48+
WITH_BREAKING_CHANGES=@WITH_BREAKING_CHANGES@

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,10 @@ ifdef FSMONITOR_OS_SETTINGS
22302230
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
22312231
endif
22322232

2233+
ifdef WITH_BREAKING_CHANGES
2234+
BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
2235+
endif
2236+
22332237
ifeq ($(TCLTK_PATH),)
22342238
NO_TCLTK = NoThanks
22352239
endif
@@ -3187,6 +3191,7 @@ GIT-BUILD-OPTIONS: FORCE
31873191
-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
31883192
-e "s|@LOCALEDIR@|\'$(localedir_SQ)\'|" \
31893193
-e "s!@BROKEN_PATH_FIX@!\'$(BROKEN_PATH_FIX)\'!" \
3194+
-e "s|@WITH_BREAKING_CHANGES@|\'$(WITH_BREAKING_CHANGES)\'|" \
31903195
GIT-BUILD-OPTIONS.in >$@+
31913196
@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
31923197
@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi

contrib/buildsystems/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_opt
11981198
string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
11991199
string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
12001200
string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
1201+
string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
12011202
if(USE_VCPKG)
12021203
string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
12031204
endif()

meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
644644
build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
645645
build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
646646

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+
647653
if get_option('sane_tool_path') != ''
648654
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
649655
else

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt',
4343
description: 'The backend used for hashing objects with the SHA256 object format')
4444

4545
# Build tweaks.
46+
option('breaking_changes', type: 'boolean', value: false,
47+
description: 'Enable upcoming breaking changes.')
4648
option('macos_use_homebrew_gettext', type: 'boolean', value: true,
4749
description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
4850

t/test-lib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,10 @@ test_lazy_prereq CURL '
18641864
curl --version
18651865
'
18661866

1867+
test_lazy_prereq WITHOUT_BREAKING_CHANGES '
1868+
test -z "$WITH_BREAKING_CHANGES"
1869+
'
1870+
18671871
# SHA1 is a test if the hash algorithm in use is SHA-1. This is both for tests
18681872
# which will not work with other hash algorithms and tests that work but don't
18691873
# test anything meaningful (e.g. special values which cause short collisions).

0 commit comments

Comments
 (0)