buildtools: fix archive extraction for LLVM 8

"llvm-ar xv lib.a" from LLVM 8 doesn't print extracted object file
names. The effect of "v" is not formally specified either.
Use "llvm-ar t" to get archive member names.

Reported-by: Xueming Zhang <xuemingx.zhang@intel.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
This commit is contained in:
Dmitry Kozlyuk 2021-01-28 22:05:15 +03:00 committed by Thomas Monjalon
parent 5c38c33f78
commit c85ebb39db

View File

@ -9,11 +9,12 @@
_, tmp_root, ar, archive, output, *pmdinfogen = sys.argv _, tmp_root, ar, archive, output, *pmdinfogen = sys.argv
with tempfile.TemporaryDirectory(dir=tmp_root) as temp: with tempfile.TemporaryDirectory(dir=tmp_root) as temp:
proc = subprocess.run( run_ar = lambda command: subprocess.run(
# Don't use "ar p", because its output is corrupted on Windows. [ar, command, os.path.abspath(archive)],
[ar, "xv", os.path.abspath(archive)], stdout=subprocess.PIPE, check=True, cwd=temp stdout=subprocess.PIPE, check=True, cwd=temp
) )
lines = proc.stdout.decode().splitlines() # Don't use "ar p", because its output is corrupted on Windows.
names = [line[len("x - ") :] for line in lines] run_ar("x")
names = run_ar("t").stdout.decode().splitlines()
paths = [os.path.join(temp, name) for name in names] paths = [os.path.join(temp, name) for name in names]
subprocess.run(pmdinfogen + paths + [output], check=True) subprocess.run(pmdinfogen + paths + [output], check=True)