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 B9B7E456F3; Wed, 31 Jul 2024 00:56:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8644410FC; Wed, 31 Jul 2024 00:56:02 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id 754D6402C8 for ; Wed, 31 Jul 2024 00:55:31 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-70eb0ae23e4so3579376b3a.0 for ; Tue, 30 Jul 2024 15:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1722380130; x=1722984930; 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=XCoa6J7mzjqWs9Pz++CDkfjK2CtkjEuk/eQ2MQ+HpOIRP0rxk7kK4f7N0W/RYG053R /MSb+GjqQwRL/JxqQlK9P3k0ixbVk9ki2WoOYJgXv/opcb7IuCs4jA5JzAPRqVpfIDKb 6Gf6EOl6srBlK17FlieUles2Btl5v11YMNNeTTDmMH0NuxieKGbTl+U4V3uX+GO0EajR YxXt+EsYTjxi+5kchR1FRXG1sb0E0EM2uFNXKa5MZKRh93aFDtrqcsu+SnZUwnIH59Es L93QMDihIHXFisTgd5SEG/rTyChcilj4EO1iCktnlYSjg29BschW101fQxrQXKG5ao84 6uNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722380130; x=1722984930; 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=b3bMYxcwExktsA0hjwXsTYMrJHe3nKeetqrmKk5VO98kl6cqWTSyMUE/jCRk1cj3Nw 0z14n5h8GvArMJm7TfHeM7fKTZk3pijlPbrL0LTeH3A0s7u5AhtIuSpSXYAcr9V3zA3H QhFec/LcvVbbqrUX7fzOTFOMgw//yKQylfxmccyUMO1ygGe0o79nh3bT8n6yopYf5W1E fM/NtfBXsEkR+mi5LOGCP1NJALig+zDh4/o6f/lLy5K253f1V28TLvk+wexmYiwONtj9 n/O5eg0i7zpQmIRQOHzlyM6RdJrkb/OxI2qo3S/LLQKWGbMi05NtP4fb63TedxDN1LT3 4mWA== X-Gm-Message-State: AOJu0YzzYwXIpgL5pOzIrk3hnVt2Hg0Z77YKV/fvkPHWU1B1WbyEv+w+ qD4vQWeqv2dG55yZN9dFBfBTS0CQGIu/Q2vVdhW7uAFtLqayqGws+6xIzBLmvjeHra0GG/f/eED Z X-Google-Smtp-Source: AGHT+IEPLFI9N6HflmD38J1Le6rMSon4UApWodN58w2+FBwrAJgi6IyT9jo8uGRx3ZAdFdyPnxZSEw== X-Received: by 2002:a05:6a00:2e87:b0:705:9a28:aa04 with SMTP id d2e1a72fcca58-70eced9bacdmr10852215b3a.23.1722380130375; Tue, 30 Jul 2024 15:55:30 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead712e9csm8949183b3a.79.2024.07.30.15.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 15:55:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH 1/3] buildtools: add helper to convert text file to header Date: Tue, 30 Jul 2024 15:51:27 -0700 Message-ID: <20240730225520.83314-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730225520.83314-1-stephen@networkplumber.org> References: <20240730225520.83314-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