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
a2184538
Commit
a2184538
authored
Dec 21, 2015
by
Edward Z. Yang
Browse files
Also probe in canonicalized path, if binary was a symlink.
Signed-off-by:
Edward Z. Yang
<
ezyang@cs.stanford.edu
>
parent
679812d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Simple/GHC.hs
View file @
a2184538
...
...
@@ -115,7 +115,8 @@ import Data.Maybe ( catMaybes )
import
Data.Monoid
as
Mon
(
Monoid
(
..
)
)
import
Data.Version
(
showVersion
)
import
System.Directory
(
doesFileExist
,
getAppUserDataDirectory
,
createDirectoryIfMissing
)
(
doesFileExist
,
getAppUserDataDirectory
,
createDirectoryIfMissing
,
canonicalizePath
)
import
System.FilePath
(
(
</>
),
(
<.>
),
takeExtension
,
takeDirectory
,
replaceExtension
,
splitExtension
,
isRelative
)
...
...
@@ -200,20 +201,26 @@ guessToolFromGhcPath :: Program -> ConfiguredProgram
->
IO
(
Maybe
(
FilePath
,
[
FilePath
]))
guessToolFromGhcPath
tool
ghcProg
verbosity
searchpath
=
do
let
toolname
=
programName
tool
path
=
programPath
ghcProg
dir
=
takeDirectory
path
versionSuffix
=
takeVersionSuffix
(
dropExeExtension
path
)
guessNormal
=
dir
</>
toolname
<.>
exeExtension
guessGhcVersioned
=
dir
</>
(
toolname
++
"-ghc"
++
versionSuffix
)
<.>
exeExtension
guessVersioned
=
dir
</>
(
toolname
++
versionSuffix
)
<.>
exeExtension
guesses
|
null
versionSuffix
=
[
guessNormal
]
|
otherwise
=
[
guessGhcVersioned
,
guessVersioned
,
guessNormal
]
given_path
=
programPath
ghcProg
given_dir
=
takeDirectory
given_path
real_path
<-
canonicalizePath
given_path
let
real_dir
=
takeDirectory
real_path
versionSuffix
path
=
takeVersionSuffix
(
dropExeExtension
path
)
guessNormal
dir
=
dir
</>
toolname
<.>
exeExtension
guessGhcVersioned
dir
=
dir
</>
(
toolname
++
"-ghc"
++
versionSuffix
dir
)
<.>
exeExtension
guessVersioned
dir
=
dir
</>
(
toolname
++
versionSuffix
dir
)
<.>
exeExtension
mkGuesses
dir
|
null
(
versionSuffix
dir
)
=
[
guessNormal
dir
]
|
otherwise
=
[
guessGhcVersioned
dir
,
guessVersioned
dir
,
guessNormal
dir
]
guesses
=
mkGuesses
given_dir
++
if
real_path
==
given_path
then
[]
else
mkGuesses
real_dir
info
verbosity
$
"looking for tool "
++
toolname
++
" near compiler in "
++
dir
++
" near compiler in "
++
given_
dir
exists
<-
mapM
doesFileExist
guesses
case
[
file
|
(
file
,
True
)
<-
zip
guesses
exists
]
of
-- If we can't find it near ghc, fall back to the usual
...
...
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