xref: /aosp_15_r20/external/skia/infra/BUILD.bazel (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1load("//bazel:macros.bzl", "gazelle")
2
3package(
4    default_applicable_licenses = ["//:license"],
5)
6
7licenses(["notice"])
8
9gazelle(
10    name = "gazelle",
11    visibility = ["//visibility:public"],
12)
13
14alias(
15    name = "mockery",
16    actual = "@com_github_vektra_mockery_v2//:v2",
17    visibility = ["//visibility:public"],
18)
19
20# Non-predefined variables must be escaped with "$$" (e.g. "$$FOO"); see
21# https://bazel.build/reference/be/make-variables#predefined_label_variables.
22#
23# Based on
24# https://skia.googlesource.com/buildbot/+/c397c94283b79a792a76812cd43a6ac5d5282ddf/bazel/tools/errcheck/BUILD.bazel#1.
25_ERRCHECK_SCRIPT = """
26# Add the "go" binary to PATH.
27GO_PATH=$$(realpath $$(dirname $(rootpath @go_sdk//:bin/go)))
28export PATH=$$GO_PATH:$$PATH
29
30# Path to the "errcheck" binary.
31ERRCHECK=$$(realpath $(rootpath @com_github_kisielk_errcheck//:errcheck))
32
33# Change into the directory where Bazel was invoked.
34cd $$BUILD_WORKING_DIRECTORY
35
36$$ERRCHECK $$@
37"""
38
39# Based on
40# https://skia.googlesource.com/buildbot/+/c397c94283b79a792a76812cd43a6ac5d5282ddf/bazel/tools/errcheck/BUILD.bazel#17.
41genrule(
42    name = "gen_errcheck",
43    outs = ["errcheck.sh"],
44    cmd = "echo '%s' > $@" % _ERRCHECK_SCRIPT,
45    tools = [
46        "@com_github_kisielk_errcheck//:errcheck",
47        "@go_sdk//:bin/go",
48    ],
49)
50
51# Wrapper script around the "errcheck" binary.
52#
53# Errcheck requires the "go" binary to be in PATH. This scripts adds the Bazel-downloaded "go"
54# binary to PATH, then forwards all command-line arguments to the "errcheck" binary.
55#
56# Reference: https://bazel.build/reference/be/shell#sh_binary.
57#
58# Based on
59# https://skia.googlesource.com/buildbot/+/c397c94283b79a792a76812cd43a6ac5d5282ddf/bazel/tools/errcheck/BUILD.bazel#27
60sh_binary(
61    name = "errcheck",
62    srcs = ["errcheck.sh"],
63    data = [
64        "@com_github_kisielk_errcheck//:errcheck",
65        "@go_sdk//:bin/go",
66    ],
67    visibility = ["//visibility:public"],
68)
69