daml/daml-lf/archive/BUILD.bazel
Gerolf Seitz cadaa59ad8
Fix redirects, java-bindings javadoc, and live-preview.sh (#5446)
* Fix redirects, java-bindings javadoc, and live-preview.sh

- javadoc_library now supports sources from filegroups as well
- //language-support/java:javadoc now generates javadoc for ledger-api, java bindings, rxjava bindings
- live-preview.sh refers to the correct javadoc target //language-support/java:javadoc
- removed leading / from redirects.map

* Only generate daml-lf javadocs if not on windows

CHANGELOG_BEGIN
CHANGELOG_END
2020-04-07 09:53:26 +02:00

229 lines
7.9 KiB
Python

# Copyright (c) 2020 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:pkg.bzl", "pkg_tar")
load("//bazel_tools:proto.bzl", "proto_gen")
load(
"//bazel_tools:scala.bzl",
"da_scala_binary",
"da_scala_library",
"da_scala_test_suite",
"lf_scalacopts",
)
load(
"//rules_daml:daml.bzl",
"daml_compile",
"daml_compile_with_dalf",
)
load("//bazel_tools:pom_file.bzl", "pom_file")
load("@os_info//:os_info.bzl", "is_windows")
load("//bazel_tools:javadoc_library.bzl", "javadoc_library")
load(":archive.bzl", "mangle_for_java")
load("//daml-lf/language:daml-lf.bzl", "LF_MAJOR_VERSIONS", "LF_VERSIONS", "lf_version_package")
[
[
filegroup(
name = "daml_lf_%s_archive_proto_srcs" % version,
srcs = glob([
"src/main/protobuf/com/{package}/daml_lf_{version}/*.proto".format(
package = lf_version_package(version),
version = mangle_for_java(version),
),
]),
),
proto_library(
name = "daml_lf_%s_archive_proto" % version,
srcs = [":daml_lf_%s_archive_proto_srcs" % version],
strip_import_prefix = "src/main/protobuf/",
visibility = ["//:__subpackages__"],
),
proto_gen(
name = "daml_lf_%s_archive_java_proto_srcs" % version,
srcs = [":daml_lf_%s_archive_proto" % version],
plugin_name = "java",
visibility = ["//visibility:public"],
),
java_library(
name = "daml_lf_%s_archive_java_proto" % version,
srcs = [":daml_lf_%s_archive_java_proto_srcs" % version],
tags = ["maven_coordinates=com.daml:daml-lf-%s-archive-java-proto:__VERSION__" % version],
visibility = ["//visibility:public"],
deps = ["@maven//:com_google_protobuf_protobuf_java"],
),
pom_file(
name = "daml_lf_%s_archive_java_proto_pom" % version,
target = "daml_lf_%s_archive_java_proto" % version,
visibility = ["//visibility:public"],
),
javadoc_library(
name = "daml_lf_%s_archive_java_proto_javadoc" % version,
srcs = ["daml_lf_%s_archive_java_proto" % version],
root_packages = [
"com.{package}.daml_lf_{version}".format(
package = lf_version_package(version),
version = mangle_for_java(version),
),
],
visibility = ["//visibility:public"],
deps = ["@maven//:com_google_protobuf_protobuf_java"],
) if not is_windows else None,
genrule(
name = "daml_lf_%s_archive_proto_zip" % version,
srcs = [":daml_lf_%s_archive_proto_srcs" % version],
outs = ["daml_lf_%s_archive_proto_zip.zip" % version],
cmd = """
DESTDIR=protobuf/com/{package}/daml_lf_{version};
MAPPINGS=()
for src in $(SRCS); do
MAPPINGS+=("$$DESTDIR/$$(basename $$src)=$$src")
done
$(rootpath @bazel_tools//tools/zip:zipper) cC "$@" "$${{MAPPINGS[@]}}"
""".format(
package = lf_version_package(version),
version = mangle_for_java(version),
),
tools = ["@bazel_tools//tools/zip:zipper"],
visibility = ["//visibility:public"],
),
pkg_tar(
name = "daml_lf_%s_archive_proto_tarball" % version,
srcs = [":daml_lf_%s_archive_proto_srcs" % version],
extension = "tar.gz",
package_dir = "com/{package}/daml_lf_{version}".format(
package = lf_version_package(version),
version = mangle_for_java(version),
),
visibility = ["//visibility:public"],
),
]
for version in LF_VERSIONS
]
# FIXME(JM): Clean this up
genrule(
name = "daml_lf_dev_archive_haskell_proto_src",
srcs = ["daml_lf_dev_archive_proto_srcs"],
outs = ["Com/Daml/DamlLfDev/DamlLf.hs"] +
["Com/Daml/DamlLfDev/DamlLf%s.hs" % v.title() for v in LF_MAJOR_VERSIONS],
cmd =
"\n".join(
[
"""
$(location @proto3_suite//:compile-proto-file) \
--includeDir daml-lf/archive/src/main/protobuf/ \
--proto com/daml/daml_lf_dev/daml_lf%s.proto \
--out $(@D)
""" % vx
for vx in [""] + ["_%s" % v for v in LF_MAJOR_VERSIONS]
],
),
tools = [
"@proto3_suite//:compile-proto-file",
],
)
da_haskell_library(
name = "daml_lf_dev_archive_haskell_proto",
srcs = [":daml_lf_dev_archive_haskell_proto_src"],
compiler_flags = ["-O0"], # disable optimization as this is otherwise way too slow to compile.
hackage_deps = [
"base",
"bytestring",
"containers",
"deepseq",
"proto3-suite",
"proto3-wire",
"text",
"vector",
],
visibility = ["//visibility:public"],
)
da_scala_library(
name = "daml_lf_archive_reader",
srcs = glob(["src/main/scala/**/*.scala"]),
scalacopts = lf_scalacopts,
tags = ["maven_coordinates=com.daml:daml-lf-archive-reader:__VERSION__"],
visibility = ["//visibility:public"],
deps = [
":daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/language",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:org_scalaz_scalaz_core_2_12",
],
)
da_scala_test_suite(
name = "daml_lf_archive_reader_tests",
size = "small",
srcs = glob(
["src/test/scala/**/*.scala"],
exclude = ["src/test/scala/com/digitalasset/daml/lf/archive/ZipBombDetectionSpec.scala"],
),
data = [
":DarReaderTest.dalf",
":DarReaderTest.dar",
":daml_lf_1.6_archive_proto_srcs",
":daml_lf_1.7_archive_proto_srcs",
":daml_lf_1.8_archive_proto_srcs",
],
scalacopts = lf_scalacopts,
deps = [
":daml_lf_1.6_archive_java_proto",
":daml_lf_1.7_archive_java_proto",
":daml_lf_1.8_archive_java_proto",
":daml_lf_archive_reader",
":daml_lf_dev_archive_java_proto",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/data",
"//daml-lf/data-scalacheck",
"//daml-lf/language",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:org_scalacheck_scalacheck_2_12",
"@maven//:org_scalatest_scalatest_2_12",
"@maven//:org_scalaz_scalaz_core_2_12",
"@maven//:org_scalaz_scalaz_scalacheck_binding_2_12",
],
)
da_scala_test_suite(
name = "daml_lf_archive_reader_zipbomb_tests",
srcs = ["src/test/scala/com/digitalasset/daml/lf/archive/ZipBombDetectionSpec.scala"],
data = [
":DarReaderTest.dar",
],
scalacopts = lf_scalacopts,
deps = [
":daml_lf_1.6_archive_java_proto",
":daml_lf_1.7_archive_java_proto",
":daml_lf_1.8_archive_java_proto",
":daml_lf_archive_reader",
":daml_lf_dev_archive_java_proto",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/data",
"@maven//:com_google_protobuf_protobuf_java",
],
)
daml_compile_with_dalf(
name = "DarReaderTest",
srcs = ["src/test/daml/DarReaderTest.daml"],
)
# An ad-hoc tool for testing, benchmarking and profiling package decoding performance in isolation.
da_scala_binary(
name = "decode-tester",
srcs = ["src/test/scala/com/digitalasset/daml/lf/archive/DecodeMain.scala"],
main_class = "com.daml.lf.archive.DecodeMain",
deps = [
":daml_lf_archive_reader",
":daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/language",
"@maven//:com_google_protobuf_protobuf_java",
],
)