daml/daml-lf/encoder/BUILD.bazel
Stefano Baghino caa8025788
Reduce noise when building //daml-lf/encoder:testing-dar-* (#13313)
changelog_begin
changelog_end

Adding Logback to the runtime dependencies allows to avoid having
logging noise when building this due to the missing logger implementation.

Before:

```
> bazel build //daml-lf/encoder:testing-dar-1.12
INFO: Invocation ID: fd46d196-8780-4b3a-9c23-41501a4668d2
INFO: Analyzed target //daml-lf/encoder:testing-dar-1.12 (1 packages loaded, 27 targets configured).
INFO: Found 1 target...
INFO: From Executing genrule //daml-lf/encoder:testing-dar-1.12:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Target //daml-lf/encoder:testing-dar-1.12 up-to-date:
  bazel-bin/daml-lf/encoder/test-1.12.dar
INFO: Elapsed time: 0.365s, Critical Path: 0.01s
INFO: 5 processes: 1 remote cache hit, 4 internal.
INFO: Build completed successfully, 5 total actions
```

After:

```
> bazel build //daml-lf/encoder:testing-dar-1.12
INFO: Invocation ID: d79a9df8-8243-49db-bd67-56a4f53ca746
INFO: Analyzed target //daml-lf/encoder:testing-dar-1.12 (1 packages loaded, 27 targets configured).
INFO: Found 1 target...
Target //daml-lf/encoder:testing-dar-1.12 up-to-date:
  bazel-bin/daml-lf/encoder/test-1.12.dar
INFO: Elapsed time: 0.332s, Critical Path: 0.01s
INFO: 5 processes: 1 remote cache hit, 4 internal.
INFO: Build completed successfully, 5 total actions
```

Notice the lack of SLF4J warnings.

See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2022-03-16 16:24:16 +00:00

172 lines
5.0 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:scala.bzl",
"da_scala_binary",
"da_scala_library",
"da_scala_test_suite",
"lf_scalacopts",
)
load(
"//daml-lf/language:daml-lf.bzl",
"LF_VERSIONS",
"lf_version_configuration",
"mangle_for_java",
)
da_scala_library(
name = "encoder",
srcs = glob(
["src/main/**/*.scala"],
exclude = ["src/main/scala/com/digitalasset/daml/lf/archive/testing/DamlLfEncoder.scala"],
),
scala_deps = [
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = lf_scalacopts,
visibility = ["//visibility:public"],
deps = [
"//daml-lf/archive:daml_lf_1.dev_archive_proto_java",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/data",
"//daml-lf/language",
"//libs-scala/crypto",
"//libs-scala/safe-proto",
"@maven//:com_google_protobuf_protobuf_java",
],
)
da_scala_test_suite(
name = "tests",
size = "small",
srcs = glob(["src/test/scala/**/*.scala"]),
data = [":testing-dar-%s" % target for target in LF_VERSIONS],
scala_deps = [
"@maven//:org_scalatest_scalatest_core",
"@maven//:org_scalatest_scalatest_matchers_core",
"@maven//:org_scalatest_scalatest_shouldmatchers",
"@maven//:org_scalatest_scalatest_wordspec",
"@maven//:org_scalaz_scalaz_core",
],
scalacopts = lf_scalacopts,
deps = [
":encoder",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/archive:daml_lf_1.dev_archive_proto_java",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/data",
"//daml-lf/language",
"//daml-lf/parser",
"//daml-lf/validation",
"//libs-scala/logging-entries",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:org_scalatest_scalatest_compatible",
],
)
da_scala_binary(
name = "encoder_binary",
srcs = glob(["src/main/scala/com/digitalasset/daml/lf/archive/testing/DamlLfEncoder.scala"]),
main_class = "com.daml.lf.archive.testing.DamlLfEncoder",
scalacopts = lf_scalacopts,
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
],
deps = [
":encoder",
"//:sdk-version-scala-lib",
"//daml-lf/archive:daml_lf_1.dev_archive_proto_java",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/archive/encoder",
"//daml-lf/data",
"//daml-lf/language",
"//daml-lf/parser",
"//daml-lf/validation",
"@maven//:com_google_protobuf_protobuf_java",
],
)
[
filegroup(
name = "lf_%s" % target,
srcs = glob([
"src/test/lf/*_all_*.lf",
"src/test/lf/*_%s_*.lf" % target,
]),
)
for target in LF_VERSIONS
]
[
[
genrule(
name = "testing-dar-%s" % target,
srcs = [":lf_%s" % target],
outs = ["test-%s.dar" % target],
cmd = "$(location :encoder_binary) $(SRCS) --output $@ --target %s" % target,
tools = [":encoder_binary"],
visibility = ["//visibility:public"],
),
sh_test(
name = "validate-dar-%s" % target,
srcs = ["src/validate.sh"],
args = [
"$(location //daml-lf/repl:repl)",
"$(location :testing-dar-%s)" % target,
"--dev" if (target == lf_version_configuration.get("dev") or target == lf_version_configuration.get("preview")) else "",
],
data = [
"//daml-lf/repl",
"testing-dar-%s" % target,
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
),
]
for target in LF_VERSIONS
]
[
[
genrule(
name = "testing-dar-lookup-scala-%s" % keyword,
outs = ["TestDars-%s.scala" % mangle_for_java(keyword)],
cmd = """
cat > $@ <<EOF
package com.daml.lf.archive.testing
object TestDar {
val fileName = \"daml-lf/encoder/test-%s.dar\"
}
EOF
""" % version,
),
da_scala_library(
name = "testing-dar-lookup-lib-%s" % keyword,
srcs = ["testing-dar-lookup-scala-%s" % keyword],
# generated_srcs is required for scaladocF
generated_srcs = ["testing-dar-lookup-scala-%s" % keyword],
visibility = ["//visibility:public"],
),
]
for (keyword, version) in lf_version_configuration.items()
if keyword in ["latest"]
]
[
alias(
name = "testing-dar-%s" % keyword,
actual = ":testing-dar-%s" % version,
visibility = ["//visibility:public"],
)
for (keyword, version) in lf_version_configuration.items()
]
filegroup(
name = "testing-dars",
srcs = ["testing-dar-%s" % version for version in LF_VERSIONS],
visibility = ["//visibility:public"],
)