Skip to content

Commit adae1e7

Browse files
hvr23Skidoo
authored andcommitted
Fix minor regression in flag assignment marshalling to custom-setup
This was introduced by f8dc46a which resulted in passing `--flags=+foo` to older custom setup scripts which wouldn't recognize the `+` prefix. This was reported by @cocreature (cherry picked from commit 2c56a40)
1 parent b26a9ee commit adae1e7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Cabal/Distribution/Simple/Setup.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ configureOptions showOrParseArgs =
754754
configConfigurationsFlags (\v flags -> flags { configConfigurationsFlags = v })
755755
(reqArg "FLAGS"
756756
(readP_to_E (\err -> "Invalid flag assignment: " ++ err) parseFlagAssignment)
757-
(map showFlagValue))
757+
(map showFlagValue'))
758758

759759
,option "" ["extra-include-dirs"]
760760
"A list of directories to search for header files"
@@ -868,6 +868,13 @@ configureOptions showOrParseArgs =
868868
reqArgFlag title _sf _lf d
869869
(fmap fromPathTemplate . get) (set . fmap toPathTemplate)
870870

871+
-- We can't use 'showFlagValue' because legacy custom-setups don't
872+
-- support the '+' prefix in --flags; so we omit the (redundant) + prefix;
873+
-- NB: we assume that we never have to set/enable '-'-prefixed flags here.
874+
showFlagValue' :: (FlagName, Bool) -> String
875+
showFlagValue' (f, True) = unFlagName f
876+
showFlagValue' (f, False) = '-' : unFlagName f
877+
871878
readPackageDbList :: String -> [Maybe PackageDB]
872879
readPackageDbList "clear" = [Nothing]
873880
readPackageDbList "global" = [Just GlobalPackageDB]

0 commit comments

Comments
 (0)