Skip to content

Commit 9c9caf1

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 deprecation 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 9c9caf1

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

Cabal/src/Distribution/Simple/Build.hs

+59-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,59 @@ 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+
{-# DEPRECATED initialBuildSteps
1058+
"This function does not prepare all source files for a package. Suggestion: use 'Setup repl --repl-multi-file=<fn>'."
1059+
#-}
1060+
1061+
-- | Creates the autogenerated files for a particular configured component.
1062+
--
1063+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
1064+
-- is insufficient on its own to prepare the build for a component.
1065+
--
1066+
-- Consumers wanting to prepare the sources of a component, e.g. in order to
1067+
-- launch a REPL session, are advised to run
1068+
-- @Setup repl <compName> --repl-multi-file=<fn>@ instead.
1069+
componentInitialBuildSteps
1070+
:: FilePath
1071+
-- ^ "dist" prefix
1072+
-> PackageDescription
1073+
-- ^ mostly information from the .cabal file
1074+
-> LocalBuildInfo
1075+
-- ^ Configuration information
1076+
-> ComponentLocalBuildInfo
1077+
-- ^ Build info about the component
1078+
-> Verbosity
1079+
-- ^ The verbosity to use
1080+
-> IO ()
1081+
componentInitialBuildSteps _distPref pkg_descr lbi clbi verbosity = do
1082+
let compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1083+
createDirectoryIfMissingVerbose verbosity True compBuildDir
1084+
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
1085+
{-# DEPRECATED componentInitialBuildSteps
1086+
"This function does not prepare all source files for a component. Suggestion: use 'Setup repl <compName> --repl-multi-file=<fn>'."
1087+
#-}
1088+
10321089
-- | Creates the autogenerated files for a particular configured component,
10331090
-- and runs the pre-build hook.
10341091
preBuildComponent
@@ -1042,7 +1099,8 @@ preBuildComponent
10421099
preBuildComponent preBuildHook verbosity lbi tgt = do
10431100
let pkg_descr = localPkgDescr lbi
10441101
clbi = targetCLBI tgt
1045-
createDirectoryIfMissingVerbose verbosity True (interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi)
1102+
compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1103+
createDirectoryIfMissingVerbose verbosity True compBuildDir
10461104
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
10471105
preBuildHook lbi tgt
10481106

0 commit comments

Comments
 (0)