Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73bddf4c authored by Romain Jobredeaux's avatar Romain Jobredeaux Committed by Gerrit Code Review
Browse files

Merge "Create Bazel BUILD targets and Bazel rule for logtag file conversion."

parents 9d57bf30 bbdd255a
Loading
Loading
Loading
Loading

tools/BUILD.bazel

0 → 100644
+20 −0
Original line number Diff line number Diff line
py_library(
    name="event_log_tags",
    srcs = ["event_log_tags.py"],
)

py_binary(
    name="java-event-log-tags",
    srcs=["java-event-log-tags.py"],
    deps=[":event_log_tags"],
    visibility = ["//visibility:public"],
    python_version = "PY2",
)

py_binary(
    name="merge-event-log-tags",
    srcs=["merge-event-log-tags.py"],
    deps=[":event_log_tags"],
    visibility = ["//visibility:public"],
    python_version = "PY2",
)
+47 −0
Original line number Diff line number Diff line
"""Event log tags generation rule"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_android//rules:rules.bzl", "android_library")

def _event_log_tags_impl(ctx):
    out_files = []
    for logtag_file in ctx.files.srcs:
        out_filename = paths.replace_extension(logtag_file.basename, ".java")
        out_file = ctx.actions.declare_file(out_filename)
        out_files.append(out_file)
        ctx.actions.run(
            inputs = [logtag_file],
            outputs = [out_file],
            arguments = [
                "-o",
                out_file.path,
                logtag_file.path,
            ],
            progress_message = "Generating Java logtag file from %s" % logtag_file.short_path,
            executable = ctx.executable._logtag_to_java_tool,
        )
    return [DefaultInfo(files = depset(out_files))]

_event_log_tags = rule(
    implementation = _event_log_tags_impl,
    attrs = {
        "srcs": attr.label_list(allow_files = [".logtags"], mandatory = True),
        "_logtag_to_java_tool": attr.label(
            executable = True,
            cfg = "exec",
            allow_files = True,
            default = Label("//build/make/tools:java-event-log-tags"),
        ),
    },
)

def event_log_tags(name, srcs):
    _event_log_tags(
        name = name + "_gen_logtags",
        srcs = srcs,
    )

    android_library(
        name = name,
        srcs = [name + "_gen_logtags"],
    )