Skip to content

Commit 69e496a

Browse files
phadej23Skidoo
authored andcommitted
Use parseFlagAssignment to parse flag assignments in cli
(cherry picked from commit f8dc46a)
1 parent 1e7b41c commit 69e496a

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Cabal/Distribution/Simple/Setup.hs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,9 @@ configureOptions showOrParseArgs =
752752
,option "f" ["flags"]
753753
"Force values for the given flags in Cabal conditionals in the .cabal file. E.g., --flags=\"debug -usebytestrings\" forces the flag \"debug\" to true and \"usebytestrings\" to false."
754754
configConfigurationsFlags (\v flags -> flags { configConfigurationsFlags = v })
755-
(reqArg' "FLAGS" readFlagList showFlagList)
755+
(reqArg "FLAGS"
756+
(readP_to_E (\err -> "Invalid flag assignment: " ++ err) parseFlagAssignment)
757+
(map showFlagValue))
756758

757759
,option "" ["extra-include-dirs"]
758760
"A list of directories to search for header files"
@@ -859,15 +861,6 @@ configureOptions showOrParseArgs =
859861
(boolOpt [] [])
860862
]
861863
where
862-
readFlagList :: String -> FlagAssignment
863-
readFlagList = map tagWithValue . words
864-
where tagWithValue ('-':fname) = (mkFlagName (lowercase fname), False)
865-
tagWithValue fname = (mkFlagName (lowercase fname), True)
866-
867-
showFlagList :: FlagAssignment -> [String]
868-
showFlagList fs = [ if not set then '-':unFlagName fname else unFlagName fname
869-
| (fname, set) <- fs]
870-
871864
liftInstallDirs =
872865
liftOption configInstallDirs (\v flags -> flags { configInstallDirs = v })
873866

0 commit comments

Comments
 (0)