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 50198456F9; Wed, 31 Jul 2024 06:23:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 817CE406BC; Wed, 31 Jul 2024 06:23:40 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 058E44042E for ; Wed, 31 Jul 2024 06:21:52 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1fc5239faebso34992405ad.1 for ; Tue, 30 Jul 2024 21:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1722399712; x=1723004512; 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=9h/uq1FGHGIM+pFt6ArfZ8KdOyxnzCimgviYb7GL8GA=; b=uBN8B5cMn4rfu8BgaWCtzypwC/7Mrthy2J0xeG2tiJyghi/MyHZfi5+GwbvB+e1fPH 64C8yVmKZOKiDl6rXEjYMyNglmhO6vqRjgfvx46hd14r4VhxlzCQNQ/i8nxTPbrNszEi ME0f7ux+1tJIwF1HfxmikoxLFcnqPvfBUmLdn3fF3dJAHJdggpvzOT40QHE18UqIfOCB eopP6ldu3ddx2+6G4zhFHR81XlfNhB7iejpATrND6KkI9A6KMXXi4d+kI+uAx+BqQNzo FuSYe7XmtFOJ9tVyStBR3Dw4/bQFMPbauxitRrKuz/N0lyEFOyztWhTEwD7J60xxzOCW 1Gvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722399712; x=1723004512; 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=9h/uq1FGHGIM+pFt6ArfZ8KdOyxnzCimgviYb7GL8GA=; b=nYqnQqR8KGSYjro9XdNn5pMW1JZo7x/A5eWW9k1diC5lEp4Q/aicFn/fF3Yzxtvc5H zwAP3wLV3rmKwHZtzws1F1j1KPyPYxyz/bPB05BkxelTEe93EyjpbC6uWlyhQ9UdWj3/ P9OwJaLp+riPzxkMpHIKFbshHBav6OZN4bglk4iMwzdbc/gG2fOnd1Ni2H0ZWqChXUuX gF11eGx5eBi03Zy16F8ysfr+L/LFKSkmtoH/dkCd1yHZNfgjd5gMhOtUXSzAd/uZrYVt R1cbZrv7nE/TwTqVasaKOdciDe8PvXSW3ij8vEfJDaNHgAzTl7eXN9Ip/s7fNmSrz631 c0Ww== X-Gm-Message-State: AOJu0Ywt0NuK/hm8nlHFrh4Dl626QF3Qz0qCDGhq5aeHYz0V/1gj7KqA WmrutDdOt3x+9TObLg6uKFliITdzHIhUr+9qXuYox7reePYCq3QE2+fXogQYopPIe3KxZqHPiai M X-Google-Smtp-Source: AGHT+IEIpe0n9wS5UNmaYqp6kJL0O7C1htYEmfj985Piae0cQNV4ApaCRWQ0p88NKmqJpaDrNevkJw== X-Received: by 2002:a17:902:ea01:b0:1f9:c3e4:4c0f with SMTP id d9443c01a7336-1ff04844d19mr109966045ad.34.1722399711970; Tue, 30 Jul 2024 21:21:51 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7c80044sm110093375ad.14.2024.07.30.21.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 21:21:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v2 1/3] buildtools: add helper to convert text file to header Date: Tue, 30 Jul 2024 21:20:29 -0700 Message-ID: <20240731042141.76985-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240731042141.76985-1-stephen@networkplumber.org> References: <20240730225520.83314-1-stephen@networkplumber.org> <20240731042141.76985-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 --- 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