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 MAKEINFO = makeinfo
POD2TEXT = pod2text POD2TEXT = pod2text
MKINSTALLDIRS = $(SHELL) $(srcdir)/src/mkinstalldirs MKINSTALLDIRS = $(SHELL) $(srcdir)/src/mkinstalldirs
PERL = @PERL@
# Version (for docs/guide/conf.py) # Version (for docs/guide/conf.py)
PACKAGE_VERSION_NUMBER = @PACKAGE_VERSION_NUMBER@ PACKAGE_VERSION_NUMBER = @PACKAGE_VERSION_NUMBER@
@ -394,6 +393,7 @@ PY_PROGRAMS = \
bin/verilator_ccache_report \ bin/verilator_ccache_report \
bin/verilator_difftree \ bin/verilator_difftree \
bin/verilator_gantt \ bin/verilator_gantt \
bin/verilator_includer \
bin/verilator_profcfunc \ bin/verilator_profcfunc \
examples/xml_py/vl_file_copy \ examples/xml_py/vl_file_copy \
examples/xml_py/vl_hier_graph \ examples/xml_py/vl_hier_graph \

View File

@ -1,20 +1,29 @@
#!/usr/bin/env perl #!/usr/bin/env python3
# DESCRIPTION: Print include statements for each ARGV # pylint: disable=C0114,C0209
# #
# Copyright 2003-2023 by Wilson Snyder. This program is free software; you # 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 # can redistribute it and/or modify the Verilator internals under the terms
# Lesser General Public License Version 3 or the Perl Artistic License # of either the GNU Lesser General Public License Version 3 or the Perl
# Version 2.0. # Artistic License Version 2.0.
#
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
###################################################################### ######################################################################
require 5.005; import re
use warnings; import sys
print "// DESCR" . "IPTION: Generated by verilator_includer via makefile\n";
foreach my $param (@ARGV) { print("// DESCR" + "IPTION: Generated by verilator_includer via makefile")
if ($param =~ /^-D([^=]+)=(.*)/) {
print "#define $1 $2\n"; re_arg_d = re.compile(r'^-D([^=]+)=(.*)')
} else {
print "#include \"$param\"\n"; 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 # Programs
VERILATOR_COVERAGE = $(PERL) $(VERILATOR_ROOT)/bin/verilator_coverage 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 VERILATOR_CCACHE_REPORT = $(PYTHON3) $(VERILATOR_ROOT)/bin/verilator_ccache_report
###################################################################### ######################################################################

View File

@ -282,8 +282,9 @@ class CallAnnotationsValidator:
handler(child) handler(child)
self._level -= 1 self._level -= 1
@staticmethod
def get_referenced_node_info( def get_referenced_node_info(
self, node: clang.cindex.Cursor node: clang.cindex.Cursor
) -> tuple[bool, Optional[clang.cindex.Cursor], VlAnnotations, ) -> tuple[bool, Optional[clang.cindex.Cursor], VlAnnotations,
Iterable[clang.cindex.Cursor]]: Iterable[clang.cindex.Cursor]]:
if not node.spelling and not node.displayname: if not node.spelling and not node.displayname:

View File

@ -40,7 +40,6 @@ CXX = @CXX@
LINK = @CXX@ LINK = @CXX@
LEX = @LEX@ LEX = @LEX@
LFLAGS = -d LFLAGS = -d
PERL = @PERL@
PYTHON3 = @PYTHON3@ PYTHON3 = @PYTHON3@
YACC = @YACC@ YACC = @YACC@
OBJCACHE ?= @OBJCACHE@ 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: $(addsuffix __header_cc.o, $(basename $(HEADER_CC_H)))
%__header_cc.cpp: %.h %__header_cc.cpp: %.h
$(PERL) $(srcdir)/../bin/verilator_includer $^ > $@ $(PYTHON3) $(srcdir)/../bin/verilator_includer $^ > $@
.SUFFIXES: .SUFFIXES: