From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3921BA0524; Fri, 8 Jan 2021 03:47:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B893140DE5; Fri, 8 Jan 2021 03:47:39 +0100 (CET) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mails.dpdk.org (Postfix) with ESMTP id AE000140DD8 for ; Fri, 8 Jan 2021 03:47:37 +0100 (CET) Received: by mail-lf1-f44.google.com with SMTP id o13so19600609lfr.3 for ; Thu, 07 Jan 2021 18:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yu3Ev+EXmzylcsL2AC1AfozvTyvbRWbK8+Qown2cmgs=; b=uopUUA0JbAv0MnOnJrOI2ji0p/y0yIweZEf0lZVuxxGbUKiIr2uI5yv5HJaOqVKHcC UiYBDnsQe1qpSAv2aikO0R2vi8AKtVeDH2fYY8ggyeSiG0ExWpDwPegSoQnzvXASHCOI am0Ja33Qa6E7HCfFUGcbSq1LZfliakiUm/CjI73t9On5FH3+kKLy+mN8ac4CGDlumMCz Wjmb34yq3awYQsGh4eO4BnnT1OsGhJ9WoplgEj4cSemuvwGWiqkNepvNz2P3+i8tFGIU dIXfNtCaYkljT9q6rRO3DJP7xVtApVTcrt7d9PniXLbGumdQJTpRPq+3WDIeo9kCnoMW Cb2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yu3Ev+EXmzylcsL2AC1AfozvTyvbRWbK8+Qown2cmgs=; b=Oxzh6+4cT5FANcEUI7Zdw7kooviubfevdHgFwKmLuvFPHVWx8+An4qhqasRA1dw5Q8 DroZOueF53++uWvE8nOxp+gKbjPAysjx41xncJ5QvRRZJ7sBVh+sRTdm/a/09B9+r+w7 qtktC9PhCxCrlG01WiRfuEXxy6GcK2SQG60WFQdEYW8U58fwx7mlxbn3vQeICALSnauH DZlLlOJCFdZ1SHHrYS0Vjmny/gfjVf5gIKa23WMWGDOBLAV+fO3XFcMZKtwhqmxkH7pT bQg6ObWVOvrY2mZe8/GnRn+FQmHnuZyU+XIQ8Gcvc7ULO5qjyFZgQU1+XQ2swDa3EwrA pqeA== X-Gm-Message-State: AOAM530TJCKunpr26CRiQJgCis4FgPyXHZfejW3XMl0X6KGRGuIRP+y0 bYQ4IEd1MLGYqTNslubHyKZreMcGZNfee6mT X-Google-Smtp-Source: ABdhPJxxg/TxztkWI5w688vOVhASExZfYhFODeJbW+Vh1hNqbZtPAADF+pwMAXeuKYAnxKcRDk1jWg== X-Received: by 2002:a19:44:: with SMTP id 65mr659817lfa.151.1610074057075; Thu, 07 Jan 2021 18:47:37 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id i19sm1733599ljj.26.2021.01.07.18.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 18:47:36 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Narcisa Ana Maria Vasile , Pallavi Kadam , Dmitry Malloy , Bruce Richardson , Neil Horman , Dmitry Kozlyuk Date: Fri, 8 Jan 2021 05:47:22 +0300 Message-Id: <20210108024723.26210-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210108024723.26210-1-dmitry.kozliuk@gmail.com> References: <20201212233447.23154-1-dmitry.kozliuk@gmail.com> <20210108024723.26210-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 3/4] buildtools: support object file extraction for Windows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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 + +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 965c08945..893a6c571 100755 --- a/buildtools/pmdinfogen.py +++ b/buildtools/pmdinfogen.py @@ -233,6 +233,12 @@ 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: @@ -241,6 +247,7 @@ def main(): raise Exception("elftools module not found") 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