From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0F4F457B3; Tue, 13 Aug 2024 18:00:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D864F40E15; Tue, 13 Aug 2024 18:00:53 +0200 (CEST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id B087A40A84 for ; Tue, 13 Aug 2024 18:00:51 +0200 (CEST) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2cb576db1c5so3800235a91.1 for ; Tue, 13 Aug 2024 09:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1723564851; x=1724169651; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tQxNv6lj4Rb2InV7FsuUQ9V4I3NFyCxd2hOtlNTsRJ4=; b=SvWPCyIekm+EM5XoCsyAb9LP/NqwTjJejqTXC9f3tntYl3mwatwkn5OW6zneOmJVeJ 5srDwiaXOMjgiwHNQr3r/s62cC8UiqwwDcf2YV02191tB39Pux1uXEHIrc1Nen/Knbrt +zhdHvIlUTpu30ZbI/jNJua7TWjUEgUPGJJ4f+6ytHYLWU/wytdLs+81sCjdLAEWdkaF jCDFVRd2N54rsWeaiNrJyTmboK2XY62CzOcvkNLEHiqOalJzW+fTQPsUpaYTYRsL/Uu0 x8zQ+6Q00SPsaiEX5nTPlnnEnY9LCMALwsN9pPHighiat2dluuCdDPmPQZz+jn0AIV0m L/IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564851; x=1724169651; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tQxNv6lj4Rb2InV7FsuUQ9V4I3NFyCxd2hOtlNTsRJ4=; b=b2HD/5MFd7sTrkhKTzHgziq4Y8FYhvoK7mBuzRBqnXjwabaQnl02oQ1yiIt7+O7bQz +DKYJl4CGDlB9ML9QEjU5q+8jBz7VoPvX6J7D/PHSStTU/vuI/ZBiBEhqybFavpNi63G 0RJTmnKoAAnsHMCYVQGvAKV8LT31yeMWqsD03G9MHUj1jVfG70sSTDdM26eWd+uqlewQ 4VJg7uwnoLXN8IUpEu+ux0lslrnD7Gjfr/C8g2yiqYtS0+e/eDp1fVpEbdyCvlsfqa4z NlWJUIkzjBqTE1Tq+T6wpzK21fDK1IvXTgyxmU+WBpTRjDqVi+5wHi3QRBvI3zkXqC/5 rgqw== X-Gm-Message-State: AOJu0Yz8tjfqcTIOwD7V+AuBWNDGCKcQIz0uGfGUM2X8rNP68tAJOViW 24AednrfgzE1g4Z343yPIkKdwC+WzBqSmq29rVIz9kAY+u8EY5BdDCqbbd8vAqRciXld1uPfBV5 pEYk= X-Google-Smtp-Source: AGHT+IHOlhbGDtjvmw8xZWaG6IZhgjDIND4f7R5dzpXnWP5y8n2hFRqXTkRLdq7lsi9+wmM+Lh+ebQ== X-Received: by 2002:a17:90a:9a5:b0:2c9:8105:483 with SMTP id 98e67ed59e1d1-2d392501f4dmr4577283a91.14.1723564850744; Tue, 13 Aug 2024 09:00:50 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d1fcfe487esm7482612a91.42.2024.08.13.09.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 09:00:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson Subject: [PATCH v6 1/4] buildtools: add helper to convert text file to header Date: Tue, 13 Aug 2024 08:57:52 -0700 Message-ID: <20240813160039.5861-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240813160039.5861-1-stephen@networkplumber.org> References: <20240730225520.83314-1-stephen@networkplumber.org> <20240813160039.5861-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Simple script to read a file and make it into a initialized C string in a header file. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- buildtools/gen-header.py | 36 ++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 buildtools/gen-header.py diff --git a/buildtools/gen-header.py b/buildtools/gen-header.py new file mode 100644 index 0000000000..06e645863c --- /dev/null +++ b/buildtools/gen-header.py @@ -0,0 +1,36 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Stephen Hemminger + +""" +Script to read a text file and convert it into a header file. +""" +import sys +import os + + +def main(): + '''program main function''' + print(f'/* File autogenerated by {sys.argv[0]} */') + for path in sys.argv[1:]: + name = os.path.basename(path) + print() + print(f'/* generated from {name} */') + with open(path, "r") as f: + array = name.replace(".", "_") + print(f'static const char {array}[] = ' + '{') + line = f.readline() + + # make sure empty string is null terminated + if not line: + print(' ""') + + while line: + s = repr(line) + print(' {}'.format(s.replace("'", '"'))) + line = f.readline() + print('};') + + +if __name__ == "__main__": + main() diff --git a/buildtools/meson.build b/buildtools/meson.build index 3adf34e1a8..bc818a71d5 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -24,6 +24,7 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +header_gen_cmd = py3 + files('gen-header.py') # install any build tools that end-users might want also install_data([ @@ -48,4 +49,3 @@ else pmdinfo += 'ar' pmdinfogen += 'elf' endif - -- 2.43.0