From f149c05e54cf2fbb037c4656ab2b766a0e2031d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Thu, 12 Jan 2017 17:03:31 +0100 Subject: [PATCH] Remove 'SPEC' ifdefs --- GhcModExe/Find.hs | 5 +---- core/Language/Haskell/GhcMod/Utils.hs | 21 +++++++++++---------- ghc-mod.cabal | 1 - 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/GhcModExe/Find.hs b/GhcModExe/Find.hs index 8ed922594..3e0a7fd04 100644 --- a/GhcModExe/Find.hs +++ b/GhcModExe/Find.hs @@ -1,7 +1,6 @@ {-# LANGUAGE CPP, BangPatterns, TupleSections, DeriveGeneric #-} module GhcModExe.Find -#ifndef SPEC ( Symbol , SymbolDb , loadSymbolDb @@ -14,9 +13,7 @@ module GhcModExe.Find , AsyncSymbolDb , newAsyncSymbolDb , getAsyncSymbolDb - ) -#endif - where + ) where import qualified GHC as G import FastString diff --git a/core/Language/Haskell/GhcMod/Utils.hs b/core/Language/Haskell/GhcMod/Utils.hs index 5de4ca3c7..29383610d 100644 --- a/core/Language/Haskell/GhcMod/Utils.hs +++ b/core/Language/Haskell/GhcMod/Utils.hs @@ -79,17 +79,18 @@ whenM mb ma = mb >>= flip when ma -- | Returns the path to the currently running ghc-mod executable. With ghc<7.6 -- this is a guess but >=7.6 uses 'getExecutablePath'. ghcModExecutable :: IO FilePath -#ifndef SPEC ghcModExecutable = do - dir <- takeDirectory <$> getExecutablePath' - return $ (if dir == "." then "" else dir) "ghc-mod" -#else -ghcModExecutable = do - gpp <- lookupEnv "STACK_EXE" - case gpp of - Just _ -> fmap ( "ghc-mod") getBinDir - _ -> fmap ( "dist/build/ghc-mod/ghc-mod") getCurrentDirectory -#endif + exe <- getExecutablePath' + stack <- lookupEnv "STACK_EXE" + case takeBaseName exe of + "spec" | Just _ <- stack -> + ( "ghc-mod") <$> getBinDir + "spec" -> + ( "dist/build/ghc-mod-real/ghc-mod-real") <$> getCurrentDirectory + "ghc-mod-real" -> + return exe + _ -> + return $ takeDirectory exe "ghc-mod" getExecutablePath' :: IO FilePath #if __GLASGOW_HASKELL__ >= 706 diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 1a01b8772..f827596b7 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -285,7 +285,6 @@ Test-Suite spec Main-Is: Main.hs Hs-Source-Dirs: test, src Ghc-Options: -Wall -fno-warn-deprecations -threaded - CPP-Options: -DSPEC=1 Type: exitcode-stdio-1.0 Other-Modules: Paths_ghc_mod Dir