-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f5c742
commit 94b1def
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module( | ||
name = "com_google_googleapis", | ||
version = "0.0.1", | ||
) | ||
|
||
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf") | ||
bazel_dep(name = "rules_proto", version = "5.3.0-21.7") | ||
|
||
switched_rules = use_extension("//:extensions.bzl", "switched_rules") | ||
switched_rules.use_languages( | ||
cc = True, | ||
csharp = True, | ||
gapic = True, | ||
go = True, | ||
grpc = True, | ||
java = True, | ||
nodejs = True, | ||
php = True, | ||
python = True, | ||
ruby = True, | ||
) | ||
use_repo(switched_rules, "com_google_googleapis_imports") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# When Bzlmod is enabled, this file replaces the content of the original WORKSPACE | ||
# and makes sure no WORKSPACE prefix or suffix are added when Bzlmod is enabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
load(":repository_rules.bzl", "switched_rules_by_language") | ||
|
||
_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): | ||
attrs = {} | ||
for module in ctx.modules: | ||
if not module.is_root: | ||
continue | ||
|
||
for t in module.tags.use_languages: | ||
attrs = { | ||
"cc": t.cc, | ||
"csharp": t.csharp, | ||
"gapic": t.gapic, | ||
"go": t.go, | ||
"go_test": t.go_test, | ||
"grpc": t.grpc, | ||
"java": t.java, | ||
"nodejs": t.nodejs, | ||
"php": t.php, | ||
"python": t.python, | ||
"ruby": t.ruby, | ||
} | ||
|
||
switched_rules_by_language( | ||
name = "com_google_googleapis_imports", | ||
**attrs | ||
) | ||
|
||
switched_rules = module_extension( | ||
implementation = _switched_rules_impl, | ||
tag_classes = { | ||
"use_languages": _use_languages_tag, | ||
}, | ||
) |