Commit 7d16d8a2 authored by Moritz Angermann's avatar Moritz Angermann Committed by Ben Gamari

Fix #elfi -> #elif; unbreak -Werror.

Reviewers: bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4209
parent b8e324a4
......@@ -48,7 +48,10 @@ import Platform
import Util
import DynFlags
#if defined(darwin_HOST_OS) || defined(linux_HOST_OS)
import System.Environment (getExecutablePath)
#endif
import System.FilePath
import System.IO
import System.Directory
......
......@@ -65,6 +65,9 @@ import System.Directory ( doesDirectoryExist, getDirectoryContents,
getCurrentDirectory )
import System.Exit ( exitWith, ExitCode(..) )
import System.Environment ( getArgs, getProgName, getEnv )
#if defined(darwin_HOST_OS) || defined(linux_HOST_OS)
import System.Environment ( getExecutablePath )
#endif
import System.IO
import System.IO.Error
import GHC.IO.Exception (IOErrorType(InappropriateType))
......@@ -2076,6 +2079,7 @@ dieForcible s = die (s ++ " (use --force to override)")
-----------------------------------------
-- Cut and pasted from ghc/compiler/main/SysTools
getLibDir :: IO (Maybe String)
#if defined(mingw32_HOST_OS)
subst :: Char -> Char -> String -> String
subst a b ls = map (\ x -> if x == a then b else x) ls
......@@ -2083,7 +2087,6 @@ subst a b ls = map (\ x -> if x == a then b else x) ls
unDosifyPath :: FilePath -> FilePath
unDosifyPath xs = subst '\\' '/' xs
getLibDir :: IO (Maybe String)
getLibDir = do base <- getExecDir "/ghc-pkg.exe"
case base of
Nothing -> return Nothing
......@@ -2116,7 +2119,7 @@ getExecPath = try_size 2048 -- plenty, PATH_MAX is 512 under Win32.
foreign import WINDOWS_CCONV unsafe "windows.h GetModuleFileNameW"
c_GetModuleFileName :: Ptr () -> CWString -> Word32 -> IO Word32
#elfi defined(darwin_HOST_OS) || defined(linux_HOST_OS)
#elif defined(darwin_HOST_OS) || defined(linux_HOST_OS)
-- TODO: a) this is copy-pasta from SysTools.hs / getBaseDir. Why can't we reuse
-- this here? and parameterise getBaseDir over the executable (for
-- windows)?
......@@ -2128,7 +2131,6 @@ foreign import WINDOWS_CCONV unsafe "windows.h GetModuleFileNameW"
-- Answer: yes this should happen. No one has found the time just yet.
getLibDir = Just . (\p -> p </> "lib") . takeDirectory . takeDirectory <$> getExecutablePath
#else
getLibDir :: IO (Maybe String)
getLibDir = return Nothing
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment