From bc7048e8d1152628669aea1ee78a4ba97054361a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 21 Jan 2023 14:40:22 -0500 Subject: [PATCH] Convert verilator_includer to python3 --- Makefile.in | 2 +- bin/verilator_includer | 39 +++++++++++++++++++++-------------- include/verilated.mk.in | 2 +- nodist/clang_check_attributes | 3 ++- src/Makefile_obj.in | 3 +-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Makefile.in b/Makefile.in index 916f6c756..ba14a84d7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -53,7 +53,6 @@ INSTALL_DATA = @INSTALL_DATA@ MAKEINFO = makeinfo POD2TEXT = pod2text MKINSTALLDIRS = $(SHELL) $(srcdir)/src/mkinstalldirs -PERL = @PERL@ # Version (for docs/guide/conf.py) PACKAGE_VERSION_NUMBER = @PACKAGE_VERSION_NUMBER@ @@ -394,6 +393,7 @@ PY_PROGRAMS = \ bin/verilator_ccache_report \ bin/verilator_difftree \ bin/verilator_gantt \ + bin/verilator_includer \ bin/verilator_profcfunc \ examples/xml_py/vl_file_copy \ examples/xml_py/vl_hier_graph \ diff --git a/bin/verilator_includer b/bin/verilator_includer index a4227a7ab..08076063e 100755 --- a/bin/verilator_includer +++ b/bin/verilator_includer @@ -1,20 +1,29 @@ -#!/usr/bin/env perl -# DESCRIPTION: Print include statements for each ARGV +#!/usr/bin/env python3 +# pylint: disable=C0114,C0209 # # Copyright 2003-2023 by Wilson Snyder. This program is free software; you -# can redistribute it and/or modify it under the terms of either the GNU -# Lesser General Public License Version 3 or the Perl Artistic License -# Version 2.0. +# can redistribute it and/or modify the Verilator internals under the terms +# of either the GNU Lesser General Public License Version 3 or the Perl +# Artistic License Version 2.0. +# # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 ###################################################################### -require 5.005; -use warnings; -print "// DESCR" . "IPTION: Generated by verilator_includer via makefile\n"; -foreach my $param (@ARGV) { - if ($param =~ /^-D([^=]+)=(.*)/) { - print "#define $1 $2\n"; - } else { - print "#include \"$param\"\n"; - } -} +import re +import sys + +print("// DESCR" + "IPTION: Generated by verilator_includer via makefile") + +re_arg_d = re.compile(r'^-D([^=]+)=(.*)') + +for arg in sys.argv[1:]: + match_d = re_arg_d.match(arg) + if match_d: + print("#define %s %s" % (match_d.group(1), match_d.group(2))) + else: + print("#include \"%s\"" % (arg)) + +###################################################################### +# Local Variables: +# compile-command: "./verilator_includer -Ddef=value -Ddef2=value2 file1.h file2.h" +# End: diff --git a/include/verilated.mk.in b/include/verilated.mk.in index 4c80f55ad..60d6f726f 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -36,7 +36,7 @@ CFG_LDLIBS_THREADS = @CFG_LDLIBS_THREADS@ # Programs VERILATOR_COVERAGE = $(PERL) $(VERILATOR_ROOT)/bin/verilator_coverage -VERILATOR_INCLUDER = $(PERL) $(VERILATOR_ROOT)/bin/verilator_includer +VERILATOR_INCLUDER = $(PYTHON3) $(VERILATOR_ROOT)/bin/verilator_includer VERILATOR_CCACHE_REPORT = $(PYTHON3) $(VERILATOR_ROOT)/bin/verilator_ccache_report ###################################################################### diff --git a/nodist/clang_check_attributes b/nodist/clang_check_attributes index 042acb7a2..825e50520 100755 --- a/nodist/clang_check_attributes +++ b/nodist/clang_check_attributes @@ -282,8 +282,9 @@ class CallAnnotationsValidator: handler(child) self._level -= 1 + @staticmethod def get_referenced_node_info( - self, node: clang.cindex.Cursor + node: clang.cindex.Cursor ) -> tuple[bool, Optional[clang.cindex.Cursor], VlAnnotations, Iterable[clang.cindex.Cursor]]: if not node.spelling and not node.displayname: diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 805a5e7d2..dd177da20 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -40,7 +40,6 @@ CXX = @CXX@ LINK = @CXX@ LEX = @LEX@ LFLAGS = -d -PERL = @PERL@ PYTHON3 = @PYTHON3@ YACC = @YACC@ OBJCACHE ?= @OBJCACHE@ @@ -387,7 +386,7 @@ HEADER_CC_H := $(filter-out $(NON_STANDALONE_HEADERS), $(notdir $(wildcard $(src header_cc: $(addsuffix __header_cc.o, $(basename $(HEADER_CC_H))) %__header_cc.cpp: %.h - $(PERL) $(srcdir)/../bin/verilator_includer $^ > $@ + $(PYTHON3) $(srcdir)/../bin/verilator_includer $^ > $@ .SUFFIXES: