daml/ledger-api/grpc-definitions/BUILD.bazel
Gary Verhaegen d2e2c21684
update copyright headers (#12240)
New year, new copyright, new expected unknown issues with various files
that won't be covered by the script and/or will be but shouldn't change.

I'll do the details on Jan 1, but would appreciate this being
preapproved so I can actually get it merged by then.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-03 16:36:51 +00:00

273 lines
8.2 KiB
Python

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:haskell.bzl", "da_haskell_library")
load("//bazel_tools:proto.bzl", "proto_gen", "proto_jars")
load(
"//bazel_tools:scala.bzl",
"scala_source_jar",
"scaladoc_jar",
)
load("@os_info//:os_info.bzl", "is_windows")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
ledger_api_proto_source_root = "ledger-api/grpc-definitions"
proto_jars(
name = "ledger_api_proto",
srcs = glob(["**/*.proto"]),
grpc = True,
maven_artifact_prefix = "ledger-api",
maven_artifact_scala_suffix = "scalapb",
maven_group = "com.daml",
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@go_googleapis//google/rpc:errdetails_proto",
"@go_googleapis//google/rpc:status_proto",
],
)
google_protobuf_src = "external/com_google_protobuf/src"
genrule(
name = "google-protobuf-haskellpb-sources",
srcs = ["@com_google_protobuf//:well_known_protos"],
outs = ["Google/Protobuf/" + b for b in [
"Any.hs",
"Duration.hs",
"Empty.hs",
"Timestamp.hs",
"Wrappers.hs",
]],
cmd = """
for src in \
external/com_google_protobuf/src/google/protobuf/any.proto \
external/com_google_protobuf/src/google/protobuf/duration.proto \
external/com_google_protobuf/src/google/protobuf/empty.proto \
external/com_google_protobuf/src/google/protobuf/timestamp.proto \
external/com_google_protobuf/src/google/protobuf/wrappers.proto \
; do
$(location @proto3-suite//:compile-proto-file) \
--includeDir """ + google_protobuf_src + """ \
--proto google/protobuf/$$(basename $$src) \
--out $(@D)
done
""",
tools = [
"@proto3-suite//:compile-proto-file",
],
visibility = ["//visibility:public"],
)
google_rpc_src = "external/go_googleapis"
genrule(
name = "google-rpc-haskellpb-sources",
srcs = [
"@go_googleapis//google/rpc:status.proto",
"@com_google_protobuf//:well_known_protos",
],
outs = ["Google/Rpc/Status.hs"],
cmd = """
$(location @proto3-suite//:compile-proto-file) \
--includeDir """ + google_protobuf_src + """ \
--includeDir """ + google_rpc_src + """ \
--proto google/rpc/status.proto \
--out $$(dirname $$(dirname $(@D)))
#2x dirname because @D works differently for a single output
""",
tools = [
"@proto3-suite//:compile-proto-file",
],
visibility = ["//visibility:public"],
)
filegroup(
name = "ledger-api-protos-fg",
srcs = glob(["com/daml/ledger/api/v1/*.proto"]),
visibility = ["//visibility:private"],
)
ledger_api_haskellpb_sources = [
"ActiveContractsService.hs",
"CommandCompletionService.hs",
"CommandService.hs",
"CommandSubmissionService.hs",
"Commands.hs",
"Completion.hs",
"Event.hs",
"LedgerConfigurationService.hs",
"LedgerIdentityService.hs",
"LedgerOffset.hs",
"PackageService.hs",
"Transaction.hs",
"TransactionFilter.hs",
"TransactionService.hs",
"Value.hs",
]
genrule(
name = "ledger-api-haskellpb-sources",
srcs = [
"@com_google_protobuf//:well_known_protos",
"@go_googleapis//google/rpc:status.proto",
":ledger-api-protos-fg",
],
outs = ["Com/Daml/Ledger/Api/V1/" + b for b in ledger_api_haskellpb_sources],
cmd = """
for src in $(locations :ledger-api-protos-fg); do
$(location @proto3-suite//:compile-proto-file) \
--includeDir """ + google_protobuf_src + """ \
--includeDir """ + google_rpc_src + """ \
--includeDir """ + ledger_api_proto_source_root + """ \
--proto com/daml/ledger/api/v1/$$(basename $$src) \
--out $(@D)
done
""",
tools = [
"@proto3-suite//:compile-proto-file",
],
)
filegroup(
name = "ledger-api-protos-fg-testing",
srcs = glob(["com/daml/ledger/api/v1/testing/*.proto"]),
visibility = ["//visibility:private"],
)
ledger_api_haskellpb_sources_testing = [
"ResetService.hs",
"TimeService.hs",
]
genrule(
name = "ledger-api-haskellpb-sources-testing",
srcs = [
"@com_google_protobuf//:well_known_protos",
"@go_googleapis//google/rpc:status.proto",
":ledger-api-protos-fg-testing",
],
outs = ["Com/Daml/Ledger/Api/V1/Testing/" + b for b in ledger_api_haskellpb_sources_testing],
cmd = """
for src in $(locations :ledger-api-protos-fg-testing); do
$(location @proto3-suite//:compile-proto-file) \
--includeDir """ + google_protobuf_src + """ \
--includeDir """ + google_rpc_src + """ \
--includeDir """ + ledger_api_proto_source_root + """ \
--proto com/daml/ledger/api/v1/testing/$$(basename $$src) \
--out $(@D)
done
""",
tools = [
"@proto3-suite//:compile-proto-file",
],
)
filegroup(
name = "ledger-api-protos-fg-admin",
srcs = glob(
["com/daml/ledger/api/v1/admin/*.proto"],
exclude = ["com/daml/ledger/api/v1/admin/participant_pruning_service.proto"], # TODO: haskell grpc client for participant pruning
),
visibility = ["//visibility:private"],
)
ledger_api_haskellpb_sources_admin = [
"PackageManagementService.hs",
"PartyManagementService.hs",
]
genrule(
name = "ledger-api-haskellpb-sources-admin",
srcs = [
"@com_google_protobuf//:well_known_protos",
"@go_googleapis//google/rpc:status.proto",
":ledger-api-protos-fg-admin",
],
outs = ["Com/Daml/Ledger/Api/V1/Admin/" + b for b in ledger_api_haskellpb_sources_admin],
cmd = """
for src in $(locations :ledger-api-protos-fg-admin); do
$(location @proto3-suite//:compile-proto-file) \
--includeDir """ + google_protobuf_src + """ \
--includeDir """ + google_rpc_src + """ \
--includeDir """ + ledger_api_proto_source_root + """ \
--proto com/daml/ledger/api/v1/admin/$$(basename $$src) \
--out $(@D)
done
""",
tools = [
"@proto3-suite//:compile-proto-file",
],
)
filegroup(
name = "all-ledger-api-haskellpb-sources",
srcs = [
":google-protobuf-haskellpb-sources",
":google-rpc-haskellpb-sources",
":ledger-api-haskellpb-sources",
":ledger-api-haskellpb-sources-admin",
":ledger-api-haskellpb-sources-testing",
],
visibility = ["//visibility:public"],
)
da_haskell_library(
name = "ledger-api-haskellpb",
srcs = [
":all-ledger-api-haskellpb-sources",
],
compiler_flags = [
"-O0",
],
hackage_deps = [
"base",
"bytestring",
"containers",
"deepseq",
"grpc-haskell",
"grpc-haskell-core",
"proto3-suite",
"proto3-wire",
"text",
"vector",
],
visibility = ["//visibility:public"],
)
proto_gen(
name = "ledger-api-docs",
srcs = [":ledger_api_proto"],
plugin_exec = "@com_github_pseudomuto_protoc_gen_doc//cmd/protoc-gen-doc:protoc-gen-doc",
plugin_name = "doc",
plugin_options = [
ledger_api_proto_source_root + "/rst_mmd.tmpl",
"docs.rst",
],
# this is _slightly_ hacky. we need to include the markdown template in the plugin_runfiles
# and refer to the file with a workspace relative path in plugin_options
plugin_runfiles = ["rst_mmd.tmpl"],
visibility = [
"//visibility:public",
],
)
genrule(
name = "docs",
srcs = [":ledger-api-docs"],
outs = ["proto-docs.rst"],
cmd = """
unzip -q $(location :ledger-api-docs)
$(location post-process.sh)
mv docs.rst '$@'
""",
tools = ["post-process.sh"],
visibility = ["//visibility:public"],
)