2 import Distribution.PackageDescription
3 import Distribution.Setup
4 import Distribution.Simple
5 import Distribution.Simple.Configure
6 import Distribution.Simple.LocalBuildInfo
7 import Distribution.Verbosity
8 import System.Environment
11 main = do args <- getArgs
13 pref : ghcpkg : args' ->
14 let verbosity = case args' of
21 _ -> error ("Bad arguments: " ++ show args)
22 in doit pref ghcpkg verbosity
24 error "Missing arguments"
26 doit :: FilePath -> FilePath -> Verbosity -> IO ()
27 doit pref ghcpkg verbosity =
28 do let userHooks = simpleUserHooks
29 copyFlags = CopyFlags {
30 copyDest = NoCopyDest,
31 copyVerbose = verbosity
33 registerFlags = RegisterFlags {
34 regUser = MaybeUserGlobal,
37 regWithHcPkg = Just ghcpkg,
38 regVerbose = verbosity
40 lbi <- getPersistBuildConfig
41 let pd = localPkgDescr lbi
42 -- XXX This is an almighty hack, shadowing the base
44 mkLib filt = case library pd of
46 let ems = filter filt $ exposedModules lib
51 error "Expected a library, but none found"
52 -- There's no files for GHC.Prim, so we will fail if we
54 pd_copy = pd { library = Just (mkLib ("GHC.Prim" /=)) }
55 pd_reg = pd { library = Just (mkLib (const True)) }
56 -- When coying, we need to actually give a concrete
57 -- directory to copy to rather than "$topdir"
58 lbi_copy = lbi { prefix = pref }
59 -- When we run GHC we give it a $topdir that includes the
60 -- $compiler/lib/ part of libsubdir, so we only want the
61 -- $pkgid part in the package.conf file. This is a bit of
63 lbi_reg = lbi { libsubdir = "$pkgid" }
64 (copyHook simpleUserHooks) pd_copy lbi_copy userHooks copyFlags
65 (regHook simpleUserHooks) pd_reg lbi_reg userHooks registerFlags