Re: [PATCH v2 03/13] meson.build: only set build variables for non-default values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 06/04/2025 20:38, Ramsay Jones wrote:
[snip]
> diff --git a/meson.build b/meson.build
> index 88a29fd043..efd0bd3319 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -693,10 +693,8 @@ 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 +706,17 @@ libgit_c_args = [
>    '-DPAGER_ENV="' + get_option('pager_environment') + '"',
>    '-DSHELL_PATH="' + fs.as_posix(shell.full_path()) + '"',
>  ]
> +
> +editor_opt = get_option('default_editor')
> +if editor_opt != '' and editor_opt != 'vi'
> +  libgit_c_args += '-DDEFAULT_EDITOR="' + editor_opt + '"'
> +endif
> +
> +pager_opt = get_option('default_pager')
> +if pager_opt != '' and pager_opt != 'less'
> +  libgit_c_args += '-DDEFAULT_PAGER="' + pager_opt + '"'
> +endif
> +
>  libgit_include_directories = [ '.' ]
>  libgit_dependencies = [ ]
>  


It would be somewhat remiss of me to not mention here that this does not
work for any but the simplest of values! :( If you set a simple single
'bareword' like 'vim' or 'more' (even '~/bin/vi') then every thing works
just fine. However, if the value contains any of (at least) the following
characters: single quote, double quote or backslash, then things
stop working!

[I spent one whole evening (and a bit - always something else to 'try')
trying to 'fix' this problem, without success]

If you try an example that is given in the Makefile:312, then the make build:

  $ make V=1 DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork' all doc >m-out 2>&1

passes the folowing arguments to (respectively) gcc and asciidoc:

  -DDEFAULT_EDITOR='"\"C:\\Program Files\\Vim\\gvim.exe\" --nofork"'
  -a 'git-default-editor="C:\Program Files\Vim\gvim.exe" --nofork'

whereas, the meson build:

  $ meson setup --optimization=2 -Ddocs=man,html -Ddefault_editor='"C:\Program Files\Vim\gvim.exe" --nofork' -Ddefault_pager=more -Dprefix=$HOME -Dpcre2=disabled build/
  The Meson build system
  ...
   User defined options
      optimization  : 2
      prefix        : /home/ramsay
      default_editor: "C:\Program Files\Vim\gvim.exe" --nofork
      default_pager : more
      docs          : man,html
      pcre2         : disabled

  Found ninja-1.11.1 at /usr/bin/ninja
  $ 

similarly, passes the folowing arguments to (respectively) gcc and asciidoc:

  '-DDEFAULT_EDITOR=""C:\\Program Files\\Vim\\gvim.exe" --nofork"'
  '-agit-default-editor="C:/Program Files/Vim/gvim.exe" --nofork'

If you now attempt a 'meson compile' it will, of course, fail to compile
editor.c because the DEFAULT_EDITOR is the empty string ("") followed by
(C:\\Program Files\\Vim\\gvim.exe" --nofork").

Also, note that the directory seperators have changed from \\ to / in the
argument to asciidoc.

[Again, spelunking the docs for meson, it said that "if you want quotes, you
will have to do it yourself"! ;) ]

OK, so I couldn't come up with any incantation which would fix this issue.
I will have to admit defeat and ask someone who actually knows meson to
fix it. :(

Thanks.

ATB,
Ramsay Jones







[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux