git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 03/12] meson.build: only set build variables for non-default values
@ 2025-03-15  2:46 Ramsay Jones
  2025-03-19 13:36 ` Patrick Steinhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2025-03-15  2:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GIT Mailing-list, Patrick Steinhardt, Adam Dinwoodie


Some preprocessor -Defines have defaults sets in the source code when
they have not been provided to the C compiler. In this case, there is
no need to pass them on the command-line, unless the build requires a
non-standard value.

The build variables for DEFAULT_EDITOR, DEFAULT_HELP_FORMAT along with
DEFAULT_PAGER have appropriate defaults ('vi', 'man' and 'less') set in
the code. Add the preprocessor -Defines to the 'libgit_c_args' only if
the values set with the corresponding 'options' are different to these
standard values.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 meson.build | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index 88a29fd043..24a4c2e3c2 100644
--- a/meson.build
+++ b/meson.build
@@ -693,10 +693,7 @@ endif
 # These variables are used for building libgit.a.
 libgit_c_args = [
   '-DBINDIR="' + get_option('bindir') + '"',
-  '-DDEFAULT_EDITOR="' + get_option('default_editor') + '"',
   '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
-  '-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"',
-  '-DDEFAULT_PAGER="' + get_option('default_pager') + '"',
   '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
   '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
   '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
@@ -708,6 +705,16 @@ libgit_c_args = [
   '-DPAGER_ENV="' + get_option('pager_environment') + '"',
   '-DSHELL_PATH="' + fs.as_posix(shell.full_path()) + '"',
 ]
+if get_option('default_editor') != 'vi'
+  libgit_c_args += '-DDEFAULT_EDITOR="' + get_option('default_editor') + '"'
+endif
+if get_option('default_pager') != 'less'
+  libgit_c_args += '-DDEFAULT_PAGER="' + get_option('default_pager') + '"'
+endif
+if get_option('default_help_format') != 'man'
+  libgit_c_args += '-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"'
+endif
+
 libgit_include_directories = [ '.' ]
 libgit_dependencies = [ ]
 
-- 
2.49.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-20  9:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15  2:46 [PATCH 03/12] meson.build: only set build variables for non-default values Ramsay Jones
2025-03-19 13:36 ` Patrick Steinhardt
2025-03-20  2:22   ` Ramsay Jones
2025-03-20  9:26     ` Patrick Steinhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).