Skip to content

Commit 53aa595

Browse files
committed
Pattern match on compiler flavour
1 parent 4562c8d commit 53aa595

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Cabal/Distribution/Simple/ShowBuildInfo.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-- |
22
-- This module defines a simple JSON-based format for exporting basic
33
-- information about a Cabal package and the compiler configuration Cabal
4-
-- would use to build it. This can be produced with the
4+
-- would use to build it. This can be produced with the
55
-- @cabal new-show-build-info@ command.
6-
--
6+
--
77
--
88
-- This format is intended for consumption by external tooling and should
99
-- therefore be rather stable. Moreover, this allows tooling users to avoid
@@ -97,7 +97,15 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
9797
]
9898
where
9999
path = maybe JsonNull (JsonString . programPath)
100-
$ lookupProgram ghcProgram (withPrograms lbi)
100+
$ (flavorToProgram . compilerFlavor $ compiler lbi)
101+
>>= flip lookupProgram (withPrograms lbi)
102+
103+
flavorToProgram :: CompilerFlavor -> Maybe Program
104+
flavorToProgram GHC = Just ghcProgram
105+
flavorToProgram GHCJS = Just ghcjsProgram
106+
flavorToProgram UHC = Just uhcProgram
107+
flavorToProgram JHC = Just jhcProgram
108+
flavorToProgram _ = Nothing
101109

102110
mkComponentInfo (name, clbi) = JsonObject
103111
[ "type" .= JsonString compType

0 commit comments

Comments
 (0)