blob: f924f2f36c133658b3926276529f02dd4e099c30 [file] [log] [blame]
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
load("@rules_java//java:defs.bzl", "java_library")
load(":extractors.bzl", "extractor_action")
package(default_visibility = ["//visibility:public"])
exports_files(["extractors.bzl"])
# Clone of default Java proto toolchain with "annotate_code" enabled for
# cross-language metadata file generation.
#
# --proto_toolchain_for_java=@io_kythe//kythe/extractors:java_proto_toolchain
proto_lang_toolchain(
name = "java_proto_toolchain",
command_line = "--java_out=annotate_code:$(OUT)",
runtime = ":protobuf_java",
)
# Clone of the java protobuf runtime that also exposes jsr250 so the generated
# proto classes with our inserted annotations can be compiled.
java_library(
name = "protobuf_java",
exports = [
"@com_google_protobuf//:protobuf_java",
"@maven//:org_apache_tomcat_tomcat_annotations_api",
],
)
# Clone of default C++ proto toolchain with "annotate_headers" enabled for
# cross-language metadata file generation.
#
# In order to work around the difficulty of plumbing additional files through
# the C++ rules, we use a plugin which embeds the metadata generated by protoc
# directly at the end of the respective headers.
#
# --proto_toolchain_for_cc=@io_kythe//kythe/extractors:cc_proto_toolchain
proto_lang_toolchain(
name = "cc_proto_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--$(PLUGIN_OUT)=:$(OUT)",
plugin = "//kythe/cxx/tools:proto_metadata_plugin",
runtime = "@com_google_protobuf//:protobuf",
)
# Alternatively, if the plugin doesn't work you can use the default code generator
# to output the metadata into a separate file. This needs to be invoked with:
#
# bazel build \
# --proto_toolchain_for_cc=@io_kythe//kythe/extractor:cc_native_proto_toolchain \
# --cc_proto_library_header_suffixes=.pb.h,.pb.h.meta
proto_lang_toolchain(
name = "cc_native_proto_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=annotate_headers,annotation_pragma_name=kythe_metadata,annotation_guard_name=KYTHE_IS_RUNNING:$(OUT)",
runtime = "@com_google_protobuf//:protobuf",
)
extractor_action(
name = "extract_kzip_cxx",
args = [
"$(EXTRA_ACTION_FILE)",
"$(output $(ACTION_ID).cxx.kzip)",
"$(location //external:vnames_config)",
],
data = ["//external:vnames_config"],
extractor = "@io_kythe//kythe/cxx/extractor:cxx_extractor_bazel",
mnemonics = ["CppCompile"],
output = "$(ACTION_ID).cxx.kzip",
)
extractor_action(
name = "extract_kzip_java",
args = [
"$(EXTRA_ACTION_FILE)",
"$(output $(ACTION_ID).java.kzip)",
"$(location //external:vnames_config)",
],
data = ["//external:vnames_config"],
extractor = "@io_kythe//kythe/java/com/google/devtools/kythe/extractors/java/bazel:java_extractor",
mnemonics = ["Javac"],
output = "$(ACTION_ID).java.kzip",
)
# We only support Bazel rules_go 0.19.0 and up.
extractor_action(
name = "extract_kzip_go",
args = [
"-corpus kythe.io",
"$(EXTRA_ACTION_FILE)",
"$(output $(ACTION_ID).go.kzip)",
"$(location //external:vnames_config)",
],
data = ["//external:vnames_config"],
extractor = "@io_kythe//kythe/go/extractors/cmd/bazel:bazel_go_extractor",
mnemonics = ["GoCompilePkg"],
output = "$(ACTION_ID).go.kzip",
)
extractor_action(
name = "extract_kzip_jvm",
args = [
"$(EXTRA_ACTION_FILE)",
"$(output $(ACTION_ID).jvm.kzip)",
"$(location //external:vnames_config)",
],
data = ["//external:vnames_config"],
extractor = "@io_kythe//kythe/java/com/google/devtools/kythe/extractors/jvm/bazel:bazel_jvm_extractor",
mnemonics = ["JavaIjar"],
output = "$(ACTION_ID).jvm.kzip",
)
extractor_action(
name = "extract_kzip_objc",
args = [
"$(EXTRA_ACTION_FILE)",
"$(output $(ACTION_ID).objc.kzip)",
"$(location //external:vnames_config)",
"$(location //third_party/bazel:get_devdir)",
"$(location //third_party/bazel:get_sdkroot)",
],
data = [
"//external:vnames_config",
"//third_party/bazel:get_devdir",
"//third_party/bazel:get_sdkroot",
],
extractor = "@io_kythe//kythe/cxx/extractor:objc_extractor_bazel",
mnemonics = ["ObjcCompile"],
output = "$(ACTION_ID).objc.kzip",
)
extractor_action(
name = "extract_typescript_kzip",
args = [
"--extra_action=$(EXTRA_ACTION_FILE)",
"--include='\\.(js|json|tsx?|d\\.ts)$$'",
"--language=typescript",
"--output=$(output $(ACTION_ID).typescript.kzip)",
"--rules=$(location //external:vnames_config)",
"--scoped=true",
"--source='\\.ts$$'",
],
data = ["//external:vnames_config"],
extractor = "@io_kythe//kythe/go/extractors/cmd/bazel:extract_kzip",
mnemonics = [
"TypeScriptCompile",
"AngularTemplateCompile",
],
output = "$(ACTION_ID).typescript.kzip",
)
extractor_action(
name = "extract_kzip_protobuf",
args = [
"--extra_action=$(EXTRA_ACTION_FILE)",
"--language=protobuf",
"--rules=$(location //external:vnames_config)",
"--output=$(output $(ACTION_ID).protobuf.kzip)",
],
data = ["//external:vnames_config"],
extractor = "//kythe/go/extractors/proto:extract_proto_kzip",
mnemonics = ["GenProtoDescriptorSet"],
output = "$(ACTION_ID).protobuf.kzip",
)
extractor_action(
name = "extract_kzip_rust",
args = [
"--extra_action=$(EXTRA_ACTION_FILE)",
"--output=$(output $(ACTION_ID).rust.kzip)",
"--vnames_config=$(location //external:vnames_config)",
],
data = ["//external:vnames_config"],
extractor = "@io_kythe//kythe/rust/extractor:extractor_script",
mnemonics = [
"Rustc",
],
output = "$(ACTION_ID).rust.kzip",
)
bzl_library(
name = "extractors_bzl",
srcs = ["extractors.bzl"],
)