Skip to content

Commit

Permalink
[bazel] Convert autogen_hjson_header to using stamping
Browse files Browse the repository at this point in the history
With this change, `autogen_hjson_header` will now only pass
stamping information to regtool if required on the command-line.

Signed-off-by: Amaury Pouly <[email protected]>
  • Loading branch information
pamaury committed Jan 18, 2024
1 parent 0d507ba commit a8cb50e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions rules/autogen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("//rules:stamp.bzl", "stamp_attr", "stamping_enabled")

"""Autogeneration rules for OpenTitan.
The rules in this file are for autogenerating various file resources
Expand All @@ -27,17 +29,22 @@ def _hjson_header(ctx):
executable = ctx.executable._regtool,
)

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

tock = ctx.actions.declare_file("{}.rs".format(ctx.label.name))
ctx.actions.run(
outputs = [tock],
inputs = ctx.files.srcs + [ctx.executable._regtool, ctx.file.version_stamp],
inputs = ctx.files.srcs + [ctx.executable._regtool] + stamp_files,
arguments = [
"--tock",
"--version-stamp={}".format(ctx.file.version_stamp.path),
"-q",
"-o",
tock.path,
] + node + [src.path for src in ctx.files.srcs],
] + stamp_args + node + [src.path for src in ctx.files.srcs],
executable = ctx.executable._regtool,
)

Expand All @@ -60,16 +67,12 @@ autogen_hjson_header = rule(
"node": attr.string(
doc = "Register block node to generate",
),
"version_stamp": attr.label(
default = "//util:full_version_file",
allow_single_file = True,
),
"_regtool": attr.label(
default = "//util:regtool",
executable = True,
cfg = "exec",
),
},
} | stamp_attr(-1, "//rules:stamp_flag"),
)

def _chip_info_src(ctx):
Expand Down

0 comments on commit a8cb50e

Please sign in to comment.