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

Message ID 20250407152509.2203243-2-bruce.richardson@intel.com (mailing list archive)
State New
Delegated to: David Marchand
Headers
Series centralize base code handling for drivers |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation warning apply patch failure

Commit Message

Bruce Richardson April 7, 2025, 3:25 p.m. UTC
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@intel.com>
---
 drivers/meson.build | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Patch

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])