@@ -171,108 +171,108 @@ buildExtraSources
171171 ghcProg
172172 buildTargetDir
173173 (neededLibWays, neededFLibWay, neededExeWay)
174- verbHandles =
175- \ PreBuildComponentInputs {buildingWhat, localBuildInfo = lbi, targetInfo} -> do
176- let
177- bi = componentBuildInfo (targetComponent targetInfo)
178- verbosity = mkVerbosity verbHandles $ buildingWhatVerbosity buildingWhat
179- clbi = targetCLBI targetInfo
180- isIndef = componentIsIndefinite clbi
181- mbWorkDir = mbWorkDirLBI lbi
182- i = interpretSymbolicPath mbWorkDir
183- sources = viewSources (targetComponent targetInfo)
184- comp = compiler lbi
185- platform = hostPlatform lbi
186- tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags buildingWhat
187- runGhcProg =
188- runGHCWithResponseFile
189- " ghc.rsp"
190- Nothing
191- tempFileOptions
192- verbosity
193- ghcProg
194- comp
195- platform
196- mbWorkDir
174+ verbHandles
175+ PreBuildComponentInputs {buildingWhat, localBuildInfo = lbi, targetInfo} = do
176+ let
177+ bi = componentBuildInfo (targetComponent targetInfo)
178+ verbosity = mkVerbosity verbHandles $ buildingWhatVerbosity buildingWhat
179+ clbi = targetCLBI targetInfo
180+ isIndef = componentIsIndefinite clbi
181+ mbWorkDir = mbWorkDirLBI lbi
182+ i = interpretSymbolicPath mbWorkDir
183+ sources = viewSources (targetComponent targetInfo)
184+ comp = compiler lbi
185+ platform = hostPlatform lbi
186+ tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags buildingWhat
187+ runGhcProg =
188+ runGHCWithResponseFile
189+ " ghc.rsp"
190+ Nothing
191+ tempFileOptions
192+ verbosity
193+ ghcProg
194+ comp
195+ platform
196+ mbWorkDir
197197
198- buildAction :: SymbolicPath Pkg File -> IO ()
199- buildAction sourceFile = do
200- let baseSrcOpts =
201- componentSourceGhcOptions
202- (verbosityLevel verbosity)
203- lbi
204- bi
205- clbi
206- buildTargetDir
207- sourceFile
208- vanillaSrcOpts =
209- -- -fPIC is used in case you are using the repl
210- -- of a dynamically linked GHC
211- baseSrcOpts{ghcOptFPic = toFlag True }
212- profSrcOpts =
213- vanillaSrcOpts
214- <> mempty
215- { ghcOptProfilingMode = toFlag True
216- }
217- sharedSrcOpts =
218- vanillaSrcOpts
219- <> mempty
220- { ghcOptFPic = toFlag True
221- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
222- }
223- profSharedSrcOpts =
224- vanillaSrcOpts
225- <> mempty
226- { ghcOptProfilingMode = toFlag True
227- , ghcOptFPic = toFlag True
228- , ghcOptDynLinkMode = toFlag GhcDynamicOnly
229- }
230- -- TODO: Placing all Haskell, C, & C++ objects in a single directory
231- -- Has the potential for file collisions. In general we would
232- -- consider this a user error. However, we should strive to
233- -- add a warning if this occurs.
234- odir = fromFlag (ghcOptObjDir vanillaSrcOpts)
198+ buildAction :: SymbolicPath Pkg File -> IO ()
199+ buildAction sourceFile = do
200+ let baseSrcOpts =
201+ componentSourceGhcOptions
202+ (verbosityLevel verbosity)
203+ lbi
204+ bi
205+ clbi
206+ buildTargetDir
207+ sourceFile
208+ vanillaSrcOpts =
209+ -- -fPIC is used in case you are using the repl
210+ -- of a dynamically linked GHC
211+ baseSrcOpts{ghcOptFPic = toFlag True }
212+ profSrcOpts =
213+ vanillaSrcOpts
214+ <> mempty
215+ { ghcOptProfilingMode = toFlag True
216+ }
217+ sharedSrcOpts =
218+ vanillaSrcOpts
219+ <> mempty
220+ { ghcOptFPic = toFlag True
221+ , ghcOptDynLinkMode = toFlag GhcDynamicOnly
222+ }
223+ profSharedSrcOpts =
224+ vanillaSrcOpts
225+ <> mempty
226+ { ghcOptProfilingMode = toFlag True
227+ , ghcOptFPic = toFlag True
228+ , ghcOptDynLinkMode = toFlag GhcDynamicOnly
229+ }
230+ -- TODO: Placing all Haskell, C, & C++ objects in a single directory
231+ -- Has the potential for file collisions. In general we would
232+ -- consider this a user error. However, we should strive to
233+ -- add a warning if this occurs.
234+ odir = fromFlag (ghcOptObjDir vanillaSrcOpts)
235235
236- compileIfNeeded :: GhcOptions -> IO ()
237- compileIfNeeded opts = do
238- needsRecomp <- checkNeedsRecompilation mbWorkDir sourceFile opts
239- when needsRecomp $ runGhcProg opts
236+ compileIfNeeded :: GhcOptions -> IO ()
237+ compileIfNeeded opts = do
238+ needsRecomp <- checkNeedsRecompilation mbWorkDir sourceFile opts
239+ when needsRecomp $ runGhcProg opts
240240
241- createDirectoryIfMissingVerbose verbosity True (i odir)
242- case targetComponent targetInfo of
243- -- For libraries, we compile extra objects in the four ways: vanilla, shared, profiled and profiled shared.
244- -- We suffix shared objects with `.dyn_o`, profiled ones with `.p_o` and profiled shared ones with `.p_dyn_o`.
245- CLib _lib
246- -- Unless for repl, in which case we only need the vanilla way
247- | BuildRepl _ <- buildingWhat ->
248- compileIfNeeded vanillaSrcOpts
249- | otherwise ->
250- do
251- forM_ (neededLibWays isIndef) $ \ case
252- StaticWay -> compileIfNeeded vanillaSrcOpts
253- DynWay -> compileIfNeeded sharedSrcOpts{ghcOptObjSuffix = toFlag " dyn_o" }
254- ProfWay -> compileIfNeeded profSrcOpts{ghcOptObjSuffix = toFlag " p_o" }
255- ProfDynWay -> compileIfNeeded profSharedSrcOpts{ghcOptObjSuffix = toFlag " p_dyn_o" }
256- CFLib flib ->
257- case neededFLibWay (withDynFLib flib) of
258- StaticWay -> compileIfNeeded vanillaSrcOpts
259- DynWay -> compileIfNeeded sharedSrcOpts
260- ProfWay -> compileIfNeeded profSrcOpts
261- ProfDynWay -> compileIfNeeded profSharedSrcOpts
262- -- For the remaining component types (Exec, Test, Bench), we also
263- -- determine with which options to build the objects (vanilla vs shared vs
264- -- profiled), but predicate is the same for the three kinds.
265- _exeLike ->
266- case neededExeWay of
267- StaticWay -> compileIfNeeded vanillaSrcOpts
268- DynWay -> compileIfNeeded sharedSrcOpts
269- ProfWay -> compileIfNeeded profSrcOpts
270- ProfDynWay -> compileIfNeeded profSharedSrcOpts
241+ createDirectoryIfMissingVerbose verbosity True (i odir)
242+ case targetComponent targetInfo of
243+ -- For libraries, we compile extra objects in the four ways: vanilla, shared, profiled and profiled shared.
244+ -- We suffix shared objects with `.dyn_o`, profiled ones with `.p_o` and profiled shared ones with `.p_dyn_o`.
245+ CLib _lib
246+ -- Unless for repl, in which case we only need the vanilla way
247+ | BuildRepl _ <- buildingWhat ->
248+ compileIfNeeded vanillaSrcOpts
249+ | otherwise ->
250+ do
251+ forM_ (neededLibWays isIndef) $ \ case
252+ StaticWay -> compileIfNeeded vanillaSrcOpts
253+ DynWay -> compileIfNeeded sharedSrcOpts{ghcOptObjSuffix = toFlag " dyn_o" }
254+ ProfWay -> compileIfNeeded profSrcOpts{ghcOptObjSuffix = toFlag " p_o" }
255+ ProfDynWay -> compileIfNeeded profSharedSrcOpts{ghcOptObjSuffix = toFlag " p_dyn_o" }
256+ CFLib flib ->
257+ case neededFLibWay (withDynFLib flib) of
258+ StaticWay -> compileIfNeeded vanillaSrcOpts
259+ DynWay -> compileIfNeeded sharedSrcOpts
260+ ProfWay -> compileIfNeeded profSrcOpts
261+ ProfDynWay -> compileIfNeeded profSharedSrcOpts
262+ -- For the remaining component types (Exec, Test, Bench), we also
263+ -- determine with which options to build the objects (vanilla vs shared vs
264+ -- profiled), but predicate is the same for the three kinds.
265+ _exeLike ->
266+ case neededExeWay of
267+ StaticWay -> compileIfNeeded vanillaSrcOpts
268+ DynWay -> compileIfNeeded sharedSrcOpts
269+ ProfWay -> compileIfNeeded profSrcOpts
270+ ProfDynWay -> compileIfNeeded profSharedSrcOpts
271271
272- -- build any sources
273- if null sources || componentIsIndefinite clbi
274- then return mempty
275- else do
276- info verbosity (" Building " ++ description ++ " ..." )
277- traverse_ buildAction sources
278- return (toNubListR sources)
272+ -- build any sources
273+ if null sources || componentIsIndefinite clbi
274+ then return mempty
275+ else do
276+ info verbosity (" Building " ++ description ++ " ..." )
277+ traverse_ buildAction sources
278+ return (toNubListR sources)
0 commit comments