Merge pull request #293 from DanielG/dev-exec-path

Fall back to getProgName when exeutable name is not available
This commit is contained in:
Kazu Yamamoto 2014-07-21 11:11:25 +09:00
commit 10ef20b967

View File

@ -34,7 +34,7 @@ import Name (getOccString)
import System.Directory (doesDirectoryExist, getAppUserDataDirectory, doesFileExist, getModificationTime) import System.Directory (doesDirectoryExist, getAppUserDataDirectory, doesFileExist, getModificationTime)
import System.FilePath ((</>), takeDirectory) import System.FilePath ((</>), takeDirectory)
import System.IO import System.IO
import System.Environment (getExecutablePath) import System.Environment
#ifndef MIN_VERSION_containers #ifndef MIN_VERSION_containers
#define MIN_VERSION_containers(x,y,z) 1 #define MIN_VERSION_containers(x,y,z) 1
@ -90,10 +90,17 @@ loadSymbolDb = SymbolDb <$> readSymbolDb
ghcModExecutable :: IO FilePath ghcModExecutable :: IO FilePath
#ifndef SPEC #ifndef SPEC
ghcModExecutable = do ghcModExecutable = do
dir <- takeDirectory <$> getExecutablePath dir <- getExecutablePath'
return $ dir </> "ghc-mod" return $ dir </> "ghc-mod"
#else #else
ghcModExecutable = return "dist/build/ghc-mod/ghc-mod" ghcModExecutable = return "dist/build/ghc-mod/ghc-mod"
#endif
where
getExecutablePath' :: IO FilePath
# if __GLASGOW_HASKELL__ >= 706
getExecutablePath' = takeDirectory <$> getExecutablePath
# else
getExecutablePath' = return ""
# endif # endif
readSymbolDb :: IO (Map Symbol [ModuleString]) readSymbolDb :: IO (Map Symbol [ModuleString])