Hi On Tue, Jul 20, 2021 at 4:12 PM Jag Raman <jag.ra...@oracle.com> wrote:
> > > > On Jul 19, 2021, at 4:24 PM, John Levon <john.le...@nutanix.com> wrote: > > > > On Mon, Jul 19, 2021 at 04:00:03PM -0400, Jagannathan Raman wrote: > > > >> add the libvfio-user library as a submodule. build it as part of QEMU > >> > >> diff --git a/meson.build b/meson.build > >> index 6e4d2d8..f2f9f86 100644 > >> --- a/meson.build > >> +++ b/meson.build > >> @@ -1894,6 +1894,41 @@ if get_option('cfi') and slirp_opt == 'system' > >> + ' Please configure with --enable-slirp=git') > >> endif > >> > >> +vfiouser = not_found > >> +if have_system and multiprocess_allowed > >> + have_internal = fs.exists(meson.current_source_dir() / > 'libvfio-user/Makefile') > >> + > >> + if not have_internal > >> + error('libvfio-user source not found - please pull git submodule') > >> + endif > >> + > >> + vfiouser_files = [ > >> + 'libvfio-user/lib/dma.c', > >> + 'libvfio-user/lib/irq.c', > >> + 'libvfio-user/lib/libvfio-user.c', > >> + 'libvfio-user/lib/migration.c', > >> + 'libvfio-user/lib/pci.c', > >> + 'libvfio-user/lib/pci_caps.c', > >> + 'libvfio-user/lib/tran_sock.c', > >> + ] > >> + > >> + vfiouser_inc = include_directories('libvfio-user/include', > 'libvfio-user/lib') > >> + > >> + json_c = dependency('json-c', required: false) > >> + if not json_c.found() > >> + json_c = dependency('libjson-c') > >> + endif > >> + > >> + libvfiouser = static_library('vfiouser', > >> + build_by_default: false, > >> + sources: vfiouser_files, > >> + dependencies: json_c, > >> + include_directories: vfiouser_inc) > >> + > >> + vfiouser = declare_dependency(link_with: libvfiouser, > >> + include_directories: vfiouser_inc) > >> +endif > > > > Why this way, rather than recursing into the submodule? Seems a bit > fragile to > > encode details of the library here. > > +maintainers of meson.build. I apologize for not adding them when I sent > the > patches out initially. I copied the email list from Elena, but Elena did > not make > any changes to meson.build - stupid me. > > John, > > This way appears to be present convention with QEMU - I’m also not > very clear > on the reason for it. > > For example submodules such as slirp (libslirp), capstone (libcapstone), > dtc (libfdt) are built this way. > For slirp and dtc, we are eventually going to use meson subproject(). No idea about capstone. > > I’m guessing it’s because QEMU doesn’t build all parts of a submodule. For > example, QEMU only builds libfdt in the doc submodule. Similarly, > libvfio-user only builds the core library without building the tests and > samples. > > You can give subproject options to build limited parts. Fwiw, since libvfio-user uses cmake, we may be able to use meson cmake.subproject() (https://mesonbuild.com/CMake-module.html). -- Marc-André Lureau