numam-dpdk/buildtools/gen-pmdinfo-cfile.py
Dmitry Kozlyuk e6e9730c70 buildtools: support object file extraction for Windows
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>
2021-01-25 23:23:50 +01:00

20 lines
684 B
Python

#!/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)