Skip to content

Commit

Permalink
Add googleapis 0.0.0-20241220-5e258e33
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 21, 2024
1 parent 1b45c47 commit 8043e85
Show file tree
Hide file tree
Showing 34 changed files with 431 additions and 1 deletion.
14 changes: 14 additions & 0 deletions modules/googleapis-cc/0.1.0/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "googleapis-cc",
version = "0.1.0",
bazel_compatibility = [">=7.2.1"],
)

bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33")
bazel_dep(name = "protobuf", version = "27.0")

switched_rules = use_extension("@googleapis//private/extensions:switched_rules.bzl", "switched_rules")
switched_rules.register(
name = "cc_proto_library",
file = "@protobuf//bazel:cc_proto_library.bzl",
)
1 change: 1 addition & 0 deletions modules/googleapis-cc/0.1.0/overlay/MODULE.bazel
Empty file.
7 changes: 7 additions & 0 deletions modules/googleapis-cc/0.1.0/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"integrity": "sha256-hznHbmgfkAkjuQDJ3w73XPQh05yrtUZQxLmtGbanbYU=",
"url": "https://github.com/fmeum/bazel-central-registry/releases/download/v1.0.0/empty.zip",
"overlay": {
"MODULE.bazel": "sha256-4GPXxlFen3Atai6EyboC87iGAPuNSpfBBmwnMQbayqc="
}
}
16 changes: 16 additions & 0 deletions modules/googleapis-cc/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://github.com/googleapis/googleapis",
"maintainers": [
{
"email": "[email protected]",
"name": "No Maintainer Specified"
}
],
"repository": [
"github:googleapis/googleapis"
],
"versions": [
"0.1.0"
],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions modules/googleapis-go/0.1.0/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "googleapis-go",
version = "0.1.0",
bazel_compatibility = [">=7.2.1"],
)

bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33")
bazel_dep(name = "rules_go", version = "0.50.1")

switched_rules = use_extension("@googleapis//private/extensions:switched_rules.bzl", "switched_rules")
switched_rules.register(
name = "go_proto_library",
file = "@rules_go//proto:def.bzl",
)
1 change: 1 addition & 0 deletions modules/googleapis-go/0.1.0/overlay/MODULE.bazel
Empty file.
7 changes: 7 additions & 0 deletions modules/googleapis-go/0.1.0/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"integrity": "sha256-hznHbmgfkAkjuQDJ3w73XPQh05yrtUZQxLmtGbanbYU=",
"url": "https://github.com/fmeum/bazel-central-registry/releases/download/v1.0.0/empty.zip",
"overlay": {
"MODULE.bazel": "sha256-GUjZBV62PY/o9joplOGrL6pIIASpyqWnhns27+JUCts="
}
}
16 changes: 16 additions & 0 deletions modules/googleapis-go/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://github.com/googleapis/googleapis",
"maintainers": [
{
"email": "[email protected]",
"name": "No Maintainer Specified"
}
],
"repository": [
"github:googleapis/googleapis"
],
"versions": [
"0.1.0"
],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions modules/googleapis-java/0.1.0/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "googleapis-java",
version = "0.1.0",
bazel_compatibility = [">=7.2.1"],
)

bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33")
bazel_dep(name = "protobuf", version = "27.0")

switched_rules = use_extension("@googleapis//private/extensions:switched_rules.bzl", "switched_rules")
switched_rules.register(
name = "java_proto_library",
file = "@protobuf//bazel:java_proto_library.bzl",
)
1 change: 1 addition & 0 deletions modules/googleapis-java/0.1.0/overlay/MODULE.bazel
Empty file.
7 changes: 7 additions & 0 deletions modules/googleapis-java/0.1.0/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"integrity": "sha256-hznHbmgfkAkjuQDJ3w73XPQh05yrtUZQxLmtGbanbYU=",
"url": "https://github.com/fmeum/bazel-central-registry/releases/download/v1.0.0/empty.zip",
"overlay": {
"MODULE.bazel": "sha256-eU1okw/B5a/szrR9RY4J489YrHyiYkbZ3uSsxa7/i+4="
}
}
16 changes: 16 additions & 0 deletions modules/googleapis-java/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://github.com/googleapis/googleapis",
"maintainers": [
{
"email": "[email protected]",
"name": "No Maintainer Specified"
}
],
"repository": [
"github:googleapis/googleapis"
],
"versions": [
"0.1.0"
],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions modules/googleapis-python/0.1.0/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module(
name = "googleapis-python",
version = "0.1.0",
bazel_compatibility = [">=7.2.1"],
)

bazel_dep(name = "googleapis", version = "0.0.0-20241220-5e258e33")
bazel_dep(name = "protobuf", version = "27.0")

switched_rules = use_extension("@googleapis//private/extensions:switched_rules.bzl", "switched_rules")
switched_rules.register(
name = "py_proto_library",
file = "@protobuf//bazel:py_proto_library.bzl",
)
1 change: 1 addition & 0 deletions modules/googleapis-python/0.1.0/overlay/MODULE.bazel
Empty file.
7 changes: 7 additions & 0 deletions modules/googleapis-python/0.1.0/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"integrity": "sha256-hznHbmgfkAkjuQDJ3w73XPQh05yrtUZQxLmtGbanbYU=",
"url": "https://github.com/fmeum/bazel-central-registry/releases/download/v1.0.0/empty.zip",
"overlay": {
"MODULE.bazel": "sha256-4Hlx29KheHuWdfrllIzz7aio1bHr7a2oe+VxNFPFoxM="
}
}
16 changes: 16 additions & 0 deletions modules/googleapis-python/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://github.com/googleapis/googleapis",
"maintainers": [
{
"email": "[email protected]",
"name": "No Maintainer Specified"
}
],
"repository": [
"github:googleapis/googleapis"
],
"versions": [
"0.1.0"
],
"yanked_versions": {}
}
11 changes: 11 additions & 0 deletions modules/googleapis/0.0.0-20241220-5e258e33/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module(
name = "googleapis",
version = "0.0.0-20241220-5e258e33",
repo_name = "com_google_googleapis",
bazel_compatibility = [">=7.2.1"],
)

bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

switched_rules = use_extension("//private/extensions:switched_rules.bzl", "switched_rules")
use_repo(switched_rules, "com_google_googleapis_imports")
30 changes: 30 additions & 0 deletions modules/googleapis/0.0.0-20241220-5e258e33/overlay/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
_use_languages_tag = tag_class(
attrs = {
"cc": attr.bool(default = False),
"csharp": attr.bool(default = False),
"gapic": attr.bool(default = False),
"go": attr.bool(default = False),
"go_test": attr.bool(default = False),
"grpc": attr.bool(default = False),
"java": attr.bool(default = False),
"nodejs": attr.bool(default = False),
"php": attr.bool(default = False),
"python": attr.bool(default = False),
"ruby": attr.bool(default = False),
},
)

def _switched_rules_impl(_ctx):
fail("""
The 'switched_rules' extension is no longer supported due to problems inherent to its design.
Instead, add 'bazel_dep(name = "googleapis-<lang>", version = "0.1.0")' to your MODULE.bazel file to use '<lang>_proto_library' targets in 'googleapis'.
To see error messages with the exact 'bazel_dep's to add, remove the 'switched_rules' usage and build your project.
The available individual modules can be found at https://registry.bazel.build/search?q=googleapis.
""")

switched_rules = module_extension(
implementation = _switched_rules_impl,
tag_classes = {
"use_languages": _use_languages_tag,
},
)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Maps rules used by googleapis to <flavor> if the rule is registered by the googleapis-<flavor>
# module or to None if the rule is not supported yet.
RULE_TO_FLAVOR = {
"cc_gapic_library": None,
"cc_grpc_library": None,
"cc_proto_library": "cc",
"csharp_gapic_assembly_pkg": None,
"csharp_gapic_library": None,
"csharp_grpc_library": None,
"csharp_proto_library": None,
"go_gapic_assembly_pkg": None,
"go_gapic_library": None,
"go_grpc_library": None,
"go_library": None,
"go_proto_library": "go",
"go_test": None,
"java_gapic_assembly_gradle_pkg": None,
"java_gapic_library": None,
"java_gapic_test": None,
"java_grpc_library": None,
"java_proto_library": "java",
"moved_proto_library": None,
"nodejs_gapic_assembly_pkg": None,
"nodejs_gapic_library": None,
"php_gapic_assembly_pkg": None,
"php_gapic_library": None,
"php_grpc_library": None,
"php_proto_library": None,
"proto_library_with_info": None,
"py_gapic_assembly_pkg": None,
"py_gapic_library": None,
"py_grpc_library": None,
"py_import": None,
"py_proto_library": "python",
"py_test": None,
"ruby_ads_gapic_library": None,
"ruby_cloud_gapic_library": None,
"ruby_gapic_assembly_pkg": None,
"ruby_grpc_library": None,
"ruby_proto_library": None,
}

# The version of the googleapis-<flavor> modules to recommend to users.
FLAVOR_VERSION = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def _fail_rule_impl(ctx):
fail(ctx.attr.message)

_fail_rule = rule(
implementation = _fail_rule_impl,
attrs = {
"message": attr.string(),
},
)

def make_fail_macro(message):
return lambda name, **kwargs: _fail_rule(name = name, message = message)
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
load(":constants.bzl", "FLAVOR_VERSION", "RULE_TO_FLAVOR")

def _imports_impl(repo_ctx):
loads = [
"""load("@com_google_googleapis//private/extensions:fail_macro.bzl", "make_fail_macro")""",
]
assignments = []

for name, file in repo_ctx.attr.rules.items():
if file:
loads.append("""load("{file}", _{name} = "{name}")""".format(
file = file,
name = name,
))
assignments.append("""{name} = _{name}""".format(
name = name,
))
else:
flavor = RULE_TO_FLAVOR[name]
if flavor:
message = """Add 'bazel_dep(name = "googleapis-{flavor}", version = "{flavor_version}")' to your MODULE.bazel file to use '{name}' targets in 'googleapis'.""".format(
flavor = flavor,
flavor_version = FLAVOR_VERSION,
name = name,
)
else:
message = """'{name} targets in googleapis are not supported with Bzlmod. If you need them, please file an issue at https://github.com/bazelbuild/bazel-central-registry.""".format(
name = name,
)
assignments.append("""{name} = make_fail_macro({message})""".format(
name = name,
message = repr(message),
))
imports_content = "\n".join(loads + assignments)

repo_ctx.file("BUILD.bazel")
repo_ctx.file("imports.bzl", imports_content)

_imports = repository_rule(
implementation = _imports_impl,
attrs = {
# Maps a name to a file label in unambiguous form.
"rules": attr.string_dict(),
},
)

def _io_bazel_rules_go_grpc_forwarder_impl(repo_ctx):
content = ""
if repo_ctx.attr.go_grpc_label:
content = """\
alias(
name = "go_grpc",
actual = "{go_grpc_label}",
visibility = ["//visibility:public"],
)
""".format(go_grpc_label = repo_ctx.attr.go_grpc_label)
repo_ctx.file("proto/BUILD.bazel", content)

_io_bazel_rules_go_grpc_forwarder = repository_rule(
implementation = _io_bazel_rules_go_grpc_forwarder_impl,
attrs = {
"go_grpc_label": attr.string(),
}
)

def _switched_rules_impl(module_ctx):
rules = {name: "" for name in RULE_TO_FLAVOR.keys()}

for module in module_ctx.modules:
if module.name != "googleapis" and not module.name.startswith("googleapis-"):
fail("This extension is internal to googleapis and cannot be accessed from " + module.name)
for rule in module.tags.register:
if rule.name not in rules:
fail("Unknown rule: %s" % rule.name)
if rules[rule.name]:
fail("Rule %s already registered" % rule.name)
rules[rule.name] = str(rule.file)

_imports(
name = "com_google_googleapis_imports",
rules = rules,
)

go_grpc_label = ""
go_proto_library_file = rules.get("go_proto_library")
if go_proto_library_file:
go_grpc_label = "@@{}//proto:go_grpc".format(Label(go_proto_library_file).workspace_name)
_io_bazel_rules_go_grpc_forwarder(
name = "io_bazel_rules_go",
go_grpc_label = go_grpc_label,
)

return module_ctx.extension_metadata(reproducible = True)

_register = tag_class(
attrs = {
"name": attr.string(),
"file": attr.label(),
},
)

switched_rules = module_extension(
implementation = _switched_rules_impl,
tag_classes = {
"register": _register,
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --java_runtime_version=remotejdk_11
Loading

0 comments on commit 8043e85

Please sign in to comment.