diff mbox series

[v2,04/13] meson.build: set default help format to html on windows

Message ID 34349bf98c5b01dd1b73065448b616517bb784a3.1743859985.git.ramsay@ramsayjones.plus.com (mailing list archive)
State New
Headers show
Series miscellaneous build mods (part 1) | expand

Commit Message

Ramsay Jones April 6, 2025, 7:38 p.m. UTC
The build variable DEFAULT_HELP_FORMAT has an appropriate default
('man') set in the code, so there is no need to pass the -Define on
the compiler command-line, unless the build requires a non-standard
value.

In addition, on windows the make build overrides the default help
format to 'html', rather than 'man', in the 'config.mak.uname' file.

In order to suppress the -Define on the C compiler command-line, only
add the -Define to the 'libgit_c_args' variable when the requested
value is not the standard 'man'. In order to override the default value
on windows, add a 'platform' value to the 'default_help_format' combo
option and set it as the default choice. When this option is set to
'platform', use the 'host_machine.system()' method call to determine the
appropriate default value for the host system.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 meson.build       | 13 ++++++++++++-
 meson_options.txt |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Ramsay Jones April 6, 2025, 8:16 p.m. UTC | #1
On 06/04/2025 20:38, Ramsay Jones wrote:
> The build variable DEFAULT_HELP_FORMAT has an appropriate default
> ('man') set in the code, so there is no need to pass the -Define on
> the compiler command-line, unless the build requires a non-standard
> value.
> 
> In addition, on windows the make build overrides the default help
> format to 'html', rather than 'man', in the 'config.mak.uname' file.
> 
> In order to suppress the -Define on the C compiler command-line, only
> add the -Define to the 'libgit_c_args' variable when the requested
> value is not the standard 'man'. In order to override the default value
> on windows, add a 'platform' value to the 'default_help_format' combo
> option and set it as the default choice. When this option is set to
> 'platform', use the 'host_machine.system()' method call to determine the
> appropriate default value for the host system.
> 
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>  meson.build       | 13 ++++++++++++-
>  meson_options.txt |  2 +-
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index efd0bd3319..8f8a258064 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -694,7 +694,6 @@ endif
>  libgit_c_args = [
>    '-DBINDIR="' + get_option('bindir') + '"',
>    '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
> -  '-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"',
>    '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
>    '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
>    '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
> @@ -717,6 +716,18 @@ if pager_opt != '' and pager_opt != 'less'
>    libgit_c_args += '-DDEFAULT_PAGER="' + pager_opt + '"'
>  endif
>  
> +help_format_opt = get_option('default_help_format')
> +if help_format_opt == 'platform'
> +  if host_machine.system() == 'windows'
> +    help_format_opt = 'html'
> +  else
> +    help_format_opt = 'man'
> +  endif
> +endif
> +if help_format_opt != 'man'
> +    libgit_c_args += '-DDEFAULT_HELP_FORMAT="' + help_format_opt + '"'
> +endif
> +

Note that host_machine.system() classifies 'cygwin' to include cygwin and
MSYS2 and 'windows' as windows but not cygwin or MSYS2! ;) The make build
overrides the help format to 'html' for windows and MINGW{32,64}, so it is
not clear to me if the test above includes MINGW.

Also, in general cygwin != MSYS2 != MINGW{32,6} != Gfw flavour MSYS2, but
it appears meson does not allow you to obtain such specific system info
(for example, by executing uname directly).

[Just a note that the make build includes 'info' as a choice, but Patrick
made the decision earlier to drop that for the meson build. Also, there is
a 'pdf' make target (I think that made it once, years ago ...)]

Thanks.

ATB,
Ramsay Jones
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index efd0bd3319..8f8a258064 100644
--- a/meson.build
+++ b/meson.build
@@ -694,7 +694,6 @@  endif
 libgit_c_args = [
   '-DBINDIR="' + get_option('bindir') + '"',
   '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
-  '-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"',
   '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
   '-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
   '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
@@ -717,6 +716,18 @@  if pager_opt != '' and pager_opt != 'less'
   libgit_c_args += '-DDEFAULT_PAGER="' + pager_opt + '"'
 endif
 
+help_format_opt = get_option('default_help_format')
+if help_format_opt == 'platform'
+  if host_machine.system() == 'windows'
+    help_format_opt = 'html'
+  else
+    help_format_opt = 'man'
+  endif
+endif
+if help_format_opt != 'man'
+    libgit_c_args += '-DDEFAULT_HELP_FORMAT="' + help_format_opt + '"'
+endif
+
 libgit_include_directories = [ '.' ]
 libgit_dependencies = [ ]
 
diff --git a/meson_options.txt b/meson_options.txt
index 78d172a740..8ac30a5223 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -95,7 +95,7 @@  option('highlight_bin', type: 'string', value: 'highlight')
 # Documentation.
 option('docs', type: 'array', choices: ['man', 'html'], value: [],
   description: 'Which documenattion formats to build and install.')
-option('default_help_format', type: 'combo', choices: ['man', 'html'], value: 'man',
+option('default_help_format', type: 'combo', choices: ['man', 'html', 'platform'], value: 'platform',
   description: 'Default format used when executing git-help(1).')
 option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto'], value: 'auto',
   description: 'Which backend to use to generate documentation.')