1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE LambdaCase #-}
3 {-# LANGUAGE RankNTypes #-}
4 {-# LANGUAGE ScopedTypeVariables #-}
5 -----------------------------------------------------------------------------
7 Work around this warning:
8 libraries/Cabal/Distribution/Simple.hs:78:0:
9 Warning: In the use of `runTests'
10 (imported from Distribution.Simple.UserHooks):
11 Deprecated: "Please use the new testing interface instead!"
13 {-# OPTIONS_GHC -fno-warn-deprecations #-}
16 -- Module : Distribution.Simple
17 -- Copyright : Isaac Jones 2003-2005
20 -- Maintainer : cabal-devel@haskell.org
21 -- Portability : portable
23 -- This is the command line front end to the Simple build system. When given
24 -- the parsed command-line args and package information, is able to perform
25 -- basic commands like configure, build, install, register, etc.
27 -- This module exports the main functions that Setup.hs scripts use. It
28 -- re-exports the 'UserHooks' type, the standard entry points like
29 -- 'defaultMain' and 'defaultMainWithHooks' and the predefined sets of
30 -- 'UserHooks' that custom @Setup.hs@ scripts can extend to add their own
33 -- This module isn't called \"Simple\" because it's simple. Far from
34 -- it. It's called \"Simple\" because it does complicated things to
37 -- The original idea was that there could be different build systems that all
38 -- presented the same compatible command line interfaces. There is still a
39 -- "Distribution.Make" system but in practice no packages use it.
40 module Distribution
.Simple
41 ( module Distribution
.Package
42 , module Distribution
.Version
43 , module Distribution
.License
44 , module Distribution
.Simple
.Compiler
45 , module Language
.Haskell
.Extension
55 , defaultMainWithHooks
56 , defaultMainWithHooksArgs
57 , defaultMainWithHooksNoRead
58 , defaultMainWithHooksNoReadArgs
60 -- ** Standard sets of hooks
66 import Control
.Exception
(try)
68 import Distribution
.Compat
.Prelude
73 import Distribution
.Package
74 import Distribution
.PackageDescription
75 import Distribution
.PackageDescription
.Configuration
76 import Distribution
.Simple
.Command
77 import Distribution
.Simple
.Compiler
78 import Distribution
.Simple
.PackageDescription
79 import Distribution
.Simple
.PreProcess
80 import Distribution
.Simple
.Program
81 import Distribution
.Simple
.Setup
82 import Distribution
.Simple
.UserHooks
84 import Distribution
.Simple
.Build
85 import Distribution
.Simple
.Register
86 import Distribution
.Simple
.SrcDist
88 import Distribution
.Simple
.Configure
90 import Distribution
.License
91 import Distribution
.Pretty
92 import Distribution
.Simple
.Bench
93 import Distribution
.Simple
.BuildPaths
94 import Distribution
.Simple
.ConfigureScript
95 import Distribution
.Simple
.Errors
96 import Distribution
.Simple
.Haddock
97 import Distribution
.Simple
.Install
98 import Distribution
.Simple
.LocalBuildInfo
99 import Distribution
.Simple
.Test
100 import Distribution
.Simple
.Utils
101 import Distribution
.Verbosity
102 import Distribution
.Version
103 import Language
.Haskell
.Extension
107 import Distribution
.Compat
.ResponseFile
(expandResponse
)
108 import System
.Directory
111 , removeDirectoryRecursive
114 import System
.Environment
(getArgs, getProgName)
115 import System
.FilePath (takeDirectory
, (</>))
117 import Data
.List
(unionBy, (\\))
119 -- | A simple implementation of @main@ for a Cabal setup script.
120 -- It reads the package description file using IO, and performs the
121 -- action specified on the command line.
123 defaultMain
= getArgs >>= defaultMainHelper simpleUserHooks
125 -- | A version of 'defaultMain' that is passed the command line
126 -- arguments, rather than getting them from the environment.
127 defaultMainArgs
:: [String] -> IO ()
128 defaultMainArgs
= defaultMainHelper simpleUserHooks
130 -- | A customizable version of 'defaultMain'.
131 defaultMainWithHooks
:: UserHooks
-> IO ()
132 defaultMainWithHooks hooks
= getArgs >>= defaultMainHelper hooks
134 -- | A customizable version of 'defaultMain' that also takes the command
136 defaultMainWithHooksArgs
:: UserHooks
-> [String] -> IO ()
137 defaultMainWithHooksArgs
= defaultMainHelper
139 -- | Like 'defaultMain', but accepts the package description as input
140 -- rather than using IO to read it.
141 defaultMainNoRead
:: GenericPackageDescription
-> IO ()
142 defaultMainNoRead
= defaultMainWithHooksNoRead simpleUserHooks
144 -- | A customizable version of 'defaultMainNoRead'.
145 defaultMainWithHooksNoRead
:: UserHooks
-> GenericPackageDescription
-> IO ()
146 defaultMainWithHooksNoRead hooks pkg_descr
=
148 >>= defaultMainHelper hooks
{readDesc
= return (Just pkg_descr
)}
150 -- | A customizable version of 'defaultMainNoRead' that also takes the
151 -- command line arguments.
154 defaultMainWithHooksNoReadArgs
:: UserHooks
-> GenericPackageDescription
-> [String] -> IO ()
155 defaultMainWithHooksNoReadArgs hooks pkg_descr
=
156 defaultMainHelper hooks
{readDesc
= return (Just pkg_descr
)}
158 -- | The central command chooser of the Simple build system,
159 -- with other defaultMain functions acting as exposed callers,
160 -- and with 'topHandler' operating as an exceptions handler.
162 -- This uses 'expandResponse' to read response files, preprocessing
163 -- response files given by "@" prefixes.
165 -- Given hooks and args, this runs 'commandsRun' onto the args,
166 -- getting 'CommandParse' data back, which is then pattern-matched into
167 -- IO actions for execution, with arguments applied by the parser.
168 defaultMainHelper
:: UserHooks
-> Args
-> IO ()
169 defaultMainHelper hooks args
= topHandler
$ do
170 args
' <- expandResponse args
171 command
<- commandsRun
(globalCommand commands
) commands args
'
173 CommandHelp help
-> printHelp help
174 CommandList opts
-> printOptionsList opts
175 CommandErrors errs
-> printErrors errs
176 CommandReadyToGo
(flags
, commandParse
) ->
179 | fromFlag
(globalVersion flags
) -> printVersion
180 | fromFlag
(globalNumericVersion flags
) -> printNumericVersion
181 CommandHelp help
-> printHelp help
182 CommandList opts
-> printOptionsList opts
183 CommandErrors errs
-> printErrors errs
184 CommandReadyToGo action
-> action
186 printHelp help
= getProgName >>= putStr . help
187 printOptionsList
= putStr . unlines
188 printErrors errs
= do
189 putStr (intercalate
"\n" errs
)
190 exitWith (ExitFailure
1)
191 printNumericVersion
= putStrLn $ prettyShow cabalVersion
194 "Cabal library version "
195 ++ prettyShow cabalVersion
197 progs
= addKnownPrograms
(hookedPrograms hooks
) defaultProgramDb
199 [ configureCommand progs
200 `commandAddAction`
\fs
as -> configureAction hooks fs
as >> return ()
201 , buildCommand progs `commandAddAction` buildAction hooks
202 , replCommand progs `commandAddAction` replAction hooks
203 , installCommand `commandAddAction` installAction hooks
204 , copyCommand `commandAddAction` copyAction hooks
205 , haddockCommand `commandAddAction` haddockAction hooks
206 , cleanCommand `commandAddAction` cleanAction hooks
207 , sdistCommand `commandAddAction` sdistAction hooks
208 , hscolourCommand `commandAddAction` hscolourAction hooks
209 , registerCommand `commandAddAction` registerAction hooks
210 , unregisterCommand `commandAddAction` unregisterAction hooks
211 , testCommand `commandAddAction` testAction hooks
212 , benchmarkCommand `commandAddAction` benchAction hooks
215 -- | Combine the preprocessors in the given hooks with the
216 -- preprocessors built into cabal.
220 allSuffixHandlers hooks
=
221 overridesPP
(hookedPreProcessors hooks
) knownSuffixHandlers
223 overridesPP
:: [PPSuffixHandler
] -> [PPSuffixHandler
] -> [PPSuffixHandler
]
224 overridesPP
= unionBy (\x y
-> fst x
== fst y
)
226 configureAction
:: UserHooks
-> ConfigFlags
-> Args
-> IO LocalBuildInfo
227 configureAction hooks flags args
= do
228 distPref
<- findDistPrefOrDefault
(configDistPref flags
)
231 { configDistPref
= toFlag distPref
235 -- See docs for 'HookedBuildInfo'
236 pbi
<- preConf hooks args flags
'
238 (mb_pd_file
, pkg_descr0
) <-
242 (flagToMaybe
(configCabalFilePath flags
))
244 let epkg_descr
= (pkg_descr0
, pbi
)
246 localbuildinfo0
<- confHook hooks epkg_descr flags
'
248 -- remember the .cabal filename if we know it
249 -- and all the extra command line args
252 { pkgDescrFile
= mb_pd_file
253 , extraConfigArgs
= args
255 writePersistBuildConfig distPref localbuildinfo
257 let pkg_descr
= localPkgDescr localbuildinfo
258 postConf hooks args flags
' pkg_descr localbuildinfo
259 return localbuildinfo
261 verbosity
= fromFlag
(configVerbosity flags
)
267 -> IO (Maybe FilePath, GenericPackageDescription
)
268 confPkgDescr hooks verbosity mb_path
= do
269 mdescr
<- readDesc hooks
271 Just descr
-> return (Nothing
, descr
)
273 pdfile
<- case mb_path
of
274 Nothing
-> defaultPackageDesc verbosity
275 Just path
-> return path
276 info verbosity
"Using Parsec parser"
277 descr
<- readGenericPackageDescription verbosity pdfile
278 return (Just pdfile
, descr
)
280 buildAction
:: UserHooks
-> BuildFlags
-> Args
-> IO ()
281 buildAction hooks flags args
= do
282 distPref
<- findDistPrefOrDefault
(buildDistPref flags
)
283 let verbosity
= fromFlag
$ buildVerbosity flags
284 lbi
<- getBuildConfig hooks verbosity distPref
287 { buildDistPref
= toFlag distPref
288 , buildCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
294 (buildProgramPaths flags
')
295 (buildProgramArgs flags
')
303 (return lbi
{withPrograms
= progs
})
305 flags
'{buildArgs
= args
}
308 replAction
:: UserHooks
-> ReplFlags
-> Args
-> IO ()
309 replAction hooks flags args
= do
310 distPref
<- findDistPrefOrDefault
(replDistPref flags
)
311 let verbosity
= fromFlag
$ replVerbosity flags
312 flags
' = flags
{replDistPref
= toFlag distPref
}
314 lbi
<- getBuildConfig hooks verbosity distPref
318 (replProgramPaths flags
')
319 (replProgramArgs flags
')
322 -- As far as I can tell, the only reason this doesn't use
323 -- 'hookedActionWithArgs' is because the arguments of 'replHook'
324 -- takes the args explicitly. UGH. -- ezyang
325 pbi
<- preRepl hooks args flags
'
326 let pkg_descr0
= localPkgDescr lbi
327 sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi
328 let pkg_descr
= updatePackageDescription pbi pkg_descr0
331 { withPrograms
= progs
332 , localPkgDescr
= pkg_descr
334 replHook hooks pkg_descr lbi
' hooks flags
' args
335 postRepl hooks args flags
' pkg_descr lbi
'
337 hscolourAction
:: UserHooks
-> HscolourFlags
-> Args
-> IO ()
338 hscolourAction hooks flags args
= do
339 distPref
<- findDistPrefOrDefault
(hscolourDistPref flags
)
340 let verbosity
= fromFlag
$ hscolourVerbosity flags
341 lbi
<- getBuildConfig hooks verbosity distPref
344 { hscolourDistPref
= toFlag distPref
345 , hscolourCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
353 (getBuildConfig hooks verbosity distPref
)
358 haddockAction
:: UserHooks
-> HaddockFlags
-> Args
-> IO ()
359 haddockAction hooks flags args
= do
360 distPref
<- findDistPrefOrDefault
(haddockDistPref flags
)
361 let verbosity
= fromFlag
$ haddockVerbosity flags
362 lbi
<- getBuildConfig hooks verbosity distPref
365 { haddockDistPref
= toFlag distPref
366 , haddockCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
372 (haddockProgramPaths flags
')
373 (haddockProgramArgs flags
')
381 (return lbi
{withPrograms
= progs
})
383 flags
'{haddockArgs
= args
}
386 cleanAction
:: UserHooks
-> CleanFlags
-> Args
-> IO ()
387 cleanAction hooks flags args
= do
388 distPref
<- findDistPrefOrDefault
(cleanDistPref flags
)
390 elbi
<- tryGetBuildConfig hooks verbosity distPref
393 { cleanDistPref
= toFlag distPref
394 , cleanCabalFilePath
= case elbi
of
396 Right lbi
-> maybeToFlag
(cabalFilePath lbi
)
399 pbi
<- preClean hooks args flags
'
401 (_
, ppd
) <- confPkgDescr hooks verbosity Nothing
402 -- It might seem like we are doing something clever here
403 -- but we're really not: if you look at the implementation
404 -- of 'clean' in the end all the package description is
405 -- used for is to clear out @extra-tmp-files@. IMO,
406 -- the configure script goo should go into @dist@ too!
408 let pkg_descr0
= flattenPackageDescription ppd
409 -- We don't sanity check for clean as an error
410 -- here would prevent cleaning:
411 -- sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi
412 let pkg_descr
= updatePackageDescription pbi pkg_descr0
414 cleanHook hooks pkg_descr
() hooks flags
'
415 postClean hooks args flags
' pkg_descr
()
417 verbosity
= fromFlag
(cleanVerbosity flags
)
419 copyAction
:: UserHooks
-> CopyFlags
-> Args
-> IO ()
420 copyAction hooks flags args
= do
421 distPref
<- findDistPrefOrDefault
(copyDistPref flags
)
422 let verbosity
= fromFlag
$ copyVerbosity flags
423 lbi
<- getBuildConfig hooks verbosity distPref
426 { copyDistPref
= toFlag distPref
427 , copyCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
434 (getBuildConfig hooks verbosity distPref
)
436 flags
'{copyArgs
= args
}
439 installAction
:: UserHooks
-> InstallFlags
-> Args
-> IO ()
440 installAction hooks flags args
= do
441 distPref
<- findDistPrefOrDefault
(installDistPref flags
)
442 let verbosity
= fromFlag
$ installVerbosity flags
443 lbi
<- getBuildConfig hooks verbosity distPref
446 { installDistPref
= toFlag distPref
447 , installCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
454 (getBuildConfig hooks verbosity distPref
)
459 -- Since Cabal-3.4 UserHooks are completely ignored
460 sdistAction
:: UserHooks
-> SDistFlags
-> Args
-> IO ()
461 sdistAction _hooks flags _args
= do
462 (_
, ppd
) <- confPkgDescr emptyUserHooks verbosity Nothing
463 let pkg_descr
= flattenPackageDescription ppd
464 sdist pkg_descr flags srcPref knownSuffixHandlers
466 verbosity
= fromFlag
(sDistVerbosity flags
)
468 testAction
:: UserHooks
-> TestFlags
-> Args
-> IO ()
469 testAction hooks flags args
= do
470 distPref
<- findDistPrefOrDefault
(testDistPref flags
)
471 let verbosity
= fromFlag
$ testVerbosity flags
472 flags
' = flags
{testDistPref
= toFlag distPref
}
479 (getBuildConfig hooks verbosity distPref
)
484 benchAction
:: UserHooks
-> BenchmarkFlags
-> Args
-> IO ()
485 benchAction hooks flags args
= do
486 distPref
<- findDistPrefOrDefault
(benchmarkDistPref flags
)
487 let verbosity
= fromFlag
$ benchmarkVerbosity flags
488 flags
' = flags
{benchmarkDistPref
= toFlag distPref
}
494 (getBuildConfig hooks verbosity distPref
)
499 registerAction
:: UserHooks
-> RegisterFlags
-> Args
-> IO ()
500 registerAction hooks flags args
= do
501 distPref
<- findDistPrefOrDefault
(regDistPref flags
)
502 let verbosity
= fromFlag
$ regVerbosity flags
503 lbi
<- getBuildConfig hooks verbosity distPref
506 { regDistPref
= toFlag distPref
507 , regCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
514 (getBuildConfig hooks verbosity distPref
)
516 flags
'{regArgs
= args
}
519 unregisterAction
:: UserHooks
-> RegisterFlags
-> Args
-> IO ()
520 unregisterAction hooks flags args
= do
521 distPref
<- findDistPrefOrDefault
(regDistPref flags
)
522 let verbosity
= fromFlag
$ regVerbosity flags
523 lbi
<- getBuildConfig hooks verbosity distPref
526 { regDistPref
= toFlag distPref
527 , regCabalFilePath
= maybeToFlag
(cabalFilePath lbi
)
534 (getBuildConfig hooks verbosity distPref
)
541 -> (UserHooks
-> Args
-> flags
-> IO HookedBuildInfo
)
543 -> PackageDescription
552 -> PackageDescription
561 hookedAction verbosity pre_hook cmd_hook
=
565 ( \h _ pd lbi uh flags
->
566 cmd_hook h pd lbi uh flags
571 -> (UserHooks
-> Args
-> flags
-> IO HookedBuildInfo
)
574 -> PackageDescription
583 -> PackageDescription
601 pbi
<- pre_hook hooks args flags
602 lbi0
<- get_build_config
603 let pkg_descr0
= localPkgDescr lbi0
604 sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi
605 let pkg_descr
= updatePackageDescription pbi pkg_descr0
606 lbi
= lbi0
{localPkgDescr
= pkg_descr
}
607 cmd_hook hooks args pkg_descr lbi hooks flags
608 post_hook hooks args flags pkg_descr lbi
610 sanityCheckHookedBuildInfo
611 :: Verbosity
-> PackageDescription
-> HookedBuildInfo
-> IO ()
612 sanityCheckHookedBuildInfo
614 (PackageDescription
{library
= Nothing
})
616 dieWithException verbosity
$ NoLibraryForPackage
617 sanityCheckHookedBuildInfo verbosity pkg_descr
(_
, hookExes
)
618 | exe1
: _
<- nonExistant
=
619 dieWithException verbosity
$ SanityCheckHookedBuildInfo exe1
621 pkgExeNames
= nub (map exeName
(executables pkg_descr
))
622 hookExeNames
= nub (map fst hookExes
)
623 nonExistant
= hookExeNames
\\ pkgExeNames
624 sanityCheckHookedBuildInfo _ _ _
= return ()
626 -- | Try to read the 'localBuildInfoFile'
631 -> IO (Either ConfigStateFileError LocalBuildInfo
)
632 tryGetBuildConfig u v
= try . getBuildConfig u v
634 -- | Read the 'localBuildInfoFile' or throw an exception.
635 getBuildConfig
:: UserHooks
-> Verbosity
-> FilePath -> IO LocalBuildInfo
636 getBuildConfig hooks verbosity distPref
= do
637 lbi_wo_programs
<- getPersistBuildConfig distPref
638 -- Restore info about unconfigured programs, since it is not serialized
643 (builtinPrograms
++ hookedPrograms hooks
)
644 (withPrograms lbi_wo_programs
)
647 case pkgDescrFile lbi
of
648 Nothing
-> return lbi
649 Just pkg_descr_file
-> do
650 outdated
<- checkPersistBuildConfigOutdated distPref pkg_descr_file
652 then reconfigure pkg_descr_file lbi
655 reconfigure
:: FilePath -> LocalBuildInfo
-> IO LocalBuildInfo
656 reconfigure pkg_descr_file lbi
= do
659 ++ " has been changed. "
660 ++ "Re-configuring with most recently used options. "
661 ++ "If this fails, please run configure manually.\n"
662 let cFlags
= configFlags lbi
665 { -- Since the list of unconfigured programs is not serialized,
666 -- restore it to the same value as normally used at the beginning
667 -- of a configure run:
671 (builtinPrograms
++ hookedPrograms hooks
)
673 `
fmap` configPrograms_ cFlags
674 , -- Use the current, not saved verbosity level:
675 configVerbosity
= Flag verbosity
677 configureAction hooks cFlags
' (extraConfigArgs lbi
)
679 -- --------------------------------------------------------------------------
682 clean
:: PackageDescription
-> CleanFlags
-> IO ()
683 clean pkg_descr flags
= do
684 let distPref
= fromFlagOrDefault defaultDistPref
$ cleanDistPref flags
685 notice verbosity
"cleaning..."
688 if fromFlag
(cleanSaveConf flags
)
689 then maybeGetPersistBuildConfig distPref
692 -- remove the whole dist/ directory rather than tracking exactly what files
693 -- we created in there.
694 chattyTry
"removing dist/" $ do
695 exists
<- doesDirectoryExist distPref
696 when exists
(removeDirectoryRecursive distPref
)
698 -- Any extra files the user wants to remove
699 traverse_ removeFileOrDirectory
(extraTmpFiles pkg_descr
)
701 -- If the user wanted to save the config, write it back
702 traverse_
(writePersistBuildConfig distPref
) maybeConfig
704 removeFileOrDirectory
:: FilePath -> IO ()
705 removeFileOrDirectory fname
= do
706 isDir
<- doesDirectoryExist fname
707 isFile
<- doesFileExist fname
709 then removeDirectoryRecursive fname
710 else when isFile
$ removeFile fname
711 verbosity
= fromFlag
(cleanVerbosity flags
)
713 -- --------------------------------------------------------------------------
716 -- | Hooks that correspond to a plain instantiation of the
717 -- \"simple\" build system
718 simpleUserHooks
:: UserHooks
721 { confHook
= configure
722 , postConf
= finalChecks
723 , buildHook
= defaultBuildHook
724 , replHook
= defaultReplHook
725 , copyHook
= \desc lbi _ f
-> install desc lbi f
726 , -- 'install' has correct 'copy' behavior with params
727 testHook
= defaultTestHook
728 , benchHook
= defaultBenchHook
729 , instHook
= defaultInstallHook
730 , cleanHook
= \p _ _ f
-> clean p f
731 , hscolourHook
= \p l h f
-> hscolour p l
(allSuffixHandlers h
) f
732 , haddockHook
= \p l h f
-> haddock p l
(allSuffixHandlers h
) f
733 , regHook
= defaultRegHook
734 , unregHook
= \p l _ f
-> unregister p l f
737 finalChecks _args flags pkg_descr lbi
=
738 checkForeignDeps pkg_descr lbi
(lessVerbose verbosity
)
740 verbosity
= fromFlag
(configVerbosity flags
)
742 -- | Basic autoconf 'UserHooks':
744 -- * 'postConf' runs @.\/configure@, if present.
746 -- * the pre-hooks, except for pre-conf, read additional build information from
747 -- /package/@.buildinfo@, if present.
749 -- Thus @configure@ can use local system information to generate
750 -- /package/@.buildinfo@ and possibly other files.
751 autoconfUserHooks
:: UserHooks
754 { postConf
= defaultPostConf
755 , preBuild
= readHookWithArgs buildVerbosity buildDistPref
756 , preRepl
= readHookWithArgs replVerbosity replDistPref
757 , preCopy
= readHookWithArgs copyVerbosity copyDistPref
758 , preClean
= readHook cleanVerbosity cleanDistPref
759 , preInst
= readHook installVerbosity installDistPref
760 , preHscolour
= readHook hscolourVerbosity hscolourDistPref
761 , preHaddock
= readHookWithArgs haddockVerbosity haddockDistPref
762 , preReg
= readHook regVerbosity regDistPref
763 , preUnreg
= readHook regVerbosity regDistPref
764 , preTest
= readHookWithArgs testVerbosity testDistPref
765 , preBench
= readHookWithArgs benchmarkVerbosity benchmarkDistPref
771 -> PackageDescription
774 defaultPostConf args flags pkg_descr lbi
=
776 let verbosity
= fromFlag
(configVerbosity flags
)
780 (takeDirectory
<$> cabalFilePath lbi
')
781 confExists
<- doesFileExist $ (baseDir lbi
) </> "configure"
788 else dieWithException verbosity ConfigureScriptNotFound
790 pbi
<- getHookedBuildInfo verbosity
(buildDir lbi
)
791 sanityCheckHookedBuildInfo verbosity pkg_descr pbi
792 let pkg_descr
' = updatePackageDescription pbi pkg_descr
793 lbi
' = lbi
{localPkgDescr
= pkg_descr
'}
794 postConf simpleUserHooks args flags pkg_descr
' lbi
'
797 :: (a
-> Flag Verbosity
)
798 -> (a
-> Flag
FilePath)
801 -> IO HookedBuildInfo
802 readHookWithArgs get_verbosity get_dist_pref _ flags
= do
803 dist_dir
<- findDistPrefOrDefault
(get_dist_pref flags
)
804 getHookedBuildInfo verbosity
(dist_dir
</> "build")
806 verbosity
= fromFlag
(get_verbosity flags
)
809 :: (a
-> Flag Verbosity
)
810 -> (a
-> Flag
FilePath)
813 -> IO HookedBuildInfo
814 readHook get_verbosity get_dist_pref a flags
= do
816 dist_dir
<- findDistPrefOrDefault
(get_dist_pref flags
)
817 getHookedBuildInfo verbosity
(dist_dir
</> "build")
819 verbosity
= fromFlag
(get_verbosity flags
)
821 getHookedBuildInfo
:: Verbosity
-> FilePath -> IO HookedBuildInfo
822 getHookedBuildInfo verbosity build_dir
= do
823 maybe_infoFile
<- findHookedPackageDesc verbosity build_dir
824 case maybe_infoFile
of
825 Nothing
-> return emptyHookedBuildInfo
827 info verbosity
$ "Reading parameters from " ++ infoFile
828 readHookedBuildInfo verbosity infoFile
832 -> PackageDescription
837 defaultTestHook args pkg_descr localbuildinfo _ flags
=
838 test args pkg_descr localbuildinfo flags
842 -> PackageDescription
847 defaultBenchHook args pkg_descr localbuildinfo _ flags
=
848 bench args pkg_descr localbuildinfo flags
851 :: PackageDescription
856 defaultInstallHook pkg_descr localbuildinfo _ flags
= do
859 { copyDistPref
= installDistPref flags
860 , copyDest
= installDest flags
861 , copyVerbosity
= installVerbosity flags
863 install pkg_descr localbuildinfo copyFlags
866 { regDistPref
= installDistPref flags
867 , regInPlace
= installInPlace flags
868 , regPackageDB
= installPackageDB flags
869 , regVerbosity
= installVerbosity flags
871 when (hasLibs pkg_descr
) $ register pkg_descr localbuildinfo registerFlags
874 :: PackageDescription
879 defaultBuildHook pkg_descr localbuildinfo hooks flags
=
880 build pkg_descr localbuildinfo flags
(allSuffixHandlers hooks
)
883 :: PackageDescription
889 defaultReplHook pkg_descr localbuildinfo hooks flags args
=
890 repl pkg_descr localbuildinfo flags
(allSuffixHandlers hooks
) args
893 :: PackageDescription
898 defaultRegHook pkg_descr localbuildinfo _ flags
=
900 then register pkg_descr localbuildinfo flags
903 (fromFlag
(regVerbosity flags
))
904 "Package contains no library to register:"
905 (packageId pkg_descr
)