Skip to content

Commit cddcee7

Browse files
eli-schwartzgitster
authored andcommitted
meson: reformat default options to workaround bug in meson configure
Since 13cb20f ("meson: fix compilation with Visual Studio", 2025-01-22) it has not been possible to list build options via `meson configure`. This is due to Meson's static analysis of build options failing to handle constant folding, and thinking we set a totally invalid default `-std=`. This is reported upstream but we anyways need to work with existing versions. It turns out there is a simple solution: turn the entire default option into a conditional branch, which means Meson sees either nothing, or everything. As a result, Git users can once again see pretty-printed options before building. Reported-by: Ramsay Jones <[email protected]> Bug: mesonbuild/meson#14623 Signed-off-by: Eli Schwartz <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d50a5e8 commit cddcee7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

meson.build

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,12 @@ project('git', 'c',
178178
capture: true,
179179
check: true,
180180
).stdout().strip() : 'unknown',
181-
default_options: [
182-
# Git requires C99 with GNU extensions, which of course isn't supported by
183-
# MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
184-
# learned to define __STDC_VERSION__ with C11 and later. We thus require
185-
# GNU C99 and fall back to C11. Meson only learned to handle the fallback
186-
# with version 1.3.0, so on older versions we use GNU C99 unconditionally.
187-
'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'gnu99,c11' : 'gnu99'),
188-
],
181+
# Git requires C99 with GNU extensions, which of course isn't supported by
182+
# MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
183+
# learned to define __STDC_VERSION__ with C11 and later. We thus require
184+
# GNU C99 and fall back to C11. Meson only learned to handle the fallback
185+
# with version 1.3.0, so on older versions we use GNU C99 unconditionally.
186+
default_options: meson.version().version_compare('>=1.3.0') ? ['c_std=gnu99,c11'] : ['c_std=gnu99'],
189187
)
190188

191189
fs = import('fs')

0 commit comments

Comments
 (0)