mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
d68d197948
* Disable scaladoc on the MacOS CI It is still built by default locally. fixes #4441 changelog_begin changelog_end * Change tag name
373 lines
11 KiB
Python
373 lines
11 KiB
Python
# Copyright (c) 2020 The DAML Authors. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
load("//bazel_tools:haskell.bzl", "da_haskell_library")
|
|
load("//bazel_tools:pkg.bzl", "pkg_tar")
|
|
load("//bazel_tools:proto.bzl", "proto_gen")
|
|
load("//bazel_tools:pom_file.bzl", "pom_file")
|
|
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
|
|
load(
|
|
"//bazel_tools:scala.bzl",
|
|
"scala_source_jar",
|
|
"scaladoc_jar",
|
|
)
|
|
load("@os_info//:os_info.bzl", "is_windows")
|
|
|
|
ledger_api_proto_source_root = "ledger-api/grpc-definitions"
|
|
|
|
proto_library(
|
|
name = "protos",
|
|
srcs = glob(["**/*.proto"]),
|
|
strip_import_prefix = "/" + ledger_api_proto_source_root,
|
|
visibility = [
|
|
"//visibility:public",
|
|
],
|
|
deps = [
|
|
"@com_github_googleapis_googleapis//google/rpc:status_proto",
|
|
"@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",
|
|
],
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "ledger-api-protos",
|
|
srcs = glob(["**/*.proto"]),
|
|
extension = "tar.gz",
|
|
strip_prefix = "./",
|
|
visibility = [
|
|
"//visibility:public",
|
|
],
|
|
)
|
|
|
|
# FIXME(#448): This has the same contents as `:ledger-api-protos` but a
|
|
# directory structure which is suitable for the SDK.
|
|
pkg_tar(
|
|
name = "ledger-api-protos-tarball",
|
|
srcs = glob(["**/*.proto"]),
|
|
extension = "tar.gz",
|
|
package_dir = "grpc-definitions",
|
|
strip_prefix = "./",
|
|
visibility = [
|
|
"//visibility:public",
|
|
],
|
|
)
|
|
|
|
proto_gen(
|
|
name = "ledger-api-scalapb-sources",
|
|
srcs = [
|
|
":protos",
|
|
"@com_github_googleapis_googleapis//google/rpc:code_proto",
|
|
"@com_github_googleapis_googleapis//google/rpc:status_proto",
|
|
"@com_github_grpc_grpc//src/proto/grpc/health/v1:health_proto_descriptor",
|
|
],
|
|
plugin_exec = "//scala-protoc-plugins/scalapb:protoc-gen-scalapb",
|
|
plugin_name = "scalapb",
|
|
plugin_options = ["grpc"],
|
|
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",
|
|
],
|
|
)
|
|
|
|
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",
|
|
],
|
|
)
|
|
|
|
google_rpc_src = "external/com_github_googleapis_googleapis"
|
|
|
|
genrule(
|
|
name = "google-rpc-haskellpb-sources",
|
|
srcs = [
|
|
"@com_github_googleapis_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",
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "ledger-api-protos-fg",
|
|
srcs = glob(["com/digitalasset/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",
|
|
"TraceContext.hs",
|
|
"Transaction.hs",
|
|
"TransactionFilter.hs",
|
|
"TransactionService.hs",
|
|
"Value.hs",
|
|
]
|
|
|
|
genrule(
|
|
name = "ledger-api-haskellpb-sources",
|
|
srcs = [
|
|
"@com_google_protobuf//:well_known_protos",
|
|
"@com_github_googleapis_googleapis//google/rpc:status.proto",
|
|
":ledger-api-protos-fg",
|
|
],
|
|
outs = ["Com/Digitalasset/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/digitalasset/ledger/api/v1/$$(basename $$src) \
|
|
--out $(@D)
|
|
done
|
|
""",
|
|
tools = [
|
|
"@proto3_suite//:compile-proto-file",
|
|
],
|
|
)
|
|
|
|
filegroup(
|
|
name = "ledger-api-protos-fg-testing",
|
|
srcs = glob(["com/digitalasset/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",
|
|
"@com_github_googleapis_googleapis//google/rpc:status.proto",
|
|
":ledger-api-protos-fg-testing",
|
|
],
|
|
outs = ["Com/Digitalasset/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/digitalasset/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/digitalasset/ledger/api/v1/admin/*.proto"]),
|
|
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",
|
|
"@com_github_googleapis_googleapis//google/rpc:status.proto",
|
|
":ledger-api-protos-fg-admin",
|
|
],
|
|
outs = ["Com/Digitalasset/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/digitalasset/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"],
|
|
)
|
|
|
|
scala_library(
|
|
name = "ledger-api-scalapb",
|
|
srcs = [":ledger-api-scalapb-sources"],
|
|
tags = [
|
|
"maven_coordinates=com.digitalasset.ledger-api.grpc-definitions:ledger-api-scalapb:__VERSION__",
|
|
],
|
|
unused_dependency_checker_mode = "error",
|
|
visibility = ["//visibility:public"],
|
|
exports = [
|
|
"@maven//:com_google_protobuf_protobuf_java",
|
|
"@maven//:com_thesamet_scalapb_lenses_2_12",
|
|
"@maven//:com_thesamet_scalapb_scalapb_runtime_2_12",
|
|
"@maven//:com_thesamet_scalapb_scalapb_runtime_grpc_2_12",
|
|
"@maven//:io_grpc_grpc_api",
|
|
"@maven//:io_grpc_grpc_core",
|
|
"@maven//:io_grpc_grpc_protobuf",
|
|
"@maven//:io_grpc_grpc_stub",
|
|
],
|
|
deps = [
|
|
"@maven//:com_google_protobuf_protobuf_java",
|
|
"@maven//:com_thesamet_scalapb_lenses_2_12",
|
|
"@maven//:com_thesamet_scalapb_scalapb_runtime_2_12",
|
|
"@maven//:com_thesamet_scalapb_scalapb_runtime_grpc_2_12",
|
|
"@maven//:io_grpc_grpc_api",
|
|
"@maven//:io_grpc_grpc_core",
|
|
"@maven//:io_grpc_grpc_protobuf",
|
|
"@maven//:io_grpc_grpc_stub",
|
|
],
|
|
)
|
|
|
|
pom_file(
|
|
name = "ledger-api-scalapb_pom",
|
|
target = ":ledger-api-scalapb",
|
|
)
|
|
|
|
# Create empty Scaladoc JAR for uploading to Maven Central
|
|
scaladoc_jar(
|
|
name = "ledger-api-scalapb_scaladoc",
|
|
srcs = [],
|
|
tags = ["scaladoc"],
|
|
deps = [],
|
|
) if is_windows == False else None
|
|
|
|
# Create empty Sources JAR for uploading to Maven Central
|
|
scala_source_jar(
|
|
name = "ledger-api-scalapb_src",
|
|
srcs = [],
|
|
)
|
|
|
|
proto_gen(
|
|
name = "ledger-api-docs",
|
|
srcs = [":protos"],
|
|
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",
|
|
],
|
|
deps = [
|
|
"@com_github_googleapis_googleapis//google/rpc:code_proto",
|
|
"@com_github_googleapis_googleapis//google/rpc:status_proto",
|
|
"@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",
|
|
],
|
|
)
|
|
|
|
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"],
|
|
)
|