@@ -72,12 +72,14 @@ import Distribution.Types.TargetInfo
72
72
import Distribution.Text
73
73
import Distribution.Pretty
74
74
75
- -- | Construct a JSON document describing the build information for a package
76
- mkBuildInfo :: PackageDescription -- ^ Mostly information from the .cabal file
77
- -> LocalBuildInfo -- ^ Configuration information
78
- -> BuildFlags -- ^ Flags that the user passed to build
79
- -> [TargetInfo ]
80
- -> Json
75
+ -- | Construct a JSON document describing the build information for a
76
+ -- package.
77
+ mkBuildInfo
78
+ :: PackageDescription -- ^ Mostly information from the .cabal file
79
+ -> LocalBuildInfo -- ^ Configuration information
80
+ -> BuildFlags -- ^ Flags that the user passed to build
81
+ -> [TargetInfo ]
82
+ -> Json
81
83
mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
82
84
where
83
85
componentsToBuild = map (\ target -> (componentLocalName $ targetCLBI target,targetCLBI target)) targetsToBuild
@@ -86,45 +88,45 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
86
88
87
89
info = JsonObject
88
90
[ " cabal-version" .= JsonString (display cabalVersion)
89
- , " compiler" .= mkCompilerInfo
90
- , " components" .= JsonArray (map mkComponentInfo componentsToBuild)
91
+ , " compiler" .= mkCompilerInfo
92
+ , " components" .= JsonArray (map mkComponentInfo componentsToBuild)
91
93
]
92
94
93
95
mkCompilerInfo = JsonObject
94
- [ " flavour" .= JsonString (prettyShow $ compilerFlavor $ compiler lbi)
96
+ [ " flavour" .= JsonString (prettyShow $ compilerFlavor $ compiler lbi)
95
97
, " compiler-id" .= JsonString (showCompilerId $ compiler lbi)
96
- , " path" .= path
98
+ , " path" .= path
97
99
]
98
100
where
99
101
path = maybe JsonNull (JsonString . programPath)
100
102
$ (flavorToProgram . compilerFlavor $ compiler lbi)
101
103
>>= flip lookupProgram (withPrograms lbi)
102
104
103
105
flavorToProgram :: CompilerFlavor -> Maybe Program
104
- flavorToProgram GHC = Just ghcProgram
106
+ flavorToProgram GHC = Just ghcProgram
105
107
flavorToProgram GHCJS = Just ghcjsProgram
106
- flavorToProgram UHC = Just uhcProgram
107
- flavorToProgram JHC = Just jhcProgram
108
- flavorToProgram _ = Nothing
108
+ flavorToProgram UHC = Just uhcProgram
109
+ flavorToProgram JHC = Just jhcProgram
110
+ flavorToProgram _ = Nothing
109
111
110
112
mkComponentInfo (name, clbi) = JsonObject
111
- [ " type" .= JsonString compType
112
- , " name" .= JsonString (prettyShow name)
113
- , " unit-id" .= JsonString (prettyShow $ componentUnitId clbi)
113
+ [ " type" .= JsonString compType
114
+ , " name" .= JsonString (prettyShow name)
115
+ , " unit-id" .= JsonString (prettyShow $ componentUnitId clbi)
114
116
, " compiler-args" .= JsonArray (map JsonString $ getCompilerArgs bi lbi clbi)
115
- , " modules" .= JsonArray (map (JsonString . display) modules)
116
- , " src-files" .= JsonArray (map JsonString sourceFiles)
117
- , " src-dirs" .= JsonArray (map JsonString $ hsSourceDirs bi)
117
+ , " modules" .= JsonArray (map (JsonString . display) modules)
118
+ , " src-files" .= JsonArray (map JsonString sourceFiles)
119
+ , " src-dirs" .= JsonArray (map JsonString $ hsSourceDirs bi)
118
120
]
119
121
where
120
122
bi = componentBuildInfo comp
121
123
Just comp = lookupComponent pkg_descr name
122
124
compType = case comp of
123
- CLib _ -> " lib"
124
- CExe _ -> " exe"
125
- CTest _ -> " test"
126
- CBench _ -> " bench"
127
- CFLib _ -> " flib"
125
+ CLib _ -> " lib"
126
+ CExe _ -> " exe"
127
+ CTest _ -> " test"
128
+ CBench _ -> " bench"
129
+ CFLib _ -> " flib"
128
130
modules = case comp of
129
131
CLib lib -> explicitLibModules lib
130
132
CExe exe -> exeModules exe
@@ -136,10 +138,11 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
136
138
137
139
-- | Get the command-line arguments that would be passed
138
140
-- to the compiler to build the given component.
139
- getCompilerArgs :: BuildInfo
140
- -> LocalBuildInfo
141
- -> ComponentLocalBuildInfo
142
- -> [String ]
141
+ getCompilerArgs
142
+ :: BuildInfo
143
+ -> LocalBuildInfo
144
+ -> ComponentLocalBuildInfo
145
+ -> [String ]
143
146
getCompilerArgs bi lbi clbi =
144
147
case compilerFlavor $ compiler lbi of
145
148
GHC -> ghc
0 commit comments