From fa761dfe6cca25c3592ca306af7d9b9339c1ae74 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 --- GhcMod/Find.hs | 5 +---- core/Language/Haskell/GhcMod/Utils.hs | 21 +++++++++++---------- ghc-mod.cabal | 1 - 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/GhcMod/Find.hs b/GhcMod/Find.hs index ebc60e54a..773c53e7f 100644 --- a/GhcMod/Find.hs +++ b/GhcMod/Find.hs @@ -1,7 +1,6 @@ {-# LANGUAGE CPP, BangPatterns, TupleSections, DeriveGeneric #-} module GhcMod.Find -#ifndef SPEC ( Symbol , SymbolDb , loadSymbolDb @@ -14,9 +13,7 @@ module GhcMod.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 19a0eba8a..5eaea8986 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 f6add42fc..1bd26f75a 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -300,7 +300,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