Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal change #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ecclesia/build_defs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ bzl_library(
srcs = ["oss.bzl"],
)

bzl_library(
name = "resources",
srcs = ["resources.bzl"],
visibility = ["//ecclesia:mmanager_users"],
)

bzl_library(
name = "query",
srcs = ["query.bzl"],
Expand Down
37 changes: 37 additions & 0 deletions ecclesia/build_defs/resources.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Helper macro for defining resource protos"""

_DEFAULT_VISIBILITY = ["//ecclesia:mmanager_users"]

def resource_proto(name, srcs, deps = None):
"""Generates a standardized set of proto libraries for a given MManager Resource.

<name>_proto - proto_library
<name>_cc_proto - cc_proto_library

Args:
name: Name of the resulting proto_library (expects '_proto' suffix, and will add it if not
provided).
srcs: Sources for the resulting proto_library.
deps: Additional dependencies for the resulting proto_library.
"""

# Fail if name was provided with '_proto' suffix. '_proto' suffix is added automatically via
# this macro and it should not be specified as part of the name arguement.
if name.endswith("_proto"):
fail("Resource proto macro should not be called with name attribute that ends with '_proto'.")

if deps == None:
deps = []

native.proto_library(
name = name + "_proto",
srcs = srcs,
deps = deps,
visibility = _DEFAULT_VISIBILITY,
)

native.cc_proto_library(
name = name + "_cc_proto",
deps = [":" + name + "_proto"],
visibility = _DEFAULT_VISIBILITY,
)