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