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 415BA45702; Wed, 31 Jul 2024 19:36:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57A5C43007; Wed, 31 Jul 2024 19:36:30 +0200 (CEST) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id AAE0843003 for ; Wed, 31 Jul 2024 19:36:28 +0200 (CEST) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-70d2d7e692eso4941314b3a.0 for ; Wed, 31 Jul 2024 10:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1722447387; x=1723052187; 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=H9AmpSmyJI8LT0bFXhTP8Iga+uZ2SO4He+V+kxI8FzACwuZBb5+RIrEtzlgsVBRTuY b45eWeNrZZZBGeFfgPUSD8nJ0GPKnVqhD3YHI65ZpXyOGK4L0+2QVoVxgT8ZJtKbiUon 56Pg2lkVxjuVB7EGcNq10Zn1mIAOn5fPDE/dBlmchlMm5nRwrZSe1ItuEJHlT2bD3ACc 2ZFC2+xRA7ZLF5a/NMgNVO6sD4y66VQqRveEyr5tmJ5PxgYgutnjgW8wNjWPENkETWAW 1TrSfaMTO7KeBMFrAVtY6t3PLu7nNhWX3J9MBqILnKMjuMxMmeEcuOsinY7mTo5Cflkz lmCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722447387; x=1723052187; 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=xFbffRD/5fh17edckeeFB8jVMF4+kRn7NEUJiXKXFxnj9BvlFO+49PqNqEdj3W4xil yWY0tcLVvCOEqCSWqxTPYjZtKu8szcgGSs7fShRU2Ri6kFc0y99I2AKlpLek234TBFbr jlJS2V6DBY96ARNE/9E4o+EfdUeyeTrcFPTybPfu4n2274Ix/1BWUhHfvKNOCKevqW8P 0CvbkjTe3Gy+ZSn6E8rrxjqjhHS6hDlTnNWgLZCfjVoIUXCar4Jz6SpVmwrXsmU9hWxf o6vpypk4iREVfM87lfcBMkISa9oBq0Ydu6ukM9vbuuSxH3xtD+2tyZdZ+e+jHuZrGd7t k5MA== X-Gm-Message-State: AOJu0YycoXCTVUqj3aJ4WwR9IuBMU6P9J7pAoUJ77ucCiGeVBlRLGsOI xFaKrnmAMls3rBlgtpJaITBkncS55YEsKlZRVpc/1BD4Bqxp4gIBGyKq3lgVG011BfR2Bx4RnPp D X-Google-Smtp-Source: AGHT+IGBTFtD7JQm6Pp78cyQiEiMXLwLY2XL6+W7fgJbdzaHqhBsM8gqbUT3sXLdZ8TQI9+3UefgVA== X-Received: by 2002:a05:6a21:32a6:b0:1c2:8cf4:766c with SMTP id adf61e73a8af0-1c68d0d9724mr178377637.33.1722447387588; Wed, 31 Jul 2024 10:36:27 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7b7b1besm10870484a12.2.2024.07.31.10.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:36:27 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3 1/3] buildtools: add helper to convert text file to header Date: Wed, 31 Jul 2024 10:35:11 -0700 Message-ID: <20240731173616.91081-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240731173616.91081-1-stephen@networkplumber.org> References: <20240730225520.83314-1-stephen@networkplumber.org> <20240731173616.91081-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