]> git.ipfire.org Git - thirdparty/git.git/commitdiff
meson: reformat default options to workaround bug in `meson configure`
authorEli Schwartz <eschwartz@gentoo.org>
Mon, 19 May 2025 17:09:42 +0000 (13:09 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 May 2025 18:32:27 +0000 (11:32 -0700)
Since 13cb20fc46 ("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 <ramsay@ramsayjones.plus.com>
Bug: https://github.com/mesonbuild/meson/issues/14623
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
meson.build

index efe2871c9dba1318297f92ff8b412ce485c84500..71396f3436bb44e07013917f59f7872efd7ff88f 100644 (file)
@@ -178,14 +178,12 @@ project('git', 'c',
     capture: true,
     check: true,
   ).stdout().strip() : 'unknown',
-  default_options: [
-    # Git requires C99 with GNU extensions, which of course isn't supported by
-    # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
-    # learned to define __STDC_VERSION__ with C11 and later. We thus require
-    # GNU C99 and fall back to C11. Meson only learned to handle the fallback
-    # with version 1.3.0, so on older versions we use GNU C99 unconditionally.
-    'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'gnu99,c11' : 'gnu99'),
-  ],
+  # Git requires C99 with GNU extensions, which of course isn't supported by
+  # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only
+  # learned to define __STDC_VERSION__ with C11 and later. We thus require
+  # GNU C99 and fall back to C11. Meson only learned to handle the fallback
+  # with version 1.3.0, so on older versions we use GNU C99 unconditionally.
+  default_options: meson.version().version_compare('>=1.3.0') ? ['c_std=gnu99,c11'] : ['c_std=gnu99'],
 )
 
 fs = import('fs')