# Copyright Google LLC, 2022
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

"""Rules to automatically generate files with utility tools."""

def _autogen_top_gen_hjson(ctx):
    """ Use topgen_matcha.py to generate top hjson file.

    This rule assumes all input hjson files (top_{name}/**/data/**/*.hjson}) are
    already up-to-date, and use util:topgen_matcha tool to generate the
    top-level hjson description. It can be used to scramble the boot rom image.

        Args:
            srcs: Input top-level hjson file.
            output: Generated top hjson file.
            data: Files needed (template files, IP hjson files).
        Output:
            output hjson file. Note topgen_matcha always dump it at
            {out_dir}/data/autogen.
            It can be one of the following files:
                data/autogen/top_{name}.gen.hjson
                data/autogen/top_{name}.gen.rom_ctrl.hjson
    """

    if not ctx.attr.output.startswith("data/autogen"):
        fail("output must be pointed to data/autogen", [ctx.attr.output])

    hjson = ctx.actions.declare_file("{}".format(ctx.attr.output))
    ctx.actions.run(
        mnemonic = "Topgen",
        outputs = [hjson],
        inputs = ctx.files.data + [ctx.file.srcs, ctx.executable._topgentool, ctx.file._util],
        env = {
            "OPENTITAN_TOP": "{}/../".format(ctx.file._util.dirname),
        },
        arguments = [
            "-t",
            "{}".format(ctx.file.srcs.path),
            "-o",
            "{}/../../".format(hjson.dirname),
            "--no-top",
            "--dump_gen_hjson",
        ],
        executable = ctx.executable._topgentool,
    )

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

autogen_top_gen_hjson = rule(
    implementation = _autogen_top_gen_hjson,
    attrs = {
        "srcs": attr.label(
            mandatory = True,
            allow_single_file = True,
            doc = "topgen input top-level hjson file",
        ),
        "data": attr.label_list(
            allow_files = True,
            doc = "Files needed at runtime",
        ),
        "output": attr.string(
            mandatory = True,
            doc = "Generated hjson file path",
        ),
        "_topgentool": attr.label(
            default = "@//util:topgen_matcha",
            executable = True,
            cfg = "exec",
        ),
        "_util": attr.label(
            default = "@lowrisc_opentitan//util:BUILD",
            allow_single_file = True,
        ),
    },
)
