Skip to content

Commit

Permalink
Draft parse programOptions via fieldGrammar
Browse files Browse the repository at this point in the history
  • Loading branch information
jgotoh committed Sep 6, 2024
1 parent f1fda9a commit c727bf0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cabal-install/parser-tests/Tests/ParserTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ testProgramOptionsConcat = do
Map.fromList
[ ("ghc", ["-threaded", "-Wall", "-fno-state-hack"])
, ("gcc", ["-baz", "-foo", "-bar"])
, ("haddock", ["--optghc=-optP -P"])
, ("ld", ["-Wl,--gc-sections"])
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
program-options
ghc-options: -fno-state-hack
gcc-options: -foo -bar
haddock-options: --optghc="-optP -P"

program-options
ghc-options: -threaded -Wall
Expand Down
4 changes: 4 additions & 0 deletions cabal-install/src/Distribution/Client/ProjectConfig/Parsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ parsePackageName pos args = case args of
parser =
P.choice [P.try (P.char '*' >> return AllPackages), SpecificPackage <$> parsec]

programArgsFieldGrammar :: ParsecFieldGrammar' [(String,[String])]
programArgsFieldGrammar =
monoidalFieldAla "ghc-options" (alaList' NoCommaFSep Token') oida

-- | Parse fields of a program-options stanza.
parseProgramArgs :: ProgramDb -> Fields Position -> ParseResult (MapMappend String [String])
parseProgramArgs programDb fields = foldM parseField mempty (filter hasOptionsSuffix $ Map.toList fields)
Expand Down

0 comments on commit c727bf0

Please sign in to comment.