[2/3] common/mlx5: get Windows dependency from standard variables

Message ID 20230105161020.247780-3-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix mlx5 build with MinGW |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Jan. 5, 2023, 4:10 p.m. UTC
  It was requested to provide path to DevX library through
DEVX_INC_PATH and DEVX_LIB_PATH.
It was non-standard and triggers some issues with recent Meson.

Using CFLAGS/LDFLAGS is standard and simpler.
It is also possible to use the Meson options -Dc_args and -Dc_link_args.
There are 2 options to provide:
	-I<include_directory>
	-L<library_directory>

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 doc/guides/platform/mlx5.rst            | 12 ++++++-----
 drivers/common/mlx5/windows/meson.build | 28 ++++++++++++-------------
 2 files changed, 21 insertions(+), 19 deletions(-)
  

Patch

diff --git a/doc/guides/platform/mlx5.rst b/doc/guides/platform/mlx5.rst
index 5784b9a87b..33eb8627b5 100644
--- a/doc/guides/platform/mlx5.rst
+++ b/doc/guides/platform/mlx5.rst
@@ -259,13 +259,15 @@  configured by the ``ibverbs_link`` build option:
 Compilation on Windows
 ~~~~~~~~~~~~~~~~~~~~~~
 
-The DevX SDK location must be set through two environment variables:
+The DevX SDK location must be set through CFLAGS/LDFLAGS,
+either::
 
-``DEVX_LIB_PATH``
-   path to the DevX lib file.
+   meson -Dc_args=-Idevx/inc -Dc_link_args=-Ldevx/lib
 
-``DEVX_INC_PATH``
-   path to the DevX header files.
+or::
+
+   export CFLAGS=-Idevx/inc
+   export LDFLAGS=-Ldevx/lib
 
 
 .. _mlx5_common_env:
diff --git a/drivers/common/mlx5/windows/meson.build b/drivers/common/mlx5/windows/meson.build
index cc486014a8..f60daed840 100644
--- a/drivers/common/mlx5/windows/meson.build
+++ b/drivers/common/mlx5/windows/meson.build
@@ -1,6 +1,20 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright 2019 Mellanox Technologies, Ltd
 
+if not cc.has_header('mlx5devx.h')
+    build = false
+    reason = 'missing dependency, "mlx5devx.h"'
+    subdir_done()
+endif
+
+devxlib = cc.find_library('mlx5devx', required: true)
+if not devxlib.found()
+    build = false
+    reason = 'missing dependency, "mlx5devx"'
+    subdir_done()
+endif
+ext_deps += devxlib
+
 includes += include_directories('.')
 
 sources += files(
@@ -8,20 +22,6 @@  sources += files(
         'mlx5_common_os.c',
 )
 
-res_lib = run_command(python3, '-c', 'import os; print(os.environ["DEVX_LIB_PATH"])', check: false)
-res_inc = run_command(python3, '-c', 'import os; print(os.environ["DEVX_INC_PATH"])', check: false)
-
-if (res_lib.returncode() != 0 or res_inc.returncode() != 0)
-    build = false
-    reason = 'DevX environment variables are not set, DEVX_LIB_PATH and DEVX_INC_PATH vars must be exported'
-    subdir_done()
-endif
-
-devx_lib_dir = res_lib.stdout().strip()
-devx_inc_dir = res_inc.stdout().strip()
-
-ext_deps += cc.find_library('mlx5devx', dirs: devx_lib_dir, required: true)
-includes += include_directories(devx_inc_dir)
 cflags_options = [
         '-std=c11',
         '-Wno-strict-prototypes',