Skip to content

Commit

Permalink
rework daml_compile bazel rule (digital-asset#5070)
Browse files Browse the repository at this point in the history
Avoiding `damlc compile/package` commands (which we would like to deprecate), and replace with plain `damlc build` together with a post dar->dalf extraction step in the couple of places where we actually want the .dalf for testing.

changelog_begin
changelog_end
  • Loading branch information
nickchapman-da authored Mar 18, 2020
1 parent 29c340f commit d81caa9
Show file tree
Hide file tree
Showing 22 changed files with 315 additions and 246 deletions.
5 changes: 3 additions & 2 deletions daml-lf/archive/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ load(
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")
Expand Down Expand Up @@ -201,9 +202,9 @@ da_scala_test_suite(
],
)

daml_compile(
daml_compile_with_dalf(
name = "DarReaderTest",
main_src = "src/test/daml/DarReaderTest.daml",
srcs = ["src/test/daml/DarReaderTest.daml"],
)

# An ad-hoc tool for testing, benchmarking and profiling package decoding performance in isolation.
Expand Down
4 changes: 2 additions & 2 deletions daml-lf/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ TEST_FILES = \
[
daml_compile(
name = name,
main_src = "%s.daml" % name,
srcs = ["%s.daml" % name],
visibility = ["//daml-lf:__subpackages__"],
)
for name in TEST_FILES
]

daml_compile(
name = "Optional",
main_src = "Optional.daml",
srcs = ["Optional.daml"],
visibility = ["//daml-lf:__subpackages__"],
)

Expand Down
3 changes: 1 addition & 2 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@os_info//:os_info.bzl", "is_linux", "is_windows")
load("//rules_daml:daml.bzl", "daml_compile", "daml_test")
load("//rules_daml:daml-build.bzl", "daml_build_test")
load("//rules_daml:daml.bzl", "daml_build_test", "daml_compile", "daml_test")
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@build_environment//:configuration.bzl", "mvn_version", "sdk_version")

Expand Down
2 changes: 1 addition & 1 deletion docs/source/upgrade/example/coin-1.0.0/daml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dependencies:
- daml-stdlib
# END
parties: [Alice, Bob]
source: daml
source: .
build-options: [--target=1.8]
2 changes: 1 addition & 1 deletion docs/source/upgrade/example/coin-2.0.0/daml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dependencies:
- daml-stdlib
# END
parties: [Alice, Bob]
source: daml
source: .
build-options: [--target=1.8]
2 changes: 1 addition & 1 deletion docs/source/upgrade/example/coin-upgrade/daml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ data-dependencies:
- path/to/coin-2.0.0.dar
# END
parties: [Alice, Bob]
source: daml
source: .
build-options: [--target=1.8]
8 changes: 5 additions & 3 deletions extractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST_DARS = [
[
daml_compile(
name = darmod,
main_src = "src/test/resources/damls/%s.daml" % darmod,
srcs = ["src/test/resources/damls/%s.daml" % darmod],
# FixMe: https://github.com/digital-asset/daml/issues/2289
# change version to lf_latest_version when freezing numeric in the next language version
target = lf_dev_version,
Expand Down Expand Up @@ -68,8 +68,10 @@ module VeryLargeArchive.Blob1 where

daml_compile(
name = "VeryLargeArchive",
srcs = [":VeryLargeArchive_src"],
main_src = ":VeryLargeArchive/Blobs.daml",
srcs = [
":VeryLargeArchive/Blobs.daml",
":VeryLargeArchive_src",
],
)

da_scala_library(
Expand Down
4 changes: 1 addition & 3 deletions language-support/hs/bindings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ da_haskell_library(
daml_compile(
name = "for-tests",
srcs = glob(["test/daml/for-tests/*.daml"]),
main_src = "test/daml/for-tests/Main.daml",
)

daml_compile(
name = "for-upload",
srcs = glob(["test/daml/for-upload/ExtraModule.daml"]),
main_src = "test/daml/for-upload/ExtraModule.daml",
srcs = ["test/daml/for-upload/ExtraModule.daml"],
)

da_haskell_test(
Expand Down
1 change: 0 additions & 1 deletion language-support/hs/bindings/examples/chat/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load("//rules_daml:daml.bzl", "daml_compile")
daml_compile(
name = "Chat",
srcs = glob(["daml/*.daml"]),
main_src = "daml/Chat.daml",
)

da_haskell_binary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ load("@os_info//:os_info.bzl", "is_windows")
daml_compile(
name = "GroupChat",
srcs = glob(["daml/GroupChat.daml"]),
main_src = "daml/GroupChat.daml",
)

daml_test(
Expand Down
1 change: 0 additions & 1 deletion language-support/hs/bindings/examples/nim/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load("//rules_daml:daml.bzl", "daml_compile")
daml_compile(
name = "Nim",
srcs = glob(["daml/*.daml"]),
main_src = "daml/Nim.daml",
)

da_haskell_binary(
Expand Down
2 changes: 1 addition & 1 deletion language-support/java/bindings-rxjava/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ da_scala_test_suite(

daml_compile(
name = "bindings-integration-tests-model-latest",
main_src = "src/main/daml/TemplateUtils.daml",
srcs = ["src/main/daml/TemplateUtils.daml"],
target = lf_stable_version,
)

Expand Down
4 changes: 1 addition & 3 deletions language-support/java/codegen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ da_scala_test(

daml_compile(
name = "test-daml",
main_src = "src/test/daml/Foo.daml",
srcs = ["src/test/daml/Foo.daml"],
)

jar_jar(
Expand Down Expand Up @@ -195,7 +195,6 @@ alias(
daml_compile(
name = "integration-tests-model-latest",
srcs = glob(["src/it/daml/**/*.daml"]),
main_src = "src/it/daml/Lib.daml",
target = lf_latest_version,
)

Expand Down Expand Up @@ -247,7 +246,6 @@ daml_compile(
daml_compile(
name = "ledger-tests-model",
srcs = glob(["src/ledger-tests/daml/**/*.daml"]),
main_src = "src/ledger-tests/daml/AllTests.daml",
target = lf_stable_version,
)

Expand Down
4 changes: 2 additions & 2 deletions language-support/scala/codegen-sample-app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ load(

daml_compile(
name = "MyMain",
main_src = "src/main/daml/MyMain.daml",
srcs = ["src/main/daml/MyMain.daml"],
# FIXME https://github.com/digital-asset/daml/issues/2256
# switch to latest once 1.9 is frozen
target = lf_dev_version,
)

daml_compile(
name = "MySecondMain",
main_src = "src/main/daml/MySecondMain.daml",
srcs = ["src/main/daml/MySecondMain.daml"],
target = lf_latest_version,
)

Expand Down
12 changes: 6 additions & 6 deletions language-support/ts/codegen/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ load("@build_environment//:configuration.bzl", "sdk_version")
load("@os_info//:os_info.bzl", "is_windows")

# This rule builds a dar from the daml sources under the 'daml'
# directory. It is referenced from the 'build-and-lint' test target that
# directory. It is referenced from the 'build-and-lint-test' target that
# follows.
daml_compile(
name = "build-and-lint-1.0.0",
name = "build-and-lint",
srcs = glob(["daml/**/*.daml"]),
main_src = "daml/Main.daml",
version = "1.0.0",
)

# build-and-lint
Expand Down Expand Up @@ -70,7 +70,7 @@ daml_compile(
# - Gracefully tears down the processes it started when its work is done.
# All in all, a pretty slick bit of work!
sh_test(
name = "build-and-lint",
name = "build-and-lint-test",
size = "large",
srcs = ["build-and-lint.sh"],
args = [
Expand All @@ -79,7 +79,7 @@ sh_test(
"$(location //:daml2ts)",
"$(location //ledger/sandbox:sandbox-binary_deploy.jar)",
"$(location //ledger-service/http-json:http-json-binary_deploy.jar)",
"$(location :build-and-lint-1.0.0.dar)",
"$(location :build-and-lint.dar)",
"$(location ts/package.json)",
"$(location //language-support/ts/daml-types:npm_package)",
"$(location //language-support/ts/daml-ledger:npm_package)",
Expand All @@ -91,7 +91,7 @@ sh_test(
"//:daml2ts",
"//ledger/sandbox:sandbox-binary_deploy.jar",
"//ledger-service/http-json:http-json-binary_deploy.jar",
":build-and-lint-1.0.0.dar",
":build-and-lint.dar",
"//language-support/ts/daml-types:npm_package",
"//language-support/ts/daml-ledger:npm_package",
] + glob(
Expand Down
2 changes: 1 addition & 1 deletion ledger-service/http-json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ da_scala_binary(

daml_compile(
name = "Account",
main_src = "src/test/daml/Account.daml",
srcs = ["src/test/daml/Account.daml"],
)

da_scala_test(
Expand Down
2 changes: 1 addition & 1 deletion ledger-service/lf-value-json/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ da_scala_library(

daml_compile(
name = "JsonEncodingTest",
main_src = "src/test/daml/JsonEncodingTest.daml",
srcs = ["src/test/daml/JsonEncodingTest.daml"],
)

da_scala_test(
Expand Down
4 changes: 2 additions & 2 deletions ledger/ledger-api-test-tool/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ load(

daml_compile(
name = "PackageManagementTest",
main_src = "src/main/daml/PackageManagementTest.daml",
srcs = ["src/main/daml/PackageManagementTest.daml"],
target = lf_stable_version,
)

Expand Down Expand Up @@ -106,7 +106,7 @@ da_scala_binary(
main_class = "com.daml.ledger.api.testtool.LedgerApiTestTool",
resources = [
"src/main/resources/logback.xml",
":PackageManagementTest",
":PackageManagementTest.dar",
"//ledger/test-common:dar-files",
],
tags = [
Expand Down
2 changes: 1 addition & 1 deletion ledger/sandbox-perf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ da_scala_library(

daml_compile(
name = "LargeTransaction",
main_src = "src/perf/resources/damls/LargeTransaction.daml",
srcs = ["src/perf/resources/damls/LargeTransaction.daml"],
visibility = ["//visibility:public"],
)

Expand Down
4 changes: 2 additions & 2 deletions ledger/test-common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ da_scala_library(

daml_compile(
name = "SemanticTests",
main_src = "src/main/daml/SemanticTests.daml",
srcs = ["src/main/daml/SemanticTests.daml"],
target = lf_stable_version,
visibility = ["//visibility:public"],
)
Expand Down Expand Up @@ -76,8 +76,8 @@ lf_test_versions = [
srcs = [
"src/main/daml/Iou.daml",
"src/main/daml/IouTrade.daml",
"src/main/daml/Test.daml",
],
main_src = "src/main/daml/Test.daml",
target = target,
visibility = ["//visibility:public"],
),
Expand Down
Loading

0 comments on commit d81caa9

Please sign in to comment.