Skip to content

Commit 3f58f3d

Browse files
committed
Reinstate 'initialBuildSteps' function
This patch reinstates the 'initialBuildSteps' function, as it is used by stack in its implementation of the multi-repl feature. A warning has been added to that function: calling it does not suffice to prepare the sources for a package, as there are other steps that one might also need to perform: - running pre-processors (such as alex/happy) - running pre-build hooks or custom logic (in build-type: Hooks or build-type: Custom or Configure) Fixes #9856
1 parent bccc59f commit 3f58f3d

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

Cabal/src/Distribution/Simple/Build.hs

+45-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ module Distribution.Simple.Build
3939
, writeBuiltinAutogenFiles
4040
, writeAutogenFiles
4141

42+
-- ** Legacy functions
43+
, componentInitialBuildSteps
44+
, initialBuildSteps
45+
4246
-- * Internal package database creation
4347
, createInternalPackageDB
4448
) where
@@ -1029,6 +1033,45 @@ replFLib flags pkg_descr lbi exe clbi =
10291033
GHC -> GHC.replFLib flags NoFlag pkg_descr lbi exe clbi
10301034
_ -> dieWithException verbosity REPLNotSupported
10311035

1036+
-- | Runs 'componentInitialBuildSteps' on every configured component.
1037+
--
1038+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
1039+
-- is insufficient on its own to prepare the build for a package.
1040+
initialBuildSteps
1041+
:: FilePath
1042+
-- ^ "dist" prefix
1043+
-> PackageDescription
1044+
-- ^ mostly information from the .cabal file
1045+
-> LocalBuildInfo
1046+
-- ^ Configuration information
1047+
-> Verbosity
1048+
-- ^ The verbosity to use
1049+
-> IO ()
1050+
initialBuildSteps distPref pkg_descr lbi verbosity =
1051+
withAllComponentsInBuildOrder pkg_descr lbi $ \_comp clbi ->
1052+
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity
1053+
1054+
-- | Creates the autogenerated files for a particular configured component.
1055+
--
1056+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
1057+
-- is insufficient on its own to prepare the build for a component.
1058+
componentInitialBuildSteps
1059+
:: FilePath
1060+
-- ^ "dist" prefix
1061+
-> PackageDescription
1062+
-- ^ mostly information from the .cabal file
1063+
-> LocalBuildInfo
1064+
-- ^ Configuration information
1065+
-> ComponentLocalBuildInfo
1066+
-- ^ Build info about the component
1067+
-> Verbosity
1068+
-- ^ The verbosity to use
1069+
-> IO ()
1070+
componentInitialBuildSteps _distPref pkg_descr lbi clbi verbosity = do
1071+
let compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1072+
createDirectoryIfMissingVerbose verbosity True compBuildDir
1073+
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
1074+
10321075
-- | Creates the autogenerated files for a particular configured component,
10331076
-- and runs the pre-build hook.
10341077
preBuildComponent
@@ -1042,7 +1085,8 @@ preBuildComponent
10421085
preBuildComponent preBuildHook verbosity lbi tgt = do
10431086
let pkg_descr = localPkgDescr lbi
10441087
clbi = targetCLBI tgt
1045-
createDirectoryIfMissingVerbose verbosity True (interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi)
1088+
compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1089+
createDirectoryIfMissingVerbose verbosity True compBuildDir
10461090
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
10471091
preBuildHook lbi tgt
10481092

0 commit comments

Comments
 (0)