From 926f079aee9087632e120cecf581c08bcd5b6f51 Mon Sep 17 00:00:00 2001 From: Kyle Butt Date: Tue, 27 Jun 2023 11:08:42 -0600 Subject: [PATCH] Make the flags passed to Stack match Cabal Cabal uses '+' to enable a flag, and '-' to disable a flag. Stack builds a dictionary that has either 'flag: true', or 'flag: false'. The behavior before was passing inconsistent flags to the different tools. Have cabal.bzl handle all the flags that we could pass to cabal. This helps to aid people new to rules_haskell. It also allows negating a flag, which didn't work before. --- haskell/cabal.bzl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/haskell/cabal.bzl b/haskell/cabal.bzl index 643c928c3..3b7a275d4 100644 --- a/haskell/cabal.bzl +++ b/haskell/cabal.bzl @@ -1307,10 +1307,12 @@ library ], "extra-deps": versioned_packages, "flags": { - pkg: { - flag[1:] if flag.startswith("-") else flag: not flag.startswith("-") + pkg: dict([ + (flag[1:], True) if flag.startswith('+') else + (flag[1:], False) if flag.startswith('-') else + (flag, True) for flag in flags - } + ]) for (pkg, flags) in repository_ctx.attr.flags.items() }, }).to_json()