Skip to content

Commit d3ba68a

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) Consumers wanting to prepare the sources of a package, e.g. in order to launch a REPL session, are advised to run @setup repl --repl-multi-file=<fn>@ instead. Fixes #9856
1 parent bccc59f commit d3ba68a

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

Cabal/src/Distribution/Simple/Build.hs

+53-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,53 @@ 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+
--
1041+
-- Consumers wanting to prepare the sources of a package, e.g. in order to
1042+
-- launch a REPL session, are advised to run @Setup repl --repl-multi-file=<fn>@
1043+
-- instead.
1044+
initialBuildSteps
1045+
:: FilePath
1046+
-- ^ "dist" prefix
1047+
-> PackageDescription
1048+
-- ^ mostly information from the .cabal file
1049+
-> LocalBuildInfo
1050+
-- ^ Configuration information
1051+
-> Verbosity
1052+
-- ^ The verbosity to use
1053+
-> IO ()
1054+
initialBuildSteps distPref pkg_descr lbi verbosity =
1055+
withAllComponentsInBuildOrder pkg_descr lbi $ \_comp clbi ->
1056+
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity
1057+
1058+
-- | Creates the autogenerated files for a particular configured component.
1059+
--
1060+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
1061+
-- is insufficient on its own to prepare the build for a component.
1062+
--
1063+
-- Consumers wanting to prepare the sources of a component, e.g. in order to
1064+
-- launch a REPL session, are advised to run
1065+
-- @Setup repl <compName> --repl-multi-file=<fn>@ instead.
1066+
componentInitialBuildSteps
1067+
:: FilePath
1068+
-- ^ "dist" prefix
1069+
-> PackageDescription
1070+
-- ^ mostly information from the .cabal file
1071+
-> LocalBuildInfo
1072+
-- ^ Configuration information
1073+
-> ComponentLocalBuildInfo
1074+
-- ^ Build info about the component
1075+
-> Verbosity
1076+
-- ^ The verbosity to use
1077+
-> IO ()
1078+
componentInitialBuildSteps _distPref pkg_descr lbi clbi verbosity = do
1079+
let compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1080+
createDirectoryIfMissingVerbose verbosity True compBuildDir
1081+
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
1082+
10321083
-- | Creates the autogenerated files for a particular configured component,
10331084
-- and runs the pre-build hook.
10341085
preBuildComponent
@@ -1042,7 +1093,8 @@ preBuildComponent
10421093
preBuildComponent preBuildHook verbosity lbi tgt = do
10431094
let pkg_descr = localPkgDescr lbi
10441095
clbi = targetCLBI tgt
1045-
createDirectoryIfMissingVerbose verbosity True (interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi)
1096+
compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1097+
createDirectoryIfMissingVerbose verbosity True compBuildDir
10461098
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
10471099
preBuildHook lbi tgt
10481100

0 commit comments

Comments
 (0)