2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE DeriveDataTypeable #-}
4 {-# LANGUAGE DeriveGeneric #-}
5 {-# LANGUAGE FlexibleContexts #-}
6 {-# LANGUAGE PatternSynonyms #-}
7 {-# LANGUAGE RankNTypes #-}
8 {-# LANGUAGE ViewPatterns #-}
10 -----------------------------------------------------------------------------
13 -- Module : Distribution.Simple.Setup.Copy
14 -- Copyright : Isaac Jones 2003-2004
18 -- Maintainer : cabal-devel@haskell.org
19 -- Portability : portable
21 -- Definition of the copy command-line options.
22 -- See: @Distribution.Simple.Setup@
23 module Distribution
.Simple
.Setup
.Copy
38 import Distribution
.Compat
.Prelude
hiding (get
)
41 import Distribution
.ReadE
42 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
43 import Distribution
.Simple
.Flag
44 import Distribution
.Simple
.InstallDirs
45 import Distribution
.Simple
.Setup
.Common
46 import Distribution
.Simple
.Utils
47 import Distribution
.Utils
.Path
48 import Distribution
.Verbosity
50 -- ------------------------------------------------------------
54 -- ------------------------------------------------------------
56 -- | Flags to @copy@: (destdir, copy-prefix (backwards compat), verbosity)
57 data CopyFlags
= CopyFlags
58 { copyCommonFlags
:: !CommonSetupFlags
59 , copyDest
:: Flag CopyDest
61 deriving (Show, Generic
)
63 pattern CopyCommonFlags
65 -> Flag
(SymbolicPath Pkg
(Dir Dist
))
66 -> Flag
(SymbolicPath CWD
(Dir Pkg
))
67 -> Flag
(SymbolicPath Pkg File
)
70 pattern CopyCommonFlags
79 { setupVerbosity
= copyVerbosity
80 , setupDistPref
= copyDistPref
81 , setupWorkingDir
= copyWorkingDir
82 , setupCabalFilePath
= copyCabalFilePath
83 , setupTargets
= copyTargets
87 instance Binary CopyFlags
88 instance Structured CopyFlags
90 defaultCopyFlags
:: CopyFlags
93 { copyCommonFlags
= defaultCommonSetupFlags
94 , copyDest
= Flag NoCopyDest
97 copyCommand
:: CommandUI CopyFlags
100 { commandName
= "copy"
101 , commandSynopsis
= "Copy the files of all/specific components to install locations."
102 , commandDescription
= Just
$ \_
->
104 "Components encompass executables and libraries. "
105 ++ "Does not call register, and allows a prefix at install time. "
106 ++ "Without the --destdir flag, configure determines location.\n"
107 , commandNotes
= Just
$ \pname
->
112 ++ " All the components in the package\n"
116 ++ " A component (i.e. lib, exe, test suite)"
118 usageAlternatives
"copy" $
120 , "COMPONENTS [FLAGS]"
122 , commandDefaultFlags
= defaultCopyFlags
123 , commandOptions
= \showOrParseArgs
-> case showOrParseArgs
of
126 ( (`
notElem`
["target-package-db"])
129 $ copyOptions ShowArgs
130 ParseArgs
-> copyOptions ParseArgs
133 copyOptions
:: ShowOrParseArgs
-> [OptionField CopyFlags
]
134 copyOptions showOrParseArgs
=
135 withCommonSetupOptions
137 (\c f
-> f
{copyCommonFlags
= c
})
142 "directory to copy files to, prepended to installation directories"
144 ( \v flags
-> case copyDest flags
of
145 Flag
(CopyToDb _
) -> error "Use either 'destdir' or 'target-package-db'."
146 _
-> flags
{copyDest
= v
}
150 (succeedReadE
(Flag
. CopyTo
))
151 (\f -> case f
of Flag
(CopyTo p
) -> [p
]; _
-> [])
155 ["target-package-db"]
156 "package database to copy files into. Required when using ${pkgroot} prefix."
158 ( \v flags
-> case copyDest flags
of
159 NoFlag
-> flags
{copyDest
= v
}
160 Flag NoCopyDest
-> flags
{copyDest
= v
}
161 _
-> error "Use either 'destdir' or 'target-package-db'."
165 (succeedReadE
(Flag
. CopyToDb
))
166 (\f -> case f
of Flag
(CopyToDb p
) -> [p
]; _
-> [])
170 emptyCopyFlags
:: CopyFlags
171 emptyCopyFlags
= mempty
173 instance Monoid CopyFlags
where
177 instance Semigroup CopyFlags
where