Skip to content

Commit

Permalink
[rules,autogen] Remove autogen_hjson_{c,rust}_header
Browse files Browse the repository at this point in the history
Those rules are now unused

Signed-off-by: Amaury Pouly <[email protected]>
  • Loading branch information
pamaury committed Dec 13, 2024
1 parent 145cd57 commit 4d3e2e6
Showing 1 changed file with 0 additions and 129 deletions.
129 changes: 0 additions & 129 deletions rules/autogen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,6 @@ used by the OpenTitan build, such as register definition files generated
from hjson register descriptions.
"""

def _hjson_c_header(ctx):
output_stem = (ctx.attr.output_stem if ctx.attr.output_stem else ctx.label.name.replace("_c_", "_"))
header = ctx.actions.declare_file("{}.h".format(output_stem))
node = []
if ctx.attr.node:
node.append("--node={}".format(ctx.attr.node))

arguments = [
"-D",
"-q",
"-o",
header.path,
] + node + [src.path for src in ctx.files.srcs]

# `inputs = ctx.files.srcs` will create `inputs` as an immutable list
# so need to unpack like this before appending the alias later
inputs = list(ctx.files.srcs)

# add path to an alias path if it's needed
if ctx.attr.alias:
alias = ctx.file.alias

# add the alias argument
arguments.extend([
"--alias",
alias.path,
])

# add the alias as an input file
inputs.append(alias)

ctx.actions.run(
outputs = [header],
inputs = inputs,
arguments = arguments,
executable = ctx.executable._regtool,
)

return [
CcInfo(compilation_context = cc_common.create_compilation_context(
includes = depset([header.dirname]),
headers = depset([header]),
)),
DefaultInfo(files = depset([header])),
OutputGroupInfo(
header = depset([header]),
),
]

autogen_hjson_c_header = rule(
implementation = _hjson_c_header,
attrs = {
"srcs": attr.label_list(allow_files = True),
"node": attr.string(
doc = "Register block node to generate",
),
"alias": attr.label(
mandatory = False,
allow_single_file = True,
doc = "A path to an alias file",
),
"output_stem": attr.string(
doc = """
The name of the output file with no suffix.
This is optional, and if not given it will be set to the
target name replacing "_c_" by "_".
""",
),
"_regtool": attr.label(
default = "//util:regtool",
executable = True,
cfg = "exec",
),
},
)

def _opentitan_ip_c_header_impl(ctx):
header = ctx.actions.declare_file("{}_regs.h".format(ctx.attr.ip))
top = ctx.attr.top[OpenTitanTopInfo]
Expand Down Expand Up @@ -181,59 +105,6 @@ opentitan_ip_rust_header = rule(
} | stamp_attr(-1, "//rules:stamp_flag"),
)

def _hjson_rust_header(ctx):
node = []
if ctx.attr.node:
node.append("--node={}".format(ctx.attr.node))
stamp_args = []
stamp_files = []
if stamping_enabled(ctx):
stamp_files = [ctx.version_file]
stamp_args.append("--version-stamp={}".format(ctx.version_file.path))

output_stem = (ctx.attr.output_stem if ctx.attr.output_stem else ctx.label.name.replace("_rust_", "_"))
tock = ctx.actions.declare_file("{}.rs".format(output_stem))
ctx.actions.run(
outputs = [tock],
inputs = ctx.files.srcs + [ctx.executable._regtool] + stamp_files,
arguments = [
"--tock",
"-q",
"-o",
tock.path,
] + stamp_args + node + [src.path for src in ctx.files.srcs],
executable = ctx.executable._regtool,
)

return [
DefaultInfo(files = depset([tock])),
OutputGroupInfo(
tock = depset([tock]),
),
]

autogen_hjson_rust_header = rule(
implementation = _hjson_rust_header,
attrs = {
"srcs": attr.label_list(allow_files = True),
"node": attr.string(
doc = "Register block node to generate",
),
"output_stem": attr.string(
doc = """
The name of the output file with no suffix.
This is optional, and if not given it will be set to the
target name replacing "_rust_" by "_".
""",
),
"_regtool": attr.label(
default = "//util:regtool",
executable = True,
cfg = "exec",
),
} | stamp_attr(-1, "//rules:stamp_flag"),
)

def _chip_info_src(ctx):
stamp_args = []
stamp_files = []
Expand Down

0 comments on commit 4d3e2e6

Please sign in to comment.