qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] meson.build: Don't look for libudev for static builds


From: Yonggang Luo
Subject: Re: [PATCH] meson.build: Don't look for libudev for static builds
Date: Sat, 3 Oct 2020 16:29:54 +0800



On Sat, Oct 3, 2020 at 3:50 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 03/10/20 09:24, 罗勇刚(Yonggang Luo) wrote:
> >
> >
> > On Fri, Oct 2, 2020 at 9:11 PM Peter Maydell <peter.maydell@linaro.org
> > <mailto:peter.maydell@linaro.org>> wrote:
> >>
> >> On Fri, 2 Oct 2020 at 14:05, Paolo Bonzini <pbonzini@redhat.com
> > <mailto:pbonzini@redhat.com>> wrote:
> >> >
> >> > On 02/10/20 14:35, Peter Maydell wrote:
> >> > >
> >> > > It would be better to do the "see if a static library is present"
> >> > > test. This isn't too hard to do in configure (compare that
> >> > > six line fix to the detection of libgio). Hopefully it is
> >> > > not too hard to do in meson ?
> >> >
> >> > Yes, something like:
> >> >
> >> > if enable_static
> >> >   skeleton = 'int main(void) { return 0; }'
> >> >   if not cc.links(skeleton, dependencies: libudev)
> >> >     if get_option('mpath').enabled()
> >> >         error('Cannot link with libudev')
> >> >       else
> >> >         warning('Cannot link with libudev, disabling')
> >> >         libudev = not_found
> >> >       endif
> >> >     endif
> >> >   endif
> >> > endif
> >>
> >> This duplicates the information that the thing that depends
> >> on libudev is mpath. Can we put this in a wrapper around
> >> dependency() so that we could just say something like
> >>   libudev = compile_checked_dependency('libudev',
> >>                        required: get_option('mpath').enabled(),
> >>                        static: enable_static)
> >>
> > Hi Bonzini,
> > This looks like a frequently used function, can we upstrem to meson?
>
> Yes, I think adding a "links" argument to dependency (similar to
> find_library's has_headers argument) makes sense.  That would be written
>
>     dependency('libudev',
>                required: get_option('mpath').enabled(),
>                static: enable_static,
>                links: skeleton)
>
For some meson script like this:
curses = not_found
if iconv.found() and not get_option('curses').disabled()
  curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses']
  curses_test = '''
    #include <locale.h>
    #include <curses.h>
    #include <wchar.h>
    int main(void) {
      wchar_t wch = L'w';
      setlocale(LC_ALL, "");
      resize_term(0, 0);
      addwstr(L"wide chars\n");
      addnwstr(&wch, 1);
      add_wch(WACS_DEGREE);
      return 0;
    }'''
  foreach curses_libname : curses_libname_list
      libcurses = dependency(curses_libname,
                             required: false,
                             method: 'pkg-config',
                             static: enable_static)

      if not libcurses.found()
        dirs = ['/usr/include/ncursesw']
        if targetos == 'windows'
          dirs = []
        endif
        libcurses = cc.find_library(curses_libname,
                                    required: false,
                                    dirs: dirs,
                                    static: enable_static)
      endif
      if libcurses.found()
        if cc.links(curses_test, dependencies: [libcurses])
          curses = declare_dependency(compile_args: '-DNCURSES_WIDECHAR', dependencies: [libcurses])
          break
        endif
      endif
  endforeach
endif

We also need to define extra  compile_args  '-DNCURSES_WIDECHAR' as the part of dependencies.

> But anyway that shouldn't be a blocker for more improvements to qemu's
> meson.build.  Now that we have 5-10 dependencies converted we have a
> clearer idea of how to abstract the tests.
>
> Paolo
>


--
         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]