Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
Show whitespace changes
Inline
Side-by-side
Cabal/Distribution/Simple/GHC.hs
View file @
a2184538
...
@@ -115,7 +115,8 @@ import Data.Maybe ( catMaybes )
...
@@ -115,7 +115,8 @@ import Data.Maybe ( catMaybes )
import
Data.Monoid
as
Mon
(
Monoid
(
..
)
)
import
Data.Monoid
as
Mon
(
Monoid
(
..
)
)
import
Data.Version
(
showVersion
)
import
Data.Version
(
showVersion
)
import
System.Directory
import
System.Directory
(
doesFileExist
,
getAppUserDataDirectory
,
createDirectoryIfMissing
)
(
doesFileExist
,
getAppUserDataDirectory
,
createDirectoryIfMissing
,
canonicalizePath
)
import
System.FilePath
(
(
</>
),
(
<.>
),
takeExtension
,
import
System.FilePath
(
(
</>
),
(
<.>
),
takeExtension
,
takeDirectory
,
replaceExtension
,
takeDirectory
,
replaceExtension
,
splitExtension
,
isRelative
)
splitExtension
,
isRelative
)
...
@@ -200,20 +201,26 @@ guessToolFromGhcPath :: Program -> ConfiguredProgram
...
@@ -200,20 +201,26 @@ guessToolFromGhcPath :: Program -> ConfiguredProgram
->
IO
(
Maybe
(
FilePath
,
[
FilePath
]))
->
IO
(
Maybe
(
FilePath
,
[
FilePath
]))
guessToolFromGhcPath
tool
ghcProg
verbosity
searchpath
guessToolFromGhcPath
tool
ghcProg
verbosity
searchpath
=
do
let
toolname
=
programName
tool
=
do
let
toolname
=
programName
tool
path
=
programPath
ghcProg
given_path
=
programPath
ghcProg
dir
=
takeDirectory
path
given_dir
=
takeDirectory
given_path
versionSuffix
=
takeVersionSuffix
(
dropExeExtension
path
)
real_path
<-
canonicalizePath
given_path
guessNormal
=
dir
</>
toolname
<.>
exeExtension
let
real_dir
=
takeDirectory
real_path
guessGhcVersioned
=
dir
</>
(
toolname
++
"-ghc"
++
versionSuffix
)
versionSuffix
path
=
takeVersionSuffix
(
dropExeExtension
path
)
guessNormal
dir
=
dir
</>
toolname
<.>
exeExtension
guessGhcVersioned
dir
=
dir
</>
(
toolname
++
"-ghc"
++
versionSuffix
dir
)
<.>
exeExtension
<.>
exeExtension
guessVersioned
=
dir
</>
(
toolname
++
versionSuffix
)
guessVersioned
dir
=
dir
</>
(
toolname
++
versionSuffix
dir
)
<.>
exeExtension
<.>
exeExtension
guesses
|
null
versionSuffix
=
[
guessNormal
]
mkGuesses
dir
|
null
(
versionSuffix
dir
)
=
[
guessNormal
dir
]
|
otherwise
=
[
guessGhcVersioned
,
|
otherwise
=
[
guessGhcVersioned
dir
,
guessVersioned
,
guessVersioned
dir
,
guessNormal
]
guessNormal
dir
]
guesses
=
mkGuesses
given_dir
++
if
real_path
==
given_path
then
[]
else
mkGuesses
real_dir
info
verbosity
$
"looking for tool "
++
toolname
info
verbosity
$
"looking for tool "
++
toolname
++
" near compiler in "
++
dir
++
" near compiler in "
++
given_
dir
exists
<-
mapM
doesFileExist
guesses
exists
<-
mapM
doesFileExist
guesses
case
[
file
|
(
file
,
True
)
<-
zip
guesses
exists
]
of
case
[
file
|
(
file
,
True
)
<-
zip
guesses
exists
]
of
-- If we can't find it near ghc, fall back to the usual
-- If we can't find it near ghc, fall back to the usual
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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