xref: /dpdk/buildtools/gen-pmdinfo-cfile.py (revision c78471cd061a0f64db006c538be34536bc66c12a)
1#!/usr/bin/env python3
2# SPDX-License-Identifier: BSD-3-Clause
3# Copyright (c) 2020 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
4
5import os
6import subprocess
7import sys
8import tempfile
9
10_, tmp_root, ar, archive, output, *pmdinfogen = sys.argv
11with tempfile.TemporaryDirectory(dir=tmp_root) as temp:
12    paths = []
13    for name in subprocess.run([ar, "t", archive], stdout=subprocess.PIPE,
14                               check=True).stdout.decode().splitlines():
15        if os.path.exists(name):
16            paths.append(name)
17        else:
18            subprocess.run([ar, "x", os.path.abspath(archive), name],
19                           check=True, cwd=temp)
20            paths.append(os.path.join(temp, name))
21    subprocess.run(pmdinfogen + paths + [output], check=True)
22