Skip to content

Commit 14d9bed

Browse files
sheafMikolaj
authored andcommitted
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 (cherry picked from commit dd74e92)
1 parent 815b141 commit 14d9bed

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
@@ -34,6 +34,10 @@ module Distribution.Simple.Build
3434
, writeBuiltinAutogenFiles
3535
, writeAutogenFiles
3636

37+
-- ** Legacy functions
38+
, componentInitialBuildSteps
39+
, initialBuildSteps
40+
3741
-- * Internal package database creation
3842
, createInternalPackageDB
3943
) where
@@ -928,6 +932,61 @@ replFLib flags pkg_descr lbi exe clbi =
928932
GHC -> GHC.replFLib flags NoFlag pkg_descr lbi exe clbi
929933
_ -> dieWithException verbosity REPLNotSupported
930934

935+
-- | Runs 'componentInitialBuildSteps' on every configured component.
936+
--
937+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
938+
-- is insufficient on its own to prepare the build for a package.
939+
--
940+
-- Consumers wanting to prepare the sources of a package, e.g. in order to
941+
-- launch a REPL session, are advised to run @Setup repl --repl-multi-file=<fn>@
942+
-- instead.
943+
initialBuildSteps
944+
:: FilePath
945+
-- ^ "dist" prefix
946+
-> PackageDescription
947+
-- ^ mostly information from the .cabal file
948+
-> LocalBuildInfo
949+
-- ^ Configuration information
950+
-> Verbosity
951+
-- ^ The verbosity to use
952+
-> IO ()
953+
initialBuildSteps distPref pkg_descr lbi verbosity =
954+
withAllComponentsInBuildOrder pkg_descr lbi $ \_comp clbi ->
955+
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity
956+
{-# DEPRECATED
957+
initialBuildSteps
958+
"This function does not prepare all source files for a package. Suggestion: use 'Setup repl --repl-multi-file=<fn>'."
959+
#-}
960+
961+
-- | Creates the autogenerated files for a particular configured component.
962+
--
963+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
964+
-- is insufficient on its own to prepare the build for a component.
965+
--
966+
-- Consumers wanting to prepare the sources of a component, e.g. in order to
967+
-- launch a REPL session, are advised to run
968+
-- @Setup repl <compName> --repl-multi-file=<fn>@ instead.
969+
componentInitialBuildSteps
970+
:: FilePath
971+
-- ^ "dist" prefix
972+
-> PackageDescription
973+
-- ^ mostly information from the .cabal file
974+
-> LocalBuildInfo
975+
-- ^ Configuration information
976+
-> ComponentLocalBuildInfo
977+
-- ^ Build info about the component
978+
-> Verbosity
979+
-- ^ The verbosity to use
980+
-> IO ()
981+
componentInitialBuildSteps _distPref pkg_descr lbi clbi verbosity = do
982+
let compBuildDir = componentBuildDir lbi clbi
983+
createDirectoryIfMissingVerbose verbosity True compBuildDir
984+
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
985+
{-# DEPRECATED
986+
componentInitialBuildSteps
987+
"This function does not prepare all source files for a component. Suggestion: use 'Setup repl <compName> --repl-multi-file=<fn>'."
988+
#-}
989+
931990
-- | Pre-build steps for a component: creates the autogenerated files
932991
-- for a particular configured component.
933992
preBuildComponent
@@ -939,7 +998,8 @@ preBuildComponent
939998
preBuildComponent verbosity lbi tgt = do
940999
let pkg_descr = localPkgDescr lbi
9411000
clbi = targetCLBI tgt
942-
createDirectoryIfMissingVerbose verbosity True (componentBuildDir lbi clbi)
1001+
compBuildDir = componentBuildDir lbi clbi
1002+
createDirectoryIfMissingVerbose verbosity True compBuildDir
9431003
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
9441004

9451005
-- | Generate and write to disk all built-in autogenerated files

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)