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.Install
14 -- Copyright : Isaac Jones 2003-2004
18 -- Maintainer : cabal-devel@haskell.org
19 -- Portability : portable
21 -- Definition of the install command-line options.
22 -- See: @Distribution.Simple.Setup@
23 module Distribution
.Simple
.Setup
.Install
28 , installCabalFilePath
38 import Distribution
.Compat
.Prelude
hiding (get
)
41 import Distribution
.ReadE
42 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
43 import Distribution
.Simple
.Compiler
44 import Distribution
.Simple
.Flag
45 import Distribution
.Simple
.InstallDirs
46 import Distribution
.Simple
.Setup
.Common
47 import Distribution
.Simple
.Utils
48 import Distribution
.Utils
.Path
49 import Distribution
.Verbosity
51 -- ------------------------------------------------------------
55 -- ------------------------------------------------------------
57 -- | Flags to @install@: (package db, verbosity)
58 data InstallFlags
= InstallFlags
59 { installCommonFlags
:: !CommonSetupFlags
60 , installPackageDB
:: Flag PackageDB
61 , installDest
:: Flag CopyDest
62 , installUseWrapper
:: Flag
Bool
63 , installInPlace
:: Flag
Bool
65 deriving (Show, Generic
)
67 pattern InstallCommonFlags
69 -> Flag
(SymbolicPath Pkg
(Dir Dist
))
70 -> Flag
(SymbolicPath CWD
(Dir Pkg
))
71 -> Flag
(SymbolicPath Pkg File
)
74 pattern InstallCommonFlags
78 , installCabalFilePath
81 ( installCommonFlags
->
83 { setupVerbosity
= installVerbosity
84 , setupDistPref
= installDistPref
85 , setupWorkingDir
= installWorkingDir
86 , setupCabalFilePath
= installCabalFilePath
87 , setupTargets
= installTargets
91 defaultInstallFlags
:: InstallFlags
94 { installCommonFlags
= defaultCommonSetupFlags
95 , installPackageDB
= NoFlag
96 , installDest
= Flag NoCopyDest
97 , installUseWrapper
= Flag
False
98 , installInPlace
= Flag
False
101 installCommand
:: CommandUI InstallFlags
104 { commandName
= "install"
106 "Copy the files into the install locations. Run register."
107 , commandDescription
= Just
$ \_
->
109 "Unlike the copy command, install calls the register command. "
110 ++ "If you want to install into a location that is not what was "
111 ++ "specified in the configure step, use the copy command.\n"
112 , commandNotes
= Nothing
113 , commandUsage
= \pname
->
114 "Usage: " ++ pname
++ " install [FLAGS]\n"
115 , commandDefaultFlags
= defaultInstallFlags
116 , commandOptions
= \showOrParseArgs
->
117 withCommonSetupOptions
119 (\c f
-> f
{installCommonFlags
= c
})
121 $ case showOrParseArgs
of
124 ( (`
notElem`
["target-package-db"])
128 ParseArgs
-> installOptions
131 installOptions
:: [OptionField InstallFlags
]
136 "install the package in the install subdirectory of the dist prefix, so it can be used without being installed"
138 (\v flags
-> flags
{installInPlace
= v
})
143 "using shell script wrappers around executables"
145 (\v flags
-> flags
{installUseWrapper
= v
})
152 (\v flags
-> flags
{installPackageDB
= v
})
157 , "upon configuration register this package in the user's local package database"
160 ( Flag GlobalPackageDB
162 , "(default) upon configuration register this package in the system-wide package database"
168 ["target-package-db"]
169 "package database to install into. Required when using ${pkgroot} prefix."
171 (\v flags
-> flags
{installDest
= v
})
174 (succeedReadE
(Flag
. CopyToDb
))
175 (\f -> case f
of Flag
(CopyToDb p
) -> [p
]; _
-> [])
179 emptyInstallFlags
:: InstallFlags
180 emptyInstallFlags
= mempty
182 instance Monoid InstallFlags
where
186 instance Semigroup InstallFlags
where