2 {-# LANGUAGE DeriveDataTypeable #-}
3 {-# LANGUAGE DeriveGeneric #-}
4 {-# LANGUAGE FlexibleContexts #-}
5 {-# LANGUAGE RankNTypes #-}
7 -----------------------------------------------------------------------------
10 -- Module : Distribution.Simple.Setup.Copy
11 -- Copyright : Isaac Jones 2003-2004
15 -- Maintainer : cabal-devel@haskell.org
16 -- Portability : portable
18 -- Definition of the copy command-line options.
19 -- See: @Distribution.Simple.Setup@
20 module Distribution
.Simple
.Setup
.Copy
27 import Distribution
.Compat
.Prelude
hiding (get
)
30 import Distribution
.ReadE
31 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
32 import Distribution
.Simple
.Flag
33 import Distribution
.Simple
.InstallDirs
34 import Distribution
.Simple
.Utils
35 import Distribution
.Verbosity
37 import Distribution
.Simple
.Setup
.Common
39 -- ------------------------------------------------------------
43 -- ------------------------------------------------------------
45 -- | Flags to @copy@: (destdir, copy-prefix (backwards compat), verbosity)
46 data CopyFlags
= CopyFlags
47 { copyDest
:: Flag CopyDest
48 , copyDistPref
:: Flag
FilePath
49 , copyVerbosity
:: Flag Verbosity
50 , -- This is the same hack as in 'buildArgs'. But I (ezyang) don't
51 -- think it's a hack, it's the right way to make hooks more robust
52 -- TODO: Stop using this eventually when 'UserHooks' gets changed
54 , copyCabalFilePath
:: Flag
FilePath
56 deriving (Show, Generic
)
58 defaultCopyFlags
:: CopyFlags
61 { copyDest
= Flag NoCopyDest
62 , copyDistPref
= NoFlag
63 , copyVerbosity
= Flag normal
65 , copyCabalFilePath
= mempty
68 copyCommand
:: CommandUI CopyFlags
71 { commandName
= "copy"
72 , commandSynopsis
= "Copy the files of all/specific components to install locations."
73 , commandDescription
= Just
$ \_
->
75 "Components encompass executables and libraries. "
76 ++ "Does not call register, and allows a prefix at install time. "
77 ++ "Without the --destdir flag, configure determines location.\n"
78 , commandNotes
= Just
$ \pname
->
83 ++ " All the components in the package\n"
87 ++ " A component (i.e. lib, exe, test suite)"
89 usageAlternatives
"copy" $
91 , "COMPONENTS [FLAGS]"
93 , commandDefaultFlags
= defaultCopyFlags
94 , commandOptions
= \showOrParseArgs
-> case showOrParseArgs
of
97 ( (`
notElem`
["target-package-db"])
100 $ copyOptions ShowArgs
101 ParseArgs
-> copyOptions ParseArgs
104 copyOptions
:: ShowOrParseArgs
-> [OptionField CopyFlags
]
105 copyOptions showOrParseArgs
=
106 [ optionVerbosity copyVerbosity
(\v flags
-> flags
{copyVerbosity
= v
})
109 (\d flags
-> flags
{copyDistPref
= d
})
114 "directory to copy files to, prepended to installation directories"
116 ( \v flags
-> case copyDest flags
of
117 Flag
(CopyToDb _
) -> error "Use either 'destdir' or 'target-package-db'."
118 _
-> flags
{copyDest
= v
}
122 (succeedReadE
(Flag
. CopyTo
))
123 (\f -> case f
of Flag
(CopyTo p
) -> [p
]; _
-> [])
127 ["target-package-db"]
128 "package database to copy files into. Required when using ${pkgroot} prefix."
130 ( \v flags
-> case copyDest flags
of
131 NoFlag
-> flags
{copyDest
= v
}
132 Flag NoCopyDest
-> flags
{copyDest
= v
}
133 _
-> error "Use either 'destdir' or 'target-package-db'."
137 (succeedReadE
(Flag
. CopyToDb
))
138 (\f -> case f
of Flag
(CopyToDb p
) -> [p
]; _
-> [])
142 emptyCopyFlags
:: CopyFlags
143 emptyCopyFlags
= mempty
145 instance Monoid CopyFlags
where
149 instance Semigroup CopyFlags
where