...
1"""Contains macros for working with github.com/99designs/gqlgen in Bazel"""
2GO = "@go_sdk//:bin/go"
3
4GQLGEN = "@com_github_99designs_gqlgen//:gqlgen"
5
6# Common pieces for both generation macros
7ARGS = [
8 "$(location %s)" % GO,
9 "$(location %s)" % GQLGEN,
10]
11
12DATA = [
13 GO,
14 GQLGEN,
15]
16
17def gqlgen(name, pkg = ""):
18 """Run 99designs/gqlgen recursively for the given package.
19
20 Args:
21 name: The name of the produced rule, and the name this rule will be callable from.
22 e.g., name = "gen_talaria_rbac" in controllers/talaria/BUILD.bazel is callable
23 as //controllers/talaria:gen_talaria_rbac.
24 pkg: Relative path from repo root to Go package to generate GQL code from. Don't provide
25 if this is being defined in the desired package.
26 """
27
28 native.sh_binary(
29 name = name,
30 srcs = ["//hack/tools/gqlgen:gqlgen.sh"],
31 args = ARGS + [
32 pkg if pkg != "" else native.package_name(),
33 ],
34 data = DATA,
35 )
View as plain text