Skip to content

Commit

Permalink
Merge pull request #6541 from commercialhaskell/re6540
Browse files Browse the repository at this point in the history
Re #6540 Temporarily work around Cabal-3.11.0.0 in StackSetupShim.hs
  • Loading branch information
mpilgrem authored Mar 31, 2024
2 parents 12eba22 + 0e2a04a commit fa7cd30
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions src/setup-shim/StackSetupShim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@ module StackSetupShim where
import Main
#if defined(MIN_VERSION_Cabal)
#if MIN_VERSION_Cabal(3,8,1)
import Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo)
import Distribution.PackageDescription
( PackageDescription, emptyHookedBuildInfo )
#else
import "Cabal" Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo)
import "Cabal" Distribution.PackageDescription
( PackageDescription, emptyHookedBuildInfo )
#endif
#else
import Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo)
import Distribution.PackageDescription
( PackageDescription, emptyHookedBuildInfo )
#endif
import Distribution.Simple
import Distribution.Simple.Build
import Distribution.Simple.Setup (ReplFlags, fromFlag, replDistPref, replVerbosity)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo)
import System.Environment (getArgs)
import Distribution.Simple.Setup
( ReplFlags, fromFlag, replDistPref, replVerbosity )
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo )
-- | Temporary, can be removed if initialBuildSteps restored to Cabal's API.
#if defined(MIN_VERSION_Cabal)
#if MIN_VERSION_Cabal(3,11,0)
import Distribution.Simple.LocalBuildInfo
( ComponentLocalBuildInfo, componentBuildDir
, withAllComponentsInBuildOrder
)
import Distribution.Simple.Utils ( createDirectoryIfMissingVerbose )
import Distribution.Verbosity ( Verbosity )
#endif
#endif
import System.Environment ( getArgs )

mainOverride :: IO ()
mainOverride = do
Expand All @@ -39,3 +54,31 @@ stackReplHook pkg_descr lbi hooks flags args = do
| otherwise ->
fail "Misuse of running Setup.hs with stack-initial-build-steps, expected no arguments"
_ -> replHook simpleUserHooks pkg_descr lbi hooks flags args

-- | Temporary, can be removed if initialBuildSteps restored to Cabal's API.
#if defined(MIN_VERSION_Cabal)
#if MIN_VERSION_Cabal(3,11,0)
-- | Runs 'componentInitialBuildSteps' on every configured component.
initialBuildSteps ::
FilePath -- ^"dist" prefix
-> PackageDescription -- ^mostly information from the .cabal file
-> LocalBuildInfo -- ^Configuration information
-> Verbosity -- ^The verbosity to use
-> IO ()
initialBuildSteps distPref pkg_descr lbi verbosity =
withAllComponentsInBuildOrder pkg_descr lbi $ \_comp clbi ->
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity

-- | Creates the autogenerated files for a particular configured component.
componentInitialBuildSteps ::
FilePath -- ^"dist" prefix
-> PackageDescription -- ^mostly information from the .cabal file
-> LocalBuildInfo -- ^Configuration information
-> ComponentLocalBuildInfo
-> Verbosity -- ^The verbosity to use
-> IO ()
componentInitialBuildSteps _distPref pkg_descr lbi clbi verbosity = do
createDirectoryIfMissingVerbose verbosity True (componentBuildDir lbi clbi)
writeBuiltinAutogenFiles verbosity pkg_descr lbi clbi
#endif
#endif

0 comments on commit fa7cd30

Please # to comment.