Skip to content

Commit

Permalink
Skip Cabal in setup_deps for GHC 9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv committed Nov 28, 2023
1 parent a043e79 commit 63991b8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 24 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ stack_snapshot(
"proto-lens-runtime",
"lens-family",
],
setup_deps = {
setup_deps = {} if GHC_VERSION and GHC_VERSION.startswith("9.6.") else {
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
Expand Down
21 changes: 20 additions & 1 deletion extensions/rules_haskell_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@rules_haskell//tools:os_info.bzl", "os_info")
load("@rules_haskell_ghc_version//:ghc_version.bzl", "GHC_VERSION")

def _empty_repo_impl(rctx):
fail(rctx.attr.error_msg)

_empty_repo = repository_rule(
implementation = _empty_repo_impl,
doc = """A dummy repository that can be loaded from the MODULE.bazel file but not fetched.""",
attrs = {
"error_msg": attr.string(
doc = "The error message displayed if the repository is fetched",
mandatory = True,
),
},
)

def repositories(*, bzlmod): # @unused
rules_haskell_dependencies_bzlmod()

Expand All @@ -24,7 +38,12 @@ def repositories(*, bzlmod): # @unused

# TODO: Remove when tests are run with a ghc version containing Cabal >= 3.10
# See https://github.com/tweag/rules_haskell/issues/1871
if GHC_VERSION and GHC_VERSION.startswith("9.4."):
if GHC_VERSION and GHC_VERSION.startswith("9.6."):
_empty_repo(
name = "Cabal",
error_msg = "When using GHC >= 9.6, do not depend on @Cabal, as https://github.com/tweag/rules_haskell/issues/1871 is fixed.",
)
elif GHC_VERSION and GHC_VERSION.startswith("9.4."):
http_archive(
name = "Cabal",
build_file_content = """
Expand Down
46 changes: 25 additions & 21 deletions rules_haskell_tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -273,27 +273,31 @@ stack_snapshot(
"temporary",
],
setup_deps = {
"polysemy": ["cabal-doctest"],
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
"c2hs": ["@Cabal//:Cabal"],
"call-stack": ["@Cabal//:Cabal"],
"doctest": ["@Cabal//:Cabal"],
"generic-deriving": ["@Cabal//:Cabal"],
"happy": ["@Cabal//:Cabal"],
"hspec": ["@Cabal//:Cabal"],
"hspec-core": ["@Cabal//:Cabal"],
"hspec-discover": ["@Cabal//:Cabal"],
"hspec-expectations": ["@Cabal//:Cabal"],
"mono-traversable": ["@Cabal//:Cabal"],
"proto-lens-protoc": ["@Cabal//:Cabal"],
"proto-lens-runtime": ["@Cabal//:Cabal"],
"quickcheck-io": ["@Cabal//:Cabal"],
"transformers-compat": ["@Cabal//:Cabal"],
"type-errors": ["@Cabal//:Cabal"],
"typed-process": ["@Cabal//:Cabal"],
"unliftio-core": ["@Cabal//:Cabal"],
name: deps
for name, deps in {
"polysemy": ["cabal-doctest"],
# See https://github.com/tweag/rules_haskell/issues/1871
"HUnit": ["@Cabal//:Cabal"],
"bifunctors": ["@Cabal//:Cabal"],
"c2hs": ["@Cabal//:Cabal"],
"call-stack": ["@Cabal//:Cabal"],
"doctest": ["@Cabal//:Cabal"],
"generic-deriving": ["@Cabal//:Cabal"],
"happy": ["@Cabal//:Cabal"],
"hspec": ["@Cabal//:Cabal"],
"hspec-core": ["@Cabal//:Cabal"],
"hspec-discover": ["@Cabal//:Cabal"],
"hspec-expectations": ["@Cabal//:Cabal"],
"mono-traversable": ["@Cabal//:Cabal"],
"proto-lens-protoc": ["@Cabal//:Cabal"],
"proto-lens-runtime": ["@Cabal//:Cabal"],
"quickcheck-io": ["@Cabal//:Cabal"],
"transformers-compat": ["@Cabal//:Cabal"],
"type-errors": ["@Cabal//:Cabal"],
"typed-process": ["@Cabal//:Cabal"],
"unliftio-core": ["@Cabal//:Cabal"],
}.items()
if [d for d in deps if d != "@Cabal//:Cabal"] or not GHC_VERSION or not GHC_VERSION.startswith("9.6.")
},
stack_snapshot_json = "//:stackage_snapshot{}.json".format(
"_" + str(GHC_VERSION) if GHC_VERSION else "",
Expand Down
2 changes: 1 addition & 1 deletion tools/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def rules_haskell_worker_dependencies(**stack_kwargs):
"text",
"vector",
],
setup_deps = {
setup_deps = {} if GHC_VERSION and GHC_VERSION.startswith("9.6.") else {
"bifunctors": ["@Cabal//:Cabal"],
"proto-lens-runtime": ["@Cabal//:Cabal"],
"transformers-compat": ["@Cabal//:Cabal"],
Expand Down

0 comments on commit 63991b8

Please sign in to comment.