Skip to content

Commit d29ece2

Browse files
sheafmergify[bot]
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) # Conflicts: # Cabal/src/Distribution/Simple/Build.hs
1 parent 9b92dd2 commit d29ece2

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

Cabal/src/Distribution/Simple/Build.hs

+69
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,8 +932,68 @@ replFLib flags pkg_descr lbi exe clbi =
928932
GHC -> GHC.replFLib flags NoFlag pkg_descr lbi exe clbi
929933
_ -> dieWithException verbosity REPLNotSupported
930934

935+
<<<<<<< HEAD
931936
-- | Pre-build steps for a component: creates the autogenerated files
932937
-- for a particular configured component.
938+
=======
939+
-- | Runs 'componentInitialBuildSteps' on every configured component.
940+
--
941+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
942+
-- is insufficient on its own to prepare the build for a package.
943+
--
944+
-- Consumers wanting to prepare the sources of a package, e.g. in order to
945+
-- launch a REPL session, are advised to run @Setup repl --repl-multi-file=<fn>@
946+
-- instead.
947+
initialBuildSteps
948+
:: FilePath
949+
-- ^ "dist" prefix
950+
-> PackageDescription
951+
-- ^ mostly information from the .cabal file
952+
-> LocalBuildInfo
953+
-- ^ Configuration information
954+
-> Verbosity
955+
-- ^ The verbosity to use
956+
-> IO ()
957+
initialBuildSteps distPref pkg_descr lbi verbosity =
958+
withAllComponentsInBuildOrder pkg_descr lbi $ \_comp clbi ->
959+
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity
960+
{-# DEPRECATED
961+
initialBuildSteps
962+
"This function does not prepare all source files for a package. Suggestion: use 'Setup repl --repl-multi-file=<fn>'."
963+
#-}
964+
965+
-- | Creates the autogenerated files for a particular configured component.
966+
--
967+
-- Legacy function: does not run pre-build hooks or pre-processors. This function
968+
-- is insufficient on its own to prepare the build for a component.
969+
--
970+
-- Consumers wanting to prepare the sources of a component, e.g. in order to
971+
-- launch a REPL session, are advised to run
972+
-- @Setup repl <compName> --repl-multi-file=<fn>@ instead.
973+
componentInitialBuildSteps
974+
:: FilePath
975+
-- ^ "dist" prefix
976+
-> PackageDescription
977+
-- ^ mostly information from the .cabal file
978+
-> LocalBuildInfo
979+
-- ^ Configuration information
980+
-> ComponentLocalBuildInfo
981+
-- ^ Build info about the component
982+
-> Verbosity
983+
-- ^ The verbosity to use
984+
-> IO ()
985+
componentInitialBuildSteps _distPref pkg_descr lbi clbi verbosity = do
986+
let compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
987+
createDirectoryIfMissingVerbose verbosity True compBuildDir
988+
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
989+
{-# DEPRECATED
990+
componentInitialBuildSteps
991+
"This function does not prepare all source files for a component. Suggestion: use 'Setup repl <compName> --repl-multi-file=<fn>'."
992+
#-}
993+
994+
-- | Creates the autogenerated files for a particular configured component,
995+
-- and runs the pre-build hook.
996+
>>>>>>> dd74e9216 (Reinstate 'initialBuildSteps' function)
933997
preBuildComponent
934998
:: Verbosity
935999
-> LocalBuildInfo
@@ -939,7 +1003,12 @@ preBuildComponent
9391003
preBuildComponent verbosity lbi tgt = do
9401004
let pkg_descr = localPkgDescr lbi
9411005
clbi = targetCLBI tgt
1006+
<<<<<<< HEAD
9421007
createDirectoryIfMissingVerbose verbosity True (componentBuildDir lbi clbi)
1008+
=======
1009+
compBuildDir = interpretSymbolicPathLBI lbi $ componentBuildDir lbi clbi
1010+
createDirectoryIfMissingVerbose verbosity True compBuildDir
1011+
>>>>>>> dd74e9216 (Reinstate 'initialBuildSteps' function)
9431012
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
9441013

9451014
-- | 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)