Re: [PATCH v2 03/13] meson.build: only set build variables for non-default values
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 14, 2025, 07:54 UTC
- Message-ID
- <Z_y_Tp5pfJ-gZLEF@pks.im>
- In-Reply-To
- <a5795bfa-cc02-4c9a-b7d2-4924a94cd0db@ramsayjones.plus.com>
On Sun, Apr 06, 2025 at 08:49:54PM +0100, Ramsay Jones wrote:
Show 48 quoted lines
>
>
> 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]Shouldn't it be possible to escape these values via `.replace()` [1]? I suspect that you already tried, but wanted to ask anyway :)
Patrick
[1]: https://mesonbuild.com/Reference-manual_elementary_str.html#strreplace