-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Prepare Stack for Cabal's changing approach to hooks #6542
Comments
Currently: Stack has: stackReplHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> ReplFlags -> [String] -> IO ()
stackReplHook pkg_descr lbi hooks flags args = do
let distPref = fromFlag (replDistPref flags)
verbosity = fromFlag (replVerbosity flags)
case args of
("stack-initial-build-steps":rest)
| null rest -> initialBuildSteps distPref pkg_descr lbi verbosity
| otherwise ->
fail "Misuse of running Setup.hs with stack-initial-build-steps, expected no arguments"
_ -> replHook simpleUserHooks pkg_descr lbi hooks flags args
-- | 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)
writeAutogenFiles verbosity pkg_descr lbi clbi
-- Field of UserHooks
replHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> ReplFlags -> [String] -> IO () and, for
|
An alternative to the module Main (main) where
import Data.List ( stripPrefix )
import Distribution.Parsec ( eitherParsec )
import Distribution.Simple.Build ( initialBuildSteps )
import Distribution.Simple.Configure ( getPersistBuildConfig )
import Distribution.Simple.PackageDescription ( readGenericPackageDescription )
import Distribution.Simple.Utils ( findPackageDesc )
import Distribution.Types.GenericPackageDescription
( GenericPackageDescription (..) )
import System.Environment ( getArgs )
main :: IO ()
main = do
args <- getArgs
case args of
[] -> putStrLn "Expected Cabal verbosity as first argument and builddir \
\as second argument."
arg1:arg2:[] -> do
eFp <- findPackageDesc ""
case eFp of
Left msg1 -> putStrLn msg1
Right fp -> do
let mRawVerbosity = stripPrefix "--verbose=" arg1
mRawBuildDir = stripPrefix "--builddir=" arg2
case (mRawVerbosity, mRawBuildDir) of
(Nothing, _) ->
putStrLn "Expected first argument to start --verbose="
(_, Nothing) ->
putStrLn "Expected second argument to start --builddir="
(Just rawVerbosity, Just rawBuildDir) -> do
case eitherParsec rawVerbosity of
Left msg2 -> putStrLn msg2
Right verbosity -> do
gpd <- readGenericPackageDescription verbosity fp
let pd = packageDescription gpd
lbi <- getPersistBuildConfig rawBuildDir
initialBuildSteps rawBuildDir pd lbi verbosity
_ -> putStrLn "Expected only Cabal verbosity as first argument and \
\builddir as second argument." |
Re #6542 Add Well-Typed's patch to the repository, so it is to hand
I believe this is incorrect for a package with |
Re #6542 Take a direct approach to `initialBuildSteps`
Motivation:
Currently:
Custom
, which makes use ofgenerateBuildModule
; andreplHook
inStackSetupShim.hs
to cause Cabal to create the autogenerated files for every configured component, without building everything, before Stack usesghc --interactive
.Related question: haskellfoundation/tech-proposals#60 (comment)
The text was updated successfully, but these errors were encountered: