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@xxxxxxxxxxxxxxxxxxxx> --- 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