Skip to content

Commit 65e3757

Browse files
ramsay-jonesgitster
authored andcommitted
meson.build: only set build variables for non-default values
Some preprocessor -Defines have defaults set 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 and DEFAULT_PAGER have appropriate defaults ('vi' 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. Also, the 'git-var' documentation contains some conditional text which documents the chosen compiled in value, which would not read well for the standard values. Similar to the above, only add the corresponding '-a' attribute arguments to the 'asciidoc_common_options' variable, if the values set in the 'options' are different to these standard values. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 507c63f commit 65e3757

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

Documentation/meson.build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ if docs_backend == 'asciidoc'
242242
'--attribute=build_dir=' + meson.current_build_dir(),
243243
]
244244

245+
pager_opt = get_option('default_pager')
246+
if pager_opt != '' and pager_opt != 'less'
247+
asciidoc_common_options += '-agit-default-pager=' + pager_opt
248+
endif
249+
250+
editor_opt = get_option('default_editor')
251+
if editor_opt != '' and editor_opt != 'vi'
252+
asciidoc_common_options += '-agit-default-editor=' + editor_opt
253+
endif
254+
245255
documentation_deps = [
246256
asciidoc_conf,
247257
]
@@ -279,6 +289,16 @@ elif docs_backend == 'asciidoctor'
279289
'--require', 'asciidoctor-extensions',
280290
]
281291

292+
pager_opt = get_option('default_pager')
293+
if pager_opt != '' and pager_opt != 'less'
294+
asciidoc_common_options += '-agit-default-pager=' + pager_opt
295+
endif
296+
297+
editor_opt = get_option('default_editor')
298+
if editor_opt != '' and editor_opt != 'vi'
299+
asciidoc_common_options += '-agit-default-editor=' + editor_opt
300+
endif
301+
282302
documentation_deps = [
283303
asciidoctor_extensions,
284304
]

meson.build

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,8 @@ endif
693693
# These variables are used for building libgit.a.
694694
libgit_c_args = [
695695
'-DBINDIR="' + get_option('bindir') + '"',
696-
'-DDEFAULT_EDITOR="' + get_option('default_editor') + '"',
697696
'-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
698697
'-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"',
699-
'-DDEFAULT_PAGER="' + get_option('default_pager') + '"',
700698
'-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
701699
'-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
702700
'-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
@@ -708,6 +706,17 @@ libgit_c_args = [
708706
'-DPAGER_ENV="' + get_option('pager_environment') + '"',
709707
'-DSHELL_PATH="' + fs.as_posix(shell.full_path()) + '"',
710708
]
709+
710+
editor_opt = get_option('default_editor')
711+
if editor_opt != '' and editor_opt != 'vi'
712+
libgit_c_args += '-DDEFAULT_EDITOR="' + editor_opt + '"'
713+
endif
714+
715+
pager_opt = get_option('default_pager')
716+
if pager_opt != '' and pager_opt != 'less'
717+
libgit_c_args += '-DDEFAULT_PAGER="' + pager_opt + '"'
718+
endif
719+
711720
libgit_include_directories = [ '.' ]
712721
libgit_dependencies = [ ]
713722

0 commit comments

Comments
 (0)