Skip to content

Commit 27d9daa

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 27d9daa

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

Cabal/src/Distribution/Simple/Build.hs

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

changelog.d/pr-9950

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
synopsis: Re-instate `initialBuildSteps`
2+
packages: Cabal
3+
issues: #9856
4+
prs: #9950
5+
6+
description: {
7+
8+
The `initialBuildSteps` function from `Distribution.Simple.Build`, which had
9+
been hastily removed, has been reinstated.
10+
11+
It now comes with a deprecation warning: calling that function does not suffice
12+
to prepare the sources for a package, as there are other steps that one might
13+
also need to perform:
14+
15+
- running pre-processors (such as alex/happy)
16+
- running pre-build hooks or custom logic
17+
(in build-type: Hooks or build-type: Custom or Configure)
18+
19+
Consumers wanting to prepare the sources of a package, e.g. in order to launch a
20+
REPL session, are advised to run `setup repl --repl-multi-file=<fn>` instead.
21+
}

0 commit comments

Comments
 (0)