Skip to content

Commit

Permalink
verilator: Add generated headers to default provider files
Browse files Browse the repository at this point in the history
  • Loading branch information
hovind committed Jan 15, 2024
1 parent f30da88 commit c7c4fee
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions verilator/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def _verilator_cc_library(ctx):
verilog_files.append(file)

verilator_output = ctx.actions.declare_directory(ctx.label.name + "-gen")
verilator_output_cpp = ctx.actions.declare_directory(ctx.label.name + ".cpp")
verilator_output_hpp = ctx.actions.declare_directory(ctx.label.name + ".h")
verilator_output_cpp = ctx.actions.declare_directory(ctx.label.name + "-cpp")
verilator_output_hpp = ctx.actions.declare_directory(ctx.attr.out_include_dir)

prefix = "V" + ctx.attr.module_top

Expand Down Expand Up @@ -175,7 +175,7 @@ def _verilator_cc_library(ctx):
defines = ["VM_TRACE"] if ctx.attr.trace else []
deps = [ctx.attr._verilator_lib, ctx.attr._zlib, ctx.attr._verilator_svdpi]

return cc_compile_and_link_static_library(
[default, cc] = cc_compile_and_link_static_library(
ctx,
srcs = [verilator_output_cpp],
hdrs = [verilator_output_hpp],
Expand All @@ -184,6 +184,10 @@ def _verilator_cc_library(ctx):
includes = [verilator_output_hpp.path],
deps = deps,
)
return [
DefaultInfo(files = depset([verilator_output_hpp], transitive = [default.files])),
cc,
]

verilator_cc_library = rule(
_verilator_cc_library,
Expand All @@ -209,6 +213,10 @@ verilator_cc_library = rule(
doc = "List of additional compilation flags",
default = [],
),
"out_include_dir": attr.string(
doc = "Name of the output subdirectory with the header files.",
default = "include",
),
"_cc_toolchain": attr.label(
doc = "CC compiler.",
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
Expand Down

0 comments on commit c7c4fee

Please sign in to comment.