Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
fd3e3889
Commit
fd3e3889
authored
Jul 10, 2018
by
Alexis Williams
Browse files
Add --env-cwd
parent
563d5017
Changes
1
Hide whitespace changes
Inline
Side-by-side
cabal-install/Distribution/Client/CmdInstall.hs
View file @
fd3e3889
...
...
@@ -124,19 +124,21 @@ import Distribution.Utils.NubList
(
fromNubList
)
import
System.Directory
(
getHomeDirectory
,
doesFileExist
,
createDirectoryIfMissing
,
getTemporaryDirectory
,
makeAbsolute
)
,
getTemporaryDirectory
,
makeAbsolute
,
getCurrentDirectory
)
import
System.FilePath
(
(
</>
),
takeDirectory
)
data
NewInstallFlags
=
NewInstallFlags
{
ninstInstallLibs
::
Flag
Bool
,
ninstEnvironmentPath
::
Flag
FilePath
,
ninstEnvironmentCwd
::
Flag
Bool
}
defaultNewInstallFlags
::
NewInstallFlags
defaultNewInstallFlags
=
NewInstallFlags
{
ninstInstallLibs
=
toFlag
False
,
ninstEnvironmentPath
=
mempty
,
ninstEnvironmentCwd
=
toFlag
False
}
newInstallOptions
::
ShowOrParseArgs
->
[
OptionField
NewInstallFlags
]
...
...
@@ -149,6 +151,10 @@ newInstallOptions _ =
"Set the environment file that may be modified."
ninstEnvironmentPath
(
\
pf
flags
->
flags
{
ninstEnvironmentPath
=
pf
})
(
reqArg
"PATH"
(
succeedReadE
Flag
)
flagToList
)
,
option
[]
[
"env-cwd"
]
"Modify the current directory's environment instead of the global one."
ninstEnvironmentCwd
(
\
pf
flags
->
flags
{
ninstEnvironmentCwd
=
pf
})
trueArg
]
installCommand
::
CommandUI
(
ConfigFlags
,
ConfigExFlags
,
InstallFlags
...
...
@@ -405,10 +411,18 @@ installAction (configFlags, configExFlags, installFlags, haddockFlags, newInstal
compilerId
@
(
CompilerId
compilerFlavor
compilerVersion
)
},
platform
,
progDb'
)
<-
configCompilerEx
hcFlavor
hcPath
hcPkg
progDb
verbosity
cwd
<-
getCurrentDirectory
let
envFile
=
flip
fromFlagOrDefault
(
ninstEnvironmentPath
newInstallFlags
)
$
defaultEnv
=
home
</>
".ghc"
</>
ghcPlatformAndVersionString
platform
compilerVersion
</>
"environments"
</>
"default"
cwdEnv
=
cwd
</>
".ghc.environment."
++
ghcPlatformAndVersionString
platform
ghcversion
envFile
=
if
fromFlagOrDefault
False
(
ninstEnvironmentCwd
newInstallFlags
)
then
cwdEnv
else
fromFlagOrDefault
defaultEnv
(
ninstEnvironmentPath
newInstallFlags
)
GhcImplInfo
{
supportsPkgEnvFiles
}
=
getImplInfo
compiler
-- Why? We know what the first part will be, we only care about the packages.
filterEnvEntries
=
filter
$
\
case
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment