# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

"""KiCad Bazel Rules."""

load("@bazel_skylib//rules:native_binary.bzl", "native_test")

def kicad_project(name, project, sym_lib_table, fp_lib_table, schematic_root, schematic_srcs, data):
    kicad_schematic_pdf(name = name + "_sch", root = schematic_root, srcs = schematic_srcs, data = data + [project, sym_lib_table])
    kicad_schematic_test(name = name + "_test", root = schematic_root, srcs = schematic_srcs, data = data + [project, sym_lib_table])

def kicad_schematic_test(name, root, srcs, data):
    args = ["sch", "erc", "--exit-code-violations", "$(rootpath " + root + " )"]

    native_test(
        name = name,
        src = str(Label("//build:kicad_cli_test")),
        args = args,
        data = srcs + data + [root],
        # Note: out is mandatory in older bazel-skylib versions.
        out = name + ".exe",
    )

def _kicad_schematic_pdf_impl(ctx):
    pdf_file = ctx.actions.declare_file(ctx.label.name + ".pdf")

    args = ["sch", "export", "pdf", "--output", pdf_file.path, ctx.file.root.path]

    ctx.actions.run(
        inputs = ctx.files.srcs + [ctx.file.root],
        outputs = [pdf_file],
        arguments = args,
        use_default_shell_env = True,
        progress_message = "running ERC on %s" % ctx.attr.name,
        executable = ctx.executable._kicad_cli,
    )

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

kicad_schematic_pdf = rule(
    implementation = _kicad_schematic_pdf_impl,
    attrs = {
        "srcs": attr.label_list(allow_files = [".kicad_sch"]),
        "root": attr.label(
            allow_single_file = [".kicad_sch"],
            mandatory = True,
        ),
        "data": attr.label_list(allow_files = True),
        "_kicad_cli": attr.label(
            executable = True,
            cfg = "exec",
            allow_files = True,
            default = Label("//build:kicad_cli"),
        ),
    },
)
