"""Contains macros for working with com_github_golang_mock//:gqlgen in Bazel""" GO = "@go_sdk//:bin/go" GOMOCK = "@com_github_golang_mock//mockgen:mockgen" # Common pieces for both generation macros ARGS = [ "$(location %s)" % GO, "$(location %s)" % GOMOCK, ] DATA = [ GO, GOMOCK, ] def gomock(name, pkg = ""): """Run gomock recursively for the given package. Args: name: The name of the produced rule, and the name this rule will be callable from. e.g., name = "gen_talaria_rbac" in controllers/talaria/BUILD.bazel is callable as //controllers/talaria:gen_talaria_rbac. pkg: Relative path from repo root to Go package to generate GQL code from. Don't provide if this is being defined in the desired package. """ native.sh_binary( name = name, srcs = ["//hack/tools/gomock:gomock.sh"], args = ARGS + [ pkg if pkg != "" else native.package_name(), ], data = DATA, )