]> git.droids-corp.org - dpdk.git/commitdiff
build: add definitions for use as Meson subproject
authorBruce Richardson <bruce.richardson@intel.com>
Fri, 6 May 2022 14:43:18 +0000 (15:43 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 7 Jun 2022 18:49:20 +0000 (20:49 +0200)
To allow other projects to easily use DPDK as a subproject, add in the
necessary dependency definitions. Slightly different definitions are
necessary for static and shared builds, since for shared builds the
drivers should not be linked in, and the internal meson dependency
objects are more complete.

To use DPDK as a subproject fallback i.e. use installed DPDK if present,
otherwise the shipped one, the following meson statement can be used:

libdpdk = dependency('libdpdk', fallback: ['dpdk', 'dpdk_dep'])

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Ben Magistro <koncept1@gmail.com>
Tested-by: Ben Magistro <koncept1@gmail.com>
buildtools/subproject/meson.build [new file with mode: 0644]
drivers/meson.build
lib/meson.build
meson.build

diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build
new file mode 100644 (file)
index 0000000..3192efa
--- /dev/null
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+message('DPDK subproject linking: ' + get_option('default_library'))
+if get_option('default_library') == 'static'
+    dpdk_dep = declare_dependency(
+            version: meson.project_version(),
+            dependencies: dpdk_static_lib_deps,
+            # static library deps in DPDK build don't include "link_with" parameters,
+            # so explicitly link-in both libs and drivers
+            link_with: dpdk_static_libraries,
+            link_whole: dpdk_drivers,
+            link_args: dpdk_extra_ldflags)
+else
+    dpdk_dep = declare_dependency(
+            version: meson.project_version(),
+            # shared library deps include all necessary linking parameters
+            dependencies: dpdk_shared_lib_deps)
+endif
+
+libdpdk_dep = dpdk_dep
index 4daa2658b76362ddddc7e71ef8a7cc38d204b394..b22c2adda76202b814fe54c9bd59ade71ce257d2 100644 (file)
@@ -246,6 +246,10 @@ foreach subpath:subdirs
 
         set_variable('shared_@0@'.format(lib_name), shared_dep)
         set_variable('static_@0@'.format(lib_name), static_dep)
+        # for drivers, we only need to add dependency objects for static libs,
+        # shared lib drivers are not linked in
+        dpdk_static_lib_deps += static_dep
+
         dependency_name = ''.join(lib_name.split('rte_'))
         if testpmd_sources.length() != 0
             testpmd_drivers_sources += testpmd_sources
index 24adbe44c9a6c740062daefedc3410e203899d07..c648f7d800e6bceafdd3a7ae146c1ee9339a1b4a 100644 (file)
@@ -266,6 +266,8 @@ foreach l:libraries
 
     set_variable('shared_rte_' + name, shared_dep)
     set_variable('static_rte_' + name, static_dep)
+    dpdk_shared_lib_deps += shared_dep
+    dpdk_static_lib_deps += static_dep
     if developer_mode
         message('lib/@0@: Defining dependency "@1@"'.format(l, name))
     endif
index 5561171617ab533e040c02b2e10ce0fb0d5cae52..987c2f4999abcbc5721bd201f4a2bc6a9d8a7f81 100644 (file)
@@ -36,6 +36,8 @@ dpdk_build_root = meson.current_build_dir()
 dpdk_conf = configuration_data()
 dpdk_libraries = []
 dpdk_static_libraries = []
+dpdk_shared_lib_deps = []
+dpdk_static_lib_deps = []
 dpdk_chkinc_headers = []
 dpdk_driver_classes = []
 dpdk_drivers = []
@@ -105,6 +107,10 @@ configure_file(output: build_cfg,
 # build pkg-config files for dpdk
 subdir('buildtools/pkg-config')
 
+if meson.is_subproject()
+    subdir('buildtools/subproject')
+endif
+
 # final output, list all the libs and drivers to be built
 # this does not affect any part of the build, for information only.
 output_message = '\n=================\nLibraries Enabled\n=================\n'