Skip to content

Commit

Permalink
Fixed include path
Browse files Browse the repository at this point in the history
  • Loading branch information
abrisco committed Aug 2, 2024
1 parent 9b1e360 commit 3f684a2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
15 changes: 0 additions & 15 deletions dependency_support/com_github_westes_flex/flex.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,3 @@ 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",
],
)
30 changes: 30 additions & 0 deletions dependency_support/verilator/private/verilator_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,33 @@ verilator_build_template = rule(
),
},
)

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

output = ctx.outputs.out
if output.basename != "FlexLexer.h":
fail("The output file must be a file named `FlexLexer.h`")

ctx.actions.symlink(
output = output,
target_file = flex_toolchain.flex_lexer_h,
)

return [DefaultInfo(
files = depset([output]),
)]

current_flex_lexer_header = rule(
doc = "Access `FlexLexer.h` from the current toolchain.",
implementation = _currrent_flex_lexer_header_impl,
attrs = {
"out": attr.output(
doc = "The location in which to write the header file to.",
mandatory = True,
),
},
toolchains = [
"@rules_flex//flex:toolchain_type",
],
)
7 changes: 5 additions & 2 deletions dependency_support/verilator/verilator.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

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", "current_flex_lexer_header")
load("@rules_hdl//dependency_support/com_github_westes_flex:flex.bzl", "genlex")
load(
"@rules_hdl//dependency_support/verilator/private:verilator_utils.bzl",
"verilator_astgen",
"verilator_bisonpre",
"verilator_build_template",
"verilator_flexfix",
"verilator_version",
"current_flex_lexer_header"
)

package(default_visibility = ["//visibility:private"])
Expand Down Expand Up @@ -198,11 +199,13 @@ cc_library(

current_flex_lexer_header(
name = "current_flex_lexer_header",
out = "fles/src/FlexLexer.h"
)

cc_library(
name = "FlexLexer",
srcs = [":current_flex_lexer_header"],
srcs = [":fles/src/FlexLexer.h"],
includes = ["flex/src"],
)

# TODO(kkiningh): Verilator also supports multithreading, should we enable it?
Expand Down

0 comments on commit 3f684a2

Please sign in to comment.