From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
Pallavi Kadam <pallavi.kadam@intel.com>,
Dmitry Malloy <dmitrym@microsoft.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Bruce Richardson <bruce.richardson@intel.com>,
Neil Horman <nhorman@tuxdriver.com>
Subject: [dpdk-dev] [PATCH 3/4] buildtools: support object file extraction for Windows
Date: Sun, 13 Dec 2020 02:34:46 +0300 [thread overview]
Message-ID: <20201212233447.23154-4-dmitry.kozliuk@gmail.com> (raw)
In-Reply-To: <20201212233447.23154-1-dmitry.kozliuk@gmail.com>
clang archiver tool is llvm-ar on Windows and ar on other platforms.
MinGW always uses ar. Replace shell script (Unix-only) that calls ar
with a Python script (OS-independent) that calls an appropriate archiver
tool selected at configuration time. Move the logic not to generate
empty sources into pmdinfogen.
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
Stdin and stdout are not longer used for input and output. Code to
handle that could be removed, but maybe it's useful for someone.
buildtools/gen-pmdinfo-cfile.py | 19 +++++++++++++++++++
buildtools/gen-pmdinfo-cfile.sh | 14 --------------
buildtools/meson.build | 10 ++++++++--
buildtools/pmdinfogen.py | 7 +++++++
4 files changed, 34 insertions(+), 16 deletions(-)
create mode 100644 buildtools/gen-pmdinfo-cfile.py
delete mode 100755 buildtools/gen-pmdinfo-cfile.sh
diff --git a/buildtools/gen-pmdinfo-cfile.py b/buildtools/gen-pmdinfo-cfile.py
new file mode 100644
index 000000000..f1f289ffe
--- /dev/null
+++ b/buildtools/gen-pmdinfo-cfile.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
+
+import os
+import subprocess
+import sys
+import tempfile
+
+_, ar, archive, output, *pmdinfogen = sys.argv
+with tempfile.TemporaryDirectory() as temp:
+ proc = subprocess.run(
+ # Don't use "ar p", because its output is corrupted on Windows.
+ [ar, "xv", os.path.abspath(archive)], capture_output=True, check=True, cwd=temp
+ )
+ lines = proc.stdout.decode().splitlines()
+ names = [line[len("x - ") :] for line in lines]
+ paths = [os.path.join(temp, name) for name in names]
+ subprocess.run(pmdinfogen + paths + [output], check=True)
diff --git a/buildtools/gen-pmdinfo-cfile.sh b/buildtools/gen-pmdinfo-cfile.sh
deleted file mode 100755
index 109ee461e..000000000
--- a/buildtools/gen-pmdinfo-cfile.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /bin/sh
-# SPDX-License-Identifier: BSD-3-Clause
-# Copyright(c) 2017 Intel Corporation
-
-arfile=$1
-output=$2
-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
-done
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 23cefd4be..0a2e91a7b 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -2,7 +2,6 @@
# Copyright(c) 2017-2019 Intel Corporation
pkgconf = find_program('pkg-config', 'pkgconf', required: false)
-pmdinfo = find_program('gen-pmdinfo-cfile.sh')
list_dir_globs = find_program('list-dir-globs.py')
check_symbols = find_program('check-symbols.sh')
ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
@@ -18,11 +17,18 @@ endif
map_to_win_cmd = py3 + files('map_to_win.py')
sphinx_wrapper = py3 + files('call-sphinx-build.py')
-# select object file format
+# select library and object file format
+pmdinfo = py3 + files('gen-pmdinfo-cfile.py')
pmdinfogen = py3 + files('pmdinfogen.py')
if host_machine.system() == 'windows'
+ if cc.get_id() == 'gcc'
+ pmdinfo += 'ar'
+ else
+ pmdinfo += 'llvm-ar'
+ endif
pmdinfogen += 'coff'
else
+ pmdinfo += 'ar'
pmdinfogen += 'elf'
endif
diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py
index 3209510eb..56f5f488c 100755
--- a/buildtools/pmdinfogen.py
+++ b/buildtools/pmdinfogen.py
@@ -230,12 +230,19 @@ def open_output(path):
return open(path, "w")
+def write_header(output):
+ output.write(
+ "static __attribute__((unused)) const char *generator = \"%s\";\n" % sys.argv[0]
+ )
+
+
def main():
args = parse_args()
if args.input.count('-') > 1:
raise Exception("'-' input cannot be used multiple times")
output = open_output(args.output)
+ write_header(output)
for path in args.input:
image = load_image(args.format, path)
drivers = load_drivers(image)
--
2.29.2
next prev parent reply other threads:[~2020-12-12 23:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-12 23:34 [dpdk-dev] [PATCH 0/4] pmdinfogen: support Windows Dmitry Kozlyuk
2020-12-12 23:34 ` [dpdk-dev] [PATCH 1/4] pmdinfogen: support COFF Dmitry Kozlyuk
2020-12-12 23:34 ` [dpdk-dev] [PATCH 2/4] pmdinfogen: allow multiple input files Dmitry Kozlyuk
2020-12-12 23:34 ` Dmitry Kozlyuk [this message]
2020-12-12 23:34 ` [dpdk-dev] [PATCH 4/4] build: enable pmdinfogen for Windows Dmitry Kozlyuk
2021-01-08 2:47 ` [dpdk-dev] [PATCH v2 0/4] pmdinfogen: support Windows Dmitry Kozlyuk
2021-01-08 2:47 ` [dpdk-dev] [PATCH v2 1/4] pmdinfogen: support COFF Dmitry Kozlyuk
2021-01-08 2:47 ` [dpdk-dev] [PATCH v2 2/4] pmdinfogen: allow multiple input files Dmitry Kozlyuk
2021-01-08 2:47 ` [dpdk-dev] [PATCH v2 3/4] buildtools: support object file extraction for Windows Dmitry Kozlyuk
2021-01-25 15:57 ` Thomas Monjalon
2021-01-08 2:47 ` [dpdk-dev] [PATCH v2 4/4] build: enable pmdinfogen " Dmitry Kozlyuk
2021-01-08 18:29 ` Jie Zhou
2021-01-25 15:59 ` [dpdk-dev] [PATCH v2 0/4] pmdinfogen: support Windows Thomas Monjalon
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=20201212233447.23154-4-dmitry.kozliuk@gmail.com \
--to=dmitry.kozliuk@gmail.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dmitrym@microsoft.com \
--cc=navasile@linux.microsoft.com \
--cc=nhorman@tuxdriver.com \
--cc=pallavi.kadam@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.