patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Nick Connolly <nick.connolly@mayadata.io>
To: Bruce Richardson <bruce.richardson@intel.com>,
	Ranjit Menon <ranjit.menon@intel.com>,
	Nick Connolly <nick.connolly@mayadata.io>
Cc: dev@dpdk.org, dmitry.kozliuk@gmail.com,
	navasile@linux.microsoft.com, dmitrym@microsoft.com,
	pallavi.kadam@intel.com, stable@dpdk.org
Subject: [dpdk-stable] [PATCH] build: fix symlink of drivers for Windows
Date: Thu,  1 Apr 2021 13:27:23 +0100
Message-ID: <20210401122723.23082-1-nick.connolly@mayadata.io> (raw)

The symlink-drivers-solibs.sh script was disabled as part of 'install'
for Windows because there is no support for shell scripts. However,
this means that driver related DLLs are not present in the installed
'libdir' directory.

Replace the shell script with a python script to perform the symbolic
linking to improve cross platform support. On Linux the functionality
is unchanged.

On Windows, symbolic links are somewhat problematic since the
SeCreateSymbolicLinkPrivilege is required to be able to create them.
In addition, different cross-compilation environments handle symbolic
links differently, e.g. WSL, Msys2, Cygwin. Rather than trying to
distinguish these scenarios, the python script will perform a file copy
for any Windows specific names.

On Windows, the shared library outputs have different names depending
upon which toolset has been used to build them. The script currently
handles Clang and GCC.

Fixes: 5c7d86948764 ("build: fix install on Windows")
Cc: stable@dpdk.org
Signed-off-by: Nick Connolly <nick.connolly@mayadata.io>
---
 buildtools/symlink-drivers-solibs.py | 49 ++++++++++++++++++++++++++++
 buildtools/symlink-drivers-solibs.sh | 13 --------
 config/meson.build                   |  7 ++--
 3 files changed, 51 insertions(+), 18 deletions(-)
 create mode 100644 buildtools/symlink-drivers-solibs.py
 delete mode 100644 buildtools/symlink-drivers-solibs.sh

diff --git a/buildtools/symlink-drivers-solibs.py b/buildtools/symlink-drivers-solibs.py
new file mode 100644
index 000000000..5627ddd9d
--- /dev/null
+++ b/buildtools/symlink-drivers-solibs.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2021 Intel Corporation
+
+import os
+import sys
+import glob
+import shutil
+
+# post-install script for meson/ninja builds to symlink the PMDs stored in
+# $libdir/dpdk/pmds-*/ to $libdir. This is needed as some PMDs depend on
+# others, e.g. PCI device PMDs depending on the PCI bus driver.
+
+# parameters to script are paths relative to install prefix:
+# 1. directory for installed regular libs e.g. lib64
+# 2. subdirectory of libdir where the pmds are
+# 3. directory for installed regular binaries e.g. bin
+
+os.chdir(os.environ['MESON_INSTALL_DESTDIR_PREFIX'])
+
+lib_dir = sys.argv[1]
+pmd_subdir = sys.argv[2]
+bin_dir = sys.argv[3]
+pmd_dir = os.path.join(lib_dir, pmd_subdir)
+
+# copy Windows PMDs to avoid any issues with symlinks since the
+# build could be a cross-compilation under WSL, Msys or Cygnus.
+# the filenames are dependent upon the specific toolchain in use.
+
+def copy_pmd_files(pattern, to_dir):
+	for file in glob.glob(os.path.join(pmd_dir, pattern)):
+		to = os.path.join(to_dir, os.path.basename(file))
+		shutil.copy2(file, to)
+		print(to + ' -> ' + file)
+
+copy_pmd_files('*rte_*.dll', bin_dir)
+copy_pmd_files('*rte_*.pdb', bin_dir)
+copy_pmd_files('*rte_*.lib', lib_dir)
+copy_pmd_files('*rte_*.dll.a', lib_dir)
+
+# symlink shared objects
+
+os.chdir(lib_dir)
+for file in glob.glob(os.path.join(pmd_subdir, 'librte_*.so*')):
+	to = os.path.basename(file)
+	if os.path.exists(to):
+		os.remove(to)
+	os.symlink(file, to)
+	print(to + ' -> ' + file)
diff --git a/buildtools/symlink-drivers-solibs.sh b/buildtools/symlink-drivers-solibs.sh
deleted file mode 100644
index 42985e855..000000000
--- a/buildtools/symlink-drivers-solibs.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/sh
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2017 Intel Corporation
-
-# post-install script for meson/ninja builds to symlink the PMDs stored in
-# $libdir/dpdk/drivers/ to $libdir. This is needed as some PMDs depend on
-# others, e.g. PCI device PMDs depending on the PCI bus driver.
-
-# parameters to script are paths relative to install prefix:
-# 1. directory for installed regular libs e.g. lib64
-# 2. subdirectory of libdir where the pmds are
-
-cd ${MESON_INSTALL_DESTDIR_PREFIX}/$1 && ln -sfv $2/librte_*.so* .
diff --git a/config/meson.build b/config/meson.build
index 66a2edcc4..c51669b7d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -57,11 +57,8 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path)
 # driver .so files often depend upon the bus drivers for their connect bus,
 # e.g. ixgbe depends on librte_bus_pci. This means that the bus drivers need
 # to be in the library path, so symlink the drivers from the main lib directory.
-if not is_windows
-	meson.add_install_script('../buildtools/symlink-drivers-solibs.sh',
-			get_option('libdir'),
-			pmd_subdir_opt)
-endif
+meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py',
+	get_option('libdir'), pmd_subdir_opt, get_option('bindir'))
 
 # set the machine type and cflags for it
 if meson.is_cross_build()
-- 
2.25.1


             reply	other threads:[~2021-04-01 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01 12:27 Nick Connolly [this message]
2021-04-04  0:00 ` Dmitry Kozlyuk
2021-04-06 10:24   ` Nick Connolly
2021-04-10  8:01 ` [dpdk-stable] [PATCH v2] " Nick Connolly
2021-04-24  0:53   ` Narcisa Ana Maria Vasile
2021-04-26 10:07 ` [dpdk-stable] [PATCH v3] " Nick Connolly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210401122723.23082-1-nick.connolly@mayadata.io \
    --to=nick.connolly@mayadata.io \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dmitrym@microsoft.com \
    --cc=navasile@linux.microsoft.com \
    --cc=pallavi.kadam@intel.com \
    --cc=ranjit.menon@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git