diff --git a/bin/verilator_includer b/bin/verilator_includer index 08076063e..f6b9bd98b 100755 --- a/bin/verilator_includer +++ b/bin/verilator_includer @@ -9,19 +9,32 @@ # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 ###################################################################### +import glob +import os import re import sys print("// DESCR" + "IPTION: Generated by verilator_includer via makefile") +print("#ifndef VERILATOR_INCLUDED") +print("#define VERILATOR_INCLUDED") re_arg_d = re.compile(r'^-D([^=]+)=(.*)') +def include(arg): + print("#include \"%s\"" % (arg)) + 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))) + elif os.path.exists(arg): + include(arg) else: - print("#include \"%s\"" % (arg)) + files = glob.glob(arg) + for file in files: + include(file) + +print("#endif") ###################################################################### # Local Variables: diff --git a/include/verilated.mk.in b/include/verilated.mk.in index 8e040cd79..9177c0643 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -183,7 +183,7 @@ ifneq ($(VM_PARALLEL_BUILDS),1) VK_OBJS += $(VM_PREFIX)__ALL.o $(VM_PREFIX)__ALL.cpp: $(addsuffix .cpp, $(VM_FAST) $(VM_SLOW)) - $(VERILATOR_INCLUDER) -DVL_INCLUDE_OPT=include $^ > $@ + $(VERILATOR_INCLUDER) -DVL_INCLUDE_OPT=include "$(VM_PREFIX)*.cpp" > $@ all_cpp: $(VM_PREFIX)__ALL.cpp else # Parallel build: Each .cpp file by itself. This can be somewhat slower for diff --git a/test_regress/driver.pl b/test_regress/driver.pl index a0c616a1f..55fff36f6 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -681,7 +681,7 @@ sub new { $self->{status_filename} ||= "$self->{obj_dir}/V" . $self->{name} . ".status"; $self->{run_log_filename} ||= "$self->{obj_dir}/vlt_sim.log"; $self->{coverage_filename} ||= "$self->{obj_dir}/coverage.dat"; - $self->{main_filename} ||= "$self->{obj_dir}/$self->{VM_PREFIX}__main.cpp"; + $self->{main_filename} ||= "$self->{obj_dir}/main__$self->{VM_PREFIX}__main.cpp"; ($self->{top_filename} ||= $self->{pl_filename}) =~ s/\.pl$//; ($self->{golden_filename} ||= $self->{pl_filename}) =~ s/\.pl$/.out/; if (-e ($self->{top_filename} . ".vhd")) { # If VHDL file exists