Skip to content

Commit

Permalink
Add rule to access FlexLexer.h for Verilator
Browse files Browse the repository at this point in the history
  • Loading branch information
abrisco committed Aug 1, 2024
1 parent 42b159c commit 9b1e360
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
15 changes: 15 additions & 0 deletions dependency_support/com_github_westes_flex/flex.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,18 @@ genlex(
],
output_to_genfiles = True,
)

def _currrent_flex_lexer_header_impl(ctx):
flex_toolchain = ctx.toolchains["@rules_flex//flex:toolchain_type"].flex_toolchain

return [DefaultInfo(
files = depset([flex_toolchain.flex_lexer_h]),
)]

current_flex_lexer_header = rule(
doc = "Access `FlexLexer.h` from the current toolchain.",
implementation = _currrent_flex_lexer_header_impl,
toolchains = [
"@rules_flex//flex:toolchain_type",
],
)
13 changes: 11 additions & 2 deletions dependency_support/verilator/verilator.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_hdl//dependency_support/com_github_westes_flex:flex.bzl", "genlex")
load("@rules_hdl//dependency_support/com_github_westes_flex:flex.bzl", "genlex", "current_flex_lexer_header")
load(
"@rules_hdl//dependency_support/verilator/private:verilator_utils.bzl",
"verilator_astgen",
Expand Down Expand Up @@ -196,6 +196,15 @@ cc_library(
strip_include_prefix = "include/",
)

current_flex_lexer_header(
name = "current_flex_lexer_header",
)

cc_library(
name = "FlexLexer",
srcs = [":current_flex_lexer_header"],
)

# TODO(kkiningh): Verilator also supports multithreading, should we enable it?
cc_library(
name = "verilator_libV3",
Expand Down Expand Up @@ -251,7 +260,7 @@ cc_library(
],
deps = [
":verilatedos",
# "@com_github_westes_flex//:FlexLexer",
":FlexLexer",
],
)

Expand Down

0 comments on commit 9b1e360

Please sign in to comment.