[dpdk-dev] [PATCH v2 3/4] build: allow hiding dependencies from pkg-config

Thomas Monjalon thomas at monjalon.net
Mon Jan 27 16:44:01 CET 2020


If a dependency is required for a driver build,
but should not be exposed to the application (via pkg-config),
it can be declared in the array hidden_deps.

The hidden_deps are used as internal dependencies,
when building the shared library and the first stage of static library.
The final static library does not include the hidden_deps
because this library object is used to generate the .pc file.

Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 doc/guides/contributing/coding_style.rst | 6 ++++++
 drivers/meson.build                      | 9 ++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 841ef6d5c8..c96457273f 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -975,6 +975,12 @@ deps
 ext_deps
 	As above.
 
+hidden_deps
+	**Default Value = []**.
+	Used to specify external dependencies, same as ``ext_deps``, except
+	the libraries won't be exposed as requirements of the static driver,
+	in the section ``Requires.private`` of the generated ``.pc`` file.
+
 includes
 	**Default Value = <driver directory>** Some drivers include a base
 	directory for additional source files and headers, so we have this
diff --git a/drivers/meson.build b/drivers/meson.build
index 29708cc2bb..759263c309 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -56,6 +56,7 @@ foreach class:dpdk_driver_classes
 		# too, so that it can be reflected in the pkgconfig output for
 		# static builds.
 		ext_deps = []
+		hidden_deps = []
 		pkgconfig_extra_libs = []
 
 		# pull in driver directory which should assign to each of the above
@@ -71,8 +72,9 @@ foreach class:dpdk_driver_classes
 		endforeach
 		if build
 			# get dependency objs from strings
-			shared_deps = ext_deps
-			static_deps = ext_deps
+			shared_deps = ext_deps + hidden_deps
+			static_deps = ext_deps + hidden_deps
+			static_pub_deps = ext_deps
 			foreach d:deps
 				if not is_variable('shared_rte_' + d)
 					build = false
@@ -82,6 +84,7 @@ foreach class:dpdk_driver_classes
 				else
 					shared_deps += [get_variable('shared_rte_' + d)]
 					static_deps += [get_variable('static_rte_' + d)]
+					static_pub_deps += [get_variable('static_rte_' + d)]
 				endif
 			endforeach
 		endif
@@ -144,7 +147,7 @@ foreach class:dpdk_driver_classes
 				sources,
 				objects: objs,
 				include_directories: includes,
-				dependencies: static_deps,
+				dependencies: static_pub_deps, # skip hidden_deps
 				c_args: cflags,
 				install: true)
 
-- 
2.24.1



More information about the dev mailing list