[PATCH v2 01/10] build: add generic support for base code in drivers

Bruce Richardson bruce.richardson at intel.com
Mon Apr 7 17:25:00 CEST 2025


Add support to the drivers meson.build file for base code files with
extra cflags for compilation. This should remove the need for custom
logic in each driver.

In future, we may want to move the base code handling down the file a
little in order to get lock checking. However, this lock checking is not
done currently on base code builds, so not all drivers can safely pass
these checks. Therefore, we handle the base code files before we add on
the extra lock annotation flags.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
---
 drivers/meson.build | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/meson.build b/drivers/meson.build
index c15319dc24..b2d2537dc8 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -145,7 +145,13 @@ foreach subpath:subdirs
         pkgconfig_extra_libs = []
         testpmd_sources = []
         require_iova_in_mbuf = true
+        # for handling base code files which may need extra cflags
+        base_sources = []
+        base_cflags = []
 
+        if fs.is_dir(drv_path / 'base')
+            includes += include_directories(drv_path / 'base')
+        endif
         if name.contains('/')
             name = name.split('/')[1]
         endif
@@ -216,6 +222,20 @@ foreach subpath:subdirs
             continue
         endif
 
+        # not all drivers base code is lock annotation safe, so do base code builds before
+        # adding on the lock annotation flags. NOTE: If no custom cflags, the lock annotation
+        # checks will be done though.
+        if base_cflags != []
+            base_lib = static_library(lib_name + '_base_lib',
+                    base_sources,
+                    dependencies: static_deps,
+                    include_directories: includes,
+                    c_args: cflags + base_cflags)
+            objs += base_lib.extract_objects(base_sources)
+        else
+            sources += base_sources
+        endif
+
         enabled_drivers += name
         lib_name = '_'.join(['rte', class, name])
         cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=' + '.'.join([log_prefix, name])
-- 
2.45.2



More information about the dev mailing list