Convert verilator_includer to python3

This commit is contained in:
Wilson Snyder 2023-01-21 14:40:22 -05:00
parent a98eceb501
commit bc7048e8d1
5 changed files with 29 additions and 20 deletions

View File

@ -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 \

View File

@ -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:

View File

@ -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
######################################################################

View File

@ -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:

View File

@ -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: