diff --git a/MAINTAINERS b/MAINTAINERS index d5a6cee20b..a7eadba130 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -105,6 +105,7 @@ F: buildtools/call-sphinx-build.py F: buildtools/list-dir-globs.py F: buildtools/pkg-config/ F: buildtools/symlink-drivers-solibs.sh +F: buildtools/symlink-drivers-solibs.py F: devtools/test-meson-builds.sh F: devtools/check-meson.py diff --git a/buildtools/symlink-drivers-solibs.py b/buildtools/symlink-drivers-solibs.py new file mode 100644 index 0000000000..9c999508a9 --- /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/config/meson.build b/config/meson.build index 9f56fab1fe..e80421003b 100644 --- a/config/meson.build +++ b/config/meson.build @@ -59,6 +59,10 @@ eal_pmd_path = join_paths(get_option('prefix'), driver_install_path) if not is_windows meson.add_install_script('../buildtools/symlink-drivers-solibs.sh', get_option('libdir'), pmd_subdir_opt) +elif meson.version().version_compare('>=0.55.0') + # 0.55.0 is required to use external program with add_install_script + meson.add_install_script(py3, '../buildtools/symlink-drivers-solibs.py', + get_option('libdir'), pmd_subdir_opt, get_option('bindir')) endif # init disable/enable driver lists that will be populated in different places