forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the core component building logic
1. Refactors the duplicated `buildExtraSources` function from `gbuild` and `buildOrReplLib` into a standalone monadic computation in the context of building a component. This refactor allows us to share the code for building an extra source amongst the two functions. 2. Creates a new module Distribution.Simple.GHC.Build.Modules which, in the same spirit as ...GHC.Build.ExtraModules, defines an action which builds all the Haskell modules of the component being built. This function clarifies and re-implements the logic of building Haskell modules in the different possible ways, while accounting for Template Haskell special "way requirements", which was previously duplicated in a non-obvious manner in gbuild and buildOrReplLib. The Note [Building Haskell modules accounting for TH] in that module explains the big picture, and the implementation is re-done in light of it. 3. Re-work the linker invocations, focusing on preserving existing behaviour before simplifying or fixing bugs any further. Fixes haskell#9389.
- Loading branch information
Showing
15 changed files
with
1,900 additions
and
1,755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE PatternSynonyms #-} | ||
|
||
module Distribution.Simple.Build.Inputs | ||
( -- * Inputs of actions for building components | ||
PreBuildComponentInputs (..) | ||
|
||
-- * Queries over the component being built | ||
, buildVerbosity | ||
, buildComponent | ||
, buildIsLib | ||
, buildCLBI | ||
, buildBI | ||
, buildCompiler | ||
|
||
-- * Re-exports | ||
, BuildingWhat (..) | ||
, LocalBuildInfo (..) | ||
, TargetInfo (..) | ||
, buildingWhatVerbosity | ||
, buildingWhatDistPref | ||
) | ||
where | ||
|
||
import Distribution.Simple.Compiler | ||
import Distribution.Simple.Setup (BuildingWhat (..), buildingWhatDistPref, buildingWhatVerbosity) | ||
import Distribution.Types.BuildInfo | ||
import Distribution.Types.Component | ||
import Distribution.Types.ComponentLocalBuildInfo | ||
import Distribution.Types.LocalBuildInfo | ||
import Distribution.Types.TargetInfo | ||
import Distribution.Verbosity | ||
|
||
-- | The information required for a build computation which is available right | ||
-- before building each component, i.e. the pre-build component inputs. | ||
data PreBuildComponentInputs = PreBuildComponentInputs | ||
{ buildingWhat :: BuildingWhat | ||
-- ^ What kind of build are we doing? | ||
, localBuildInfo :: LocalBuildInfo | ||
-- ^ Information about the package | ||
, targetInfo :: TargetInfo | ||
-- ^ Information about an individual component | ||
} | ||
|
||
-- | Get the @'Verbosity'@ from the context the component being built is in. | ||
buildVerbosity :: PreBuildComponentInputs -> Verbosity | ||
buildVerbosity = buildingWhatVerbosity . buildingWhat | ||
|
||
-- | Get the @'Component'@ being built. | ||
buildComponent :: PreBuildComponentInputs -> Component | ||
buildComponent = targetComponent . targetInfo | ||
|
||
-- | Is the @'Component'@ being built a @'Library'@? | ||
buildIsLib :: PreBuildComponentInputs -> Bool | ||
buildIsLib = do | ||
component <- buildComponent | ||
let isLib | ||
| CLib{} <- component = True | ||
| otherwise = False | ||
return isLib | ||
{-# INLINE buildIsLib #-} | ||
|
||
-- | Get the @'ComponentLocalBuildInfo'@ for the component being built. | ||
buildCLBI :: PreBuildComponentInputs -> ComponentLocalBuildInfo | ||
buildCLBI = targetCLBI . targetInfo | ||
|
||
-- | Get the @'BuildInfo'@ of the component being built. | ||
buildBI :: PreBuildComponentInputs -> BuildInfo | ||
buildBI = componentBuildInfo . buildComponent | ||
|
||
-- | Get the @'Compiler'@ being used to build the component. | ||
buildCompiler :: PreBuildComponentInputs -> Compiler | ||
buildCompiler = compiler . localBuildInfo |
Oops, something went wrong.