daml/daml-assistant/BUILD.bazel
dylant-da 760f879e35
Extract available snapshot versions from Github (#17029)
* Extract available snapshot versions from Github

* Refactor slightly, add comments

* Implement caching

* Make getLatest commands query the minimum number of times from Github

* lint

* filter out prereleases, fix naming

* Fix outdated reference `extractVersionsFromSnapshots` to extractReleases

* Retrieve all versions so that getLatest can prune old versions' patches

* Hide --snapshots, --all, and --force-reload flags from daml version

* Get isPrerelease check correct way around

* Thread UseCache to `daml install` and other commands

* Refactor getEnvLatestStableSdkVersion to defer sdk version extraction

* store envLatestStableSdkVersion thunk in struct so tests can override it

* Read environment var early in getLatestStableSdkVersion

I implemented this with `overrideWithEnvVarMaybe`, but it required some
rather opaque abuse of `fmap pure`, `sequence`, and `join`

* Replace hidden with internal so flags don't show up in help
2023-06-28 12:04:00 +00:00

155 lines
3.7 KiB
Python

# Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_library", "da_haskell_repl", "da_haskell_test", "generate_and_track_cabal")
load("//bazel_tools/packaging:packaging.bzl", "package_app")
load("@os_info//:os_info.bzl", "is_windows")
# This library is intended to be used by applications called by the assistant,
# e.g., damlc, to get the names of the various environment variables set by the assistant.
da_haskell_library(
name = "daml-project-config",
srcs = glob(["daml-project-config/**/*.hs"]),
hackage_deps = [
"aeson",
"base",
"directory",
"extra",
"filepath",
"lens",
"safe-exceptions",
"semver",
"text",
"yaml",
],
src_strip_prefix = "daml-project-config",
visibility = ["//visibility:public"],
deps = [],
)
da_haskell_library(
name = "daml-lib",
srcs = glob(
["src/**/*.hs"],
),
hackage_deps = [
"aeson",
"base",
"bytestring",
"conduit",
"conduit-extra",
"containers",
"unordered-containers",
"directory",
"extra",
"filelock",
"filepath",
"http-client",
"http-client-tls",
"http-conduit",
"http-types",
"lens",
"optparse-applicative",
"process",
"safe",
"safe-exceptions",
"semver",
"tar-conduit",
"tasty",
"tasty-hunit",
"tasty-quickcheck",
"temporary",
"terminal-progress-bar",
"text",
"time",
"tls",
"typed-process",
"unix-compat",
"utf8-string",
"yaml",
] + (["Win32"] if is_windows else []),
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":daml-project-config",
"//libs-haskell/da-hs-base",
],
)
da_haskell_binary(
name = "daml",
srcs = ["exe/DA/Daml/Assistant.hs"],
hackage_deps = [
"aeson",
"base",
"containers",
"directory",
"extra",
"filepath",
"safe",
"safe-exceptions",
"typed-process",
"text",
"unordered-containers",
],
main_function = "DA.Daml.Assistant.main",
src_strip_prefix = "exe",
visibility = ["//visibility:public"],
deps = [
":daml-lib",
":daml-project-config",
"//libs-haskell/da-hs-base",
],
)
package_app(
name = "daml-dist",
binary = ":daml",
visibility = ["//visibility:public"],
)
da_haskell_test(
name = "test",
srcs = ["test/DA/Daml/Assistant/Tests.hs"],
hackage_deps = [
"base",
"conduit",
"conduit-extra",
"directory",
"extra",
"filepath",
"safe-exceptions",
"tar-conduit",
"tasty",
"tasty-hunit",
"tasty-quickcheck",
"temporary",
"text",
"unix-compat",
],
main_function = "DA.Daml.Assistant.Tests.main",
src_strip_prefix = "test",
visibility = ["//visibility:public"],
deps = [
":daml-lib",
":daml-project-config",
"//libs-haskell/da-hs-base",
"//libs-haskell/test-utils",
],
)
# Target for da-ghcid, includes everything except integration tests.
da_haskell_repl(
name = "repl",
testonly = True,
collect_data = False,
visibility = ["//visibility:public"],
deps = [
"//daml-assistant:daml",
"//daml-assistant:test",
"//daml-assistant/daml-helper",
],
)
generate_and_track_cabal("daml-project-config", None, "daml-project-config")