From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C3453A04DB;
	Wed, 14 Oct 2020 20:32:34 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 284131BF99;
	Wed, 14 Oct 2020 20:31:57 +0200 (CEST)
Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com
 [209.85.208.178]) by dpdk.org (Postfix) with ESMTP id 030141DB18;
 Wed, 14 Oct 2020 20:31:47 +0200 (CEST)
Received: by mail-lj1-f178.google.com with SMTP id c21so433456ljn.13;
 Wed, 14 Oct 2020 11:31:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=ckUUpp/68YWeTyJx5dyVIlt3VIXvd8FgnKyroCqZu8E=;
 b=H0AbZvhJzvwnoPHg6radrSTuIPR8iaH0lhwrjxO7OXm9iY1WUGWkZvhfrCBdihqxdq
 tCigK1xnPkPcAWdMUo56MX2Nx+AWsKvN28JXh5HDc1pQXK0CxF6tsxwiCWWp23s4JmnL
 MxCO2Rjr0m0q5QRJcLeAb1NdtsXYX9c4kFkcMHLyAaFSzMFtulwhAjyFw6lMz0Jj8v8w
 JHuOem01dm59lGJvztxR/xwmTVfWJADwi3qSgrAxiqqUkn9yUeUrJiYr0K1IARgOZ8ut
 gHCbO9pyNAivGtA92qxyhFaqdMfqx//YP3rEgaMBIxR5atOv3HNwqpJeqRNReY35X882
 VTXA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=ckUUpp/68YWeTyJx5dyVIlt3VIXvd8FgnKyroCqZu8E=;
 b=flOQm2u4exDlxKGoMqCdnzgZzZW4QX7Lk4umxMu9FBIhiHFlnn+c5ZB14moEozJwpj
 YuSVh37beUEaGltWGb7FLXoddbEWEFPUvVMwW5VAF2JK94nnwJqsTeMibxY10w6xxaDm
 G07m+TxYznpEmPex31zOAEZtGmoZ3qQh34PfWirjg0SZHphDD5vD9JRlyR2OPM4uRe+o
 ws4Q3x3Nh7jP61z3MdavLhKvUZKiyElMB4UsG3WKrV7s8GXjCyb1qpz3tvsZMgTf/bG8
 DacbBkJLM9uRmL+nLiZ3ybgXIp53imDwBkL8diD9sPXR0i1JUdDRXoBKKY92573QWiA8
 THbw==
X-Gm-Message-State: AOAM530J3qNmIcJIGp99bNhPQBXqFJDRhj0Rm67LsUYOAJEK5f9yeBp+
 UYJEudJRpdjCDOLqDJxRj6m+tYHeHheG2Q==
X-Google-Smtp-Source: ABdhPJwtYjSFuS5q6n254khQEvHqJSGO6/DEzPhhuzIBWjv9z/2QSOK63DGS0D3QazaUjkn3luZkOg==
X-Received: by 2002:a2e:a54c:: with SMTP id e12mr14476ljn.164.1602700306279;
 Wed, 14 Oct 2020 11:31:46 -0700 (PDT)
Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru.
 [37.110.65.23])
 by smtp.gmail.com with ESMTPSA id d21sm32942lfl.62.2020.10.14.11.31.45
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 14 Oct 2020 11:31:45 -0700 (PDT)
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: ci@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>,
 David Marchand <david.marchand@redhat.com>,
 Thomas Monjalon <thomas@monjalon.net>,
 Maxime Coquelin <maxime.coquelin@redhat.com>,
 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
 Aaron Conole <aconole@redhat.com>,
 Michael Santana <maicolgabriel@hotmail.com>,
 Bruce Richardson <bruce.richardson@intel.com>
Date: Wed, 14 Oct 2020 21:31:35 +0300
Message-Id: <20201014183136.22239-3-dmitry.kozliuk@gmail.com>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201014183136.22239-1-dmitry.kozliuk@gmail.com>
References: <20201004015947.9012-1-dmitry.kozliuk@gmail.com>
 <20201014183136.22239-1-dmitry.kozliuk@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v7 2/3] build: use Python pmdinfogen
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Use the same interpreter to run pmdinfogen as for other build scripts.
Adjust wrapper script accordingly and also don't suppress stderr from ar
and pmdinfogen.

Add configure-time check for elftools Python module.

Add python3-pyelftools to CI configuration. The package is available on
all major distributions. FreeBSD has no system requirements section in
its GSG. Currently neither Windows uses pmdinfogen, nor is COFF (PE)
supported.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
 .travis.yml                       |  2 +-
 buildtools/gen-pmdinfo-cfile.sh   |  6 +++---
 buildtools/meson.build            | 15 +++++++++++++++
 doc/guides/linux_gsg/sys_reqs.rst |  6 ++++++
 drivers/meson.build               |  2 +-
 meson.build                       |  1 -
 6 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5e12db23b..6744f6fc1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ addons:
   apt:
     update: true
     packages: &required_packages
-      - [libnuma-dev, python3-setuptools, python3-wheel, python3-pip, ninja-build]
+      - [libnuma-dev, python3-setuptools, python3-wheel, python3-pip, python3-pyelftools, ninja-build]
       - [libbsd-dev, libpcap-dev, libibverbs-dev, libcrypto++-dev, libfdt-dev, libjansson-dev]
 
 _aarch64_packages: &aarch64_packages
diff --git a/buildtools/gen-pmdinfo-cfile.sh b/buildtools/gen-pmdinfo-cfile.sh
index 43059cf36..109ee461e 100755
--- a/buildtools/gen-pmdinfo-cfile.sh
+++ b/buildtools/gen-pmdinfo-cfile.sh
@@ -4,11 +4,11 @@
 
 arfile=$1
 output=$2
-pmdinfogen=$3
+shift 2
+pmdinfogen=$*
 
 # The generated file must not be empty if compiled in pedantic mode
 echo 'static __attribute__((unused)) const char *generator = "'$0'";' > $output
 for ofile in `ar t $arfile` ; do
-	ar p $arfile $ofile | $pmdinfogen - - >> $output 2> /dev/null
+	ar p $arfile $ofile | $pmdinfogen - - >> $output
 done
-exit 0
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 04808dabc..0c668eb46 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -17,3 +17,18 @@ else
 endif
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+pmdinfogen = py3 + files('pmdinfogen.py')
+
+# TODO: starting from Meson 0.51.0 use
+# 	python3 = import('python').find_installation('python',
+#		modules : python3_required_modules)
+python3_required_modules = ['elftools']
+foreach module : python3_required_modules
+	script = \
+		'import importlib.util;' + \
+		'import sys;' + \
+		'exit(importlib.util.find_spec("@0@") is None)'.format(module)
+	if run_command(py3, '-c', script).returncode() != 0
+		error('missing python module: @0@'.format(module))
+	endif
+endforeach
diff --git a/doc/guides/linux_gsg/sys_reqs.rst b/doc/guides/linux_gsg/sys_reqs.rst
index 6ecdc04aa..89c9f2570 100644
--- a/doc/guides/linux_gsg/sys_reqs.rst
+++ b/doc/guides/linux_gsg/sys_reqs.rst
@@ -52,6 +52,12 @@ Compilation of the DPDK
     * If the packaged version is below the minimum version, the latest versions
       can be installed from Python's "pip" repository: ``pip3 install meson ninja``
 
+*   ``pyelftools`` (version 0.22+)
+
+    * For RHEL/Fedora systems it can be installed using ``dnf install python-pyelftools``
+
+    * For Ubuntu/Debian it can be installed using ``apt install python3-pyelftools``
+
 *   Library for handling NUMA (Non Uniform Memory Access).
 
     * ``numactl-devel`` in RHEL/Fedora;
diff --git a/drivers/meson.build b/drivers/meson.build
index 5f9526557..88364259d 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -137,7 +137,7 @@ foreach subpath:subdirs
 						command: [pmdinfo, tmp_lib.full_path(),
 							'@OUTPUT@', pmdinfogen],
 						output: out_filename,
-						depends: [pmdinfogen, tmp_lib])
+						depends: [tmp_lib])
 			endif
 
 			# now build the static driver
diff --git a/meson.build b/meson.build
index 61d9a4f5f..a6e8c09c2 100644
--- a/meson.build
+++ b/meson.build
@@ -45,7 +45,6 @@ subdir('buildtools')
 subdir('config')
 
 # build libs and drivers
-subdir('buildtools/pmdinfogen')
 subdir('lib')
 subdir('drivers')
 
-- 
2.28.0