From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: Andre Muezerie <andremue@linux.microsoft.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Subject: [PATCH v7 4/5] buildtools: embed driver information with MSVC
Date: Wed, 11 Jun 2025 11:45:31 +0200 [thread overview]
Message-ID: <20250611094532.1242167-5-david.marchand@redhat.com> (raw)
In-Reply-To: <20250611094532.1242167-1-david.marchand@redhat.com>
From: Andre Muezerie <andremue@linux.microsoft.com>
The archiver tool from the MSVC toolset is lib.exe. It has different
parameters then it's GNU counterpart "ar".
buildtools\meson.build was updated to use lib.exe when MSVC compiler is
used. This is to allow the code to be built without requiring GNU "ar"
to be installed in that scenario.
Script gen-pmdinfo-cfile.py was updated to use the correct parameters
when using lib.exe.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
buildtools/gen-pmdinfo-cfile.py | 25 ++++++++++++++++++++-----
buildtools/meson.build | 2 ++
buildtools/pmdinfogen.py | 11 ++++++-----
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/buildtools/gen-pmdinfo-cfile.py b/buildtools/gen-pmdinfo-cfile.py
index 8ffc192c40..5d2e8e076e 100644
--- a/buildtools/gen-pmdinfo-cfile.py
+++ b/buildtools/gen-pmdinfo-cfile.py
@@ -6,16 +6,31 @@
import subprocess
import sys
-_, ar, tmp_dir, archive, output, *pmdinfogen = sys.argv
+_, archiver, tmp_dir, archive, output, *pmdinfogen = sys.argv
paths = []
-for name in subprocess.run([ar, "t", archive], stdout=subprocess.PIPE,
- check=True).stdout.decode().splitlines():
+if archiver == "lib":
+ archiver_options = ["/LIST", "/NOLOGO"]
+else:
+ archiver_options = ["t"]
+
+for name in (
+ subprocess.run(
+ [archiver] + archiver_options + [archive],
+ stdout=subprocess.PIPE,
+ check=True,
+ )
+ .stdout.decode()
+ .splitlines()
+):
if os.path.exists(name):
paths.append(name)
else:
if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir)
- subprocess.run([ar, "x", os.path.abspath(archive), name],
- check=True, cwd=tmp_dir)
+ if archiver == "lib":
+ run_args = [archiver, f"/EXTRACT:{name}", os.path.abspath(archive)]
+ else:
+ run_args = [archiver, "x", os.path.abspath(archive), name]
+ subprocess.run(run_args, check=True, cwd=tmp_dir)
paths.append(os.path.join(tmp_dir, name))
subprocess.run(pmdinfogen + paths + [output], check=True)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 822e79502a..7b5e449cdb 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -44,6 +44,8 @@ pmdinfogen = py3 + files('pmdinfogen.py')
if host_machine.system() == 'windows'
if cc.get_id() == 'gcc'
pmdinfo += 'ar'
+ elif cc.get_id() == 'msvc'
+ pmdinfo += 'lib'
else
pmdinfo += 'llvm-ar'
endif
diff --git a/buildtools/pmdinfogen.py b/buildtools/pmdinfogen.py
index 7be2e39dd2..63e0a8b364 100755
--- a/buildtools/pmdinfogen.py
+++ b/buildtools/pmdinfogen.py
@@ -87,7 +87,7 @@ def get_value(self, offset, size):
@property
def string_value(self):
value = self._symbol.get_value(0)
- return coff.decode_asciiz(value) if value else ''
+ return coff.decode_asciiz(value) if value else ""
class COFFImage:
@@ -192,7 +192,7 @@ def dump(self, file):
dumped = json.dumps(self.__dict__)
escaped = dumped.replace('"', '\\"')
print(
- 'const char %s_pmd_info[] __attribute__((used)) = "PMD_INFO_STRING= %s";'
+ 'RTE_PMD_EXPORT_SYMBOL(const char, %s_pmd_info)[] = "PMD_INFO_STRING= %s";'
% (self.name, escaped),
file=file,
)
@@ -215,7 +215,7 @@ def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("format", help="object file format, 'elf' or 'coff'")
parser.add_argument(
- "input", nargs='+', help="input object file path or '-' for stdin"
+ "input", nargs="+", help="input object file path or '-' for stdin"
)
parser.add_argument("output", help="output C file path or '-' for stdout")
return parser.parse_args()
@@ -252,13 +252,14 @@ def open_output(path):
def write_header(output):
output.write(
- "static __attribute__((unused)) const char *generator = \"%s\";\n" % sys.argv[0]
+ "#include <dev_driver.h>\n"
+ 'static __rte_unused const char *generator = "%s";\n' % sys.argv[0]
)
def main():
args = parse_args()
- if args.input.count('-') > 1:
+ if args.input.count("-") > 1:
raise Exception("'-' input cannot be used multiple times")
if args.format == "elf" and "ELFFile" not in globals():
raise Exception("elftools module not found")
--
2.49.0
next prev parent reply other threads:[~2025-06-11 9:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 10:09 [PATCH v6 0/4] allow pmdinfo to be inserted and parsed using MSVC David Marchand
2025-06-10 10:09 ` [PATCH v6 1/4] dev: hide driver export macros David Marchand
2025-06-10 10:09 ` [PATCH v6 2/4] dev: export driver information with MSVC David Marchand
2025-06-10 12:13 ` David Marchand
2025-06-10 10:09 ` [PATCH v6 3/4] buildtools: embed " David Marchand
2025-06-10 10:09 ` [PATCH v6 4/4] usertools: enable pmdinfo " David Marchand
2025-06-10 10:17 ` Robin Jarry
2025-06-11 9:45 ` [PATCH v7 0/5] allow pmdinfo to be inserted and parsed using MSVC David Marchand
2025-06-11 9:45 ` [PATCH v7 1/5] dev: hide driver export macros David Marchand
2025-06-11 13:24 ` Andre Muezerie
2025-06-11 9:45 ` [PATCH v7 2/5] dev: rename pmdinfo internal symbols David Marchand
2025-06-11 13:26 ` Andre Muezerie
2025-06-11 9:45 ` [PATCH v7 3/5] dev: export driver information with MSVC David Marchand
2025-06-11 13:27 ` Andre Muezerie
2025-06-11 9:45 ` David Marchand [this message]
2025-06-11 13:28 ` [PATCH v7 4/5] buildtools: embed " Andre Muezerie
2025-06-11 9:45 ` [PATCH v7 5/5] usertools: enable pmdinfo " David Marchand
2025-06-12 13:23 ` [PATCH v7 0/5] allow pmdinfo to be inserted and parsed using MSVC David Marchand
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=20250611094532.1242167-5-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=andremue@linux.microsoft.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).