daml/daml-lf/archive/BUILD.bazel

234 lines
6.6 KiB
Python
Raw Normal View History

2019-04-04 11:33:38 +03:00
# Copyright (c) 2019 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_library",
"da_scala_test_suite",
"lf_scalacopts",
2019-04-04 11:33:38 +03:00
)
load(
"//rules_daml:daml.bzl",
"daml_compile",
2019-04-04 11:33:38 +03:00
)
load("//bazel_tools:pom_file.bzl", "pom_file")
2019-04-04 11:33:38 +03:00
load("@os_info//:os_info.bzl", "is_windows")
load("//bazel_tools:javadoc_library.bzl", "javadoc_library")
2019-04-04 11:33:38 +03:00
LF_MAJOR_VERSIONS = [
"0",
"1",
]
2019-04-04 11:33:38 +03:00
filegroup(
name = "daml-lf-archive-srcs",
srcs = ["da/daml_lf.proto"] + ["da/daml_lf_%s.proto" % v for v in LF_MAJOR_VERSIONS],
visibility = ["//visibility:public"],
)
exports_files(
["da/daml_lf_%s.proto" % v for v in LF_MAJOR_VERSIONS],
2019-04-04 11:33:38 +03:00
)
proto_library(
name = "daml_lf_proto",
srcs = [":daml-lf-archive-srcs"],
proto_source_root = "daml-lf/archive",
visibility = ["//:__subpackages__"],
2019-04-04 11:33:38 +03:00
)
proto_gen(
name = "daml_lf_java_proto_srcs",
srcs = [":daml_lf_proto"],
plugin_name = "java",
2019-04-04 11:33:38 +03:00
)
java_library(
name = "daml_lf_java_proto",
srcs = [":daml_lf_java_proto_srcs"],
tags = ["maven_coordinates=com.digitalasset:daml-lf-archive:__VERSION__"],
visibility = ["//visibility:public"],
exports = ["//3rdparty/jvm/com/google/protobuf:protobuf_java"],
deps = ["//3rdparty/jvm/com/google/protobuf:protobuf_java"],
2019-04-04 11:33:38 +03:00
)
# FIXME(JM): Clean this up
genrule(
name = "daml_lf_haskell_proto_src",
srcs = glob(["da/*.proto"]),
outs = ["Da/DamlLf.hs"] + ["Da/DamlLf%s.hs" % v.title() for v in LF_MAJOR_VERSIONS],
cmd =
"ORIGPWD=`pwd`\ncd daml-lf/archive\n" +
"\n".join(
[
"$$ORIGPWD/$(location @haskell_proto3__suite//:compile-proto-file) --proto da/daml_lf%s.proto --out $$ORIGPWD/$(@D)" % vx
for vx in [""] + ["_%s" % v for v in LF_MAJOR_VERSIONS]
],
),
tools = [
"@haskell_proto3__suite//:compile-proto-file",
],
2019-04-04 11:33:38 +03:00
)
da_haskell_library(
name = "daml_lf_haskell_proto",
srcs = [":daml_lf_haskell_proto_src"],
compiler_flags = ["-O0"], # disable optimization as this is otherwise way too slow to compile.
hazel_deps = [
"base",
"bytestring",
"containers",
"deepseq",
"proto3-suite",
"proto3-wire",
"text",
"vector",
],
visibility = ["//visibility:public"],
2019-04-04 11:33:38 +03:00
)
da_scala_library(
name = "daml_lf_archive_scala",
srcs = glob(["src/main/**/*.scala"]),
scalacopts = lf_scalacopts,
tags = ["maven_coordinates=com.digitalasset:daml-lf-archive-scala:__VERSION__"],
visibility = ["//visibility:public"],
deps = [
":daml_lf_java_proto",
"//3rdparty/jvm/com/google/protobuf:protobuf_java",
"//3rdparty/jvm/org/scalaz:scalaz_core",
"//daml-lf/data",
"//daml-lf/language",
],
2019-04-04 11:33:38 +03:00
)
da_scala_test_suite(
name = "daml_lf_archive_scala_tests",
size = "small",
srcs = glob(["src/test/**/*.scala"]),
data = [
":DarReaderTest.dalf",
":DarReaderTest.dar",
intern package IDs in LF (#1614) * specify the new fields for interning package IDs * percolating intern tables * crawl packages for package IDs as a pre-phase: generic prep * stub case for interned_id in Scala packageref reader * HasPackageRefs instances for the rest of the ast * make intern table and use when encoding PackageRefs in v1 * don't need where * stub out decode for interned package IDs * no benefit to using uint32 instead of uint64 * percolate in encode one step * interned case for decoding PackageRefs * naming details * intern table decoder * finish propagating the intern table in encoder * encode the package ID table * document the vital assumption of encodeInternedPackageIds * propagate the intern table through the LF decoder - done by stacking ReaderT on top of Decode internally, as discussed with @hurryabit * daml-lf-proto requires mtl * stub out interned case in Scala LF decoder * stub interface decoder function * get the interned table to most places in InterfaceReader * support for interned package IDs in Scala decoder * use ImmArraySeq instead of Vector for Scala intern decode table * adding that ghc extension didn't make sense * implement interned ID decoding for InterfaceReader * scenario service won't have interned package IDs * test the interned ID resolution in Scala by examining the proto -> AST in detail * proper precondition for the dev phase of interned IDs testing * better error reporting for malformed DALFs in intern test * just import Data.Int - suggested by @neil-da; thanks * pass around the lookup function instead of the vector in decoder - suggested by @neil-da; thanks * remove derivations for types deleted in e63b012d2d * rename VersionAware to EncodeCtx - suggested by @hurryabit; thanks * rename MDecode to MonadDecode - suggested by @hurryabit; thanks * pass a function through the encoder instead of a set - based on suggestions by @hurryabit and @neil-da; thanks * daml-ghc test that interned IDs are generated - suggested by @hurryabit; thanks * adapt to 5b480c99ec #1844
2019-06-26 12:15:24 +03:00
":DarReaderTest-dev.dalf",
],
scalacopts = lf_scalacopts,
deps = [
":daml_lf_archive_scala",
":daml_lf_java_proto",
"//3rdparty/jvm/com/google/protobuf:protobuf_java",
"//3rdparty/jvm/org/scalacheck",
"//3rdparty/jvm/org/scalatest",
"//3rdparty/jvm/org/scalaz:scalaz_core",
"//3rdparty/jvm/org/scalaz:scalaz_scalacheck_binding",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/data",
"//daml-lf/language",
"//daml-lf/parser",
"//daml-lf/validation",
],
2019-04-04 11:33:38 +03:00
)
daml_compile(
name = "DarReaderTest",
main_src = "src/test/daml/DarReaderTest.daml",
2019-04-04 11:33:38 +03:00
)
intern package IDs in LF (#1614) * specify the new fields for interning package IDs * percolating intern tables * crawl packages for package IDs as a pre-phase: generic prep * stub case for interned_id in Scala packageref reader * HasPackageRefs instances for the rest of the ast * make intern table and use when encoding PackageRefs in v1 * don't need where * stub out decode for interned package IDs * no benefit to using uint32 instead of uint64 * percolate in encode one step * interned case for decoding PackageRefs * naming details * intern table decoder * finish propagating the intern table in encoder * encode the package ID table * document the vital assumption of encodeInternedPackageIds * propagate the intern table through the LF decoder - done by stacking ReaderT on top of Decode internally, as discussed with @hurryabit * daml-lf-proto requires mtl * stub out interned case in Scala LF decoder * stub interface decoder function * get the interned table to most places in InterfaceReader * support for interned package IDs in Scala decoder * use ImmArraySeq instead of Vector for Scala intern decode table * adding that ghc extension didn't make sense * implement interned ID decoding for InterfaceReader * scenario service won't have interned package IDs * test the interned ID resolution in Scala by examining the proto -> AST in detail * proper precondition for the dev phase of interned IDs testing * better error reporting for malformed DALFs in intern test * just import Data.Int - suggested by @neil-da; thanks * pass around the lookup function instead of the vector in decoder - suggested by @neil-da; thanks * remove derivations for types deleted in e63b012d2d * rename VersionAware to EncodeCtx - suggested by @hurryabit; thanks * rename MDecode to MonadDecode - suggested by @hurryabit; thanks * pass a function through the encoder instead of a set - based on suggestions by @hurryabit and @neil-da; thanks * daml-ghc test that interned IDs are generated - suggested by @hurryabit; thanks * adapt to 5b480c99ec #1844
2019-06-26 12:15:24 +03:00
daml_compile(
name = "DarReaderTest-dev",
main_src = "src/test/daml/DarReaderTest.daml",
target = "1.dev",
)
2019-04-04 11:33:38 +03:00
filegroup(
name = "proto_srcs",
srcs = ["da/daml_lf.proto"] + ["da/daml_lf_%s.proto" % v for v in LF_MAJOR_VERSIONS],
2019-04-04 11:33:38 +03:00
)
proto_library(
name = "daml_lf_proto_lib",
srcs = [":proto_srcs"],
proto_source_root = "daml-lf/archive",
2019-04-04 11:33:38 +03:00
)
java_proto_library(
name = "daml_lf_proto_lib_java",
visibility = ["//visibility:public"],
deps = [":daml_lf_proto_lib"],
2019-04-04 11:33:38 +03:00
)
javadoc_library(
name = "daml_lf_archive_java_javadoc",
srcs = [":daml_lf_proto_lib_java"],
root_packages = ["com.digitalasset.daml_lf"],
visibility = ["//visibility:public"],
deps = [":daml_lf_proto_lib_java"],
)
# This is an hack to avoid having to complicate the release logic.
# Once we stop bundling proto files in daml_lf_archive_java
# we can remove this.
genrule(
name = "daml_lf_archive_java_srcjar",
srcs = ["daml_lf_proto_lib_java"],
outs = ["daml_lf_archive_java_srcjar.jar"],
cmd = """
for file in $(locations :daml_lf_proto_lib_java); do
if [[ $$file == *src* ]]; then
cp $$file $(location daml_lf_archive_java_srcjar.jar)
fi
done
""",
visibility = ["//visibility:public"],
)
2019-04-04 11:33:38 +03:00
# NOTE(MH): The pre-bazel release process put the `.proto` files in
# `daml-lf-archive.jar` as well. This rule is replicating this old behavior.
# This will very likely change in the future to not include the `.proto` files.
genrule(
name = "daml_lf_archive_java",
srcs = [
":proto_srcs",
":daml_lf_proto_lib_java",
],
outs = ["daml_lf_archive_java.jar"],
cmd = """
2019-04-04 11:33:38 +03:00
INPUT=$$(echo "$(locations :daml_lf_proto_lib_java)" | cut -d ' ' -f 1)
cp -L $$INPUT $@
chmod u+w $@
$(location @zip_dev_env//:zip) -g $@ $(locations :proto_srcs)
""",
tags = ["maven_coordinates=com.digitalasset:daml-lf-archive:__VERSION__"],
tools = ["@zip_dev_env//:zip"],
visibility = ["//visibility:public"],
)
pom_file(
name = "daml_lf_archive_java_pom",
target = ":daml_lf_archive_java",
visibility = ["//visibility:public"],
2019-04-04 11:33:38 +03:00
)
genrule(
name = "daml_lf_archive_protos_zip",
srcs = [":proto_srcs"],
outs = ["daml_lf_archive_protos_zip.zip"],
cmd = """
2019-04-04 11:33:38 +03:00
mkdir -p daml-lf-archive-protos/protobuf/com/digitalasset/daml_lf
cp $(SRCS) daml-lf-archive-protos/protobuf/com/digitalasset/daml_lf
$(location @zip_dev_env//:zip) -r $@ daml-lf-archive-protos
""",
tools = ["@zip_dev_env//:zip"],
visibility = ["//visibility:public"],
2019-04-04 11:33:38 +03:00
)
pkg_tar(
name = "daml_lf_archive_protos_tarball",
srcs = [":proto_srcs"],
extension = "tar.gz",
package_dir = "daml-lf-archive-protos/protobuf/da",
visibility = ["//visibility:public"],
2019-04-04 11:33:38 +03:00
)