From 1978a4b27c04dd593c5810ad9837b883e3519315 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 17 Aug 2015 13:20:43 -0700 Subject: [PATCH] Add compilerExeName helper --- src/Stack/Build/Haddock.hs | 5 +---- src/Stack/Ghci.hs | 5 +---- src/Stack/Setup.hs | 7 ++----- src/Stack/Types/Compiler.hs | 4 ++++ 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Stack/Build/Haddock.hs b/src/Stack/Build/Haddock.hs index 40c920c0cc..7c2e67eb58 100644 --- a/src/Stack/Build/Haddock.hs +++ b/src/Stack/Build/Haddock.hs @@ -203,12 +203,9 @@ generateHaddockIndex descr envOverride wc packageIDs docRelDir destDir = do readProcessNull (Just destDir) envOverride - exeName + (compilerExeName wc) (["--gen-contents", "--gen-index"] ++ concatMap fst interfaceOpts) where - exeName = case wc of - Ghc -> "haddock" - Ghcjs -> "haddock-ghcjs" toInterfaceOpt pid@(PackageIdentifier name _) = do let interfaceRelFile = docRelDir FP. packageIdentifierString pid FP. diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index af8141a1bb..671049c1c2 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -78,15 +78,12 @@ ghci GhciOpts{..} = do odir = [ "-odir=" <> toFilePath (objectInterfaceDir bconfig) , "-hidir=" <> toFilePath (objectInterfaceDir bconfig)] - defaultCommand = case wc of - Ghc -> "ghc" - Ghcjs -> "ghcjs" $logInfo ("Configuring GHCi with the following packages: " <> T.intercalate ", " (map (packageNameText . ghciPkgName) pkgs)) exec defaultEnvSettings - (fromMaybe defaultCommand ghciGhcCommand) + (fromMaybe (compilerExeName wc) ghciGhcCommand) ("--interactive" : odir <> pkgopts <> srcfiles <> ghciArgs) -- | Figure out the main-is file to load based on the targets. Sometimes there diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index a03919285b..bdf3dcf1c6 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -379,10 +379,7 @@ upgradeCabal menv wc = do let ident = PackageIdentifier name newest m <- unpackPackageIdents menv tmpdir' Nothing (Set.singleton ident) - let compilerName = case wc of - Ghc -> "ghc" - Ghcjs -> "ghcjs" - compilerPath <- join $ findExecutable menv compilerName + compilerPath <- join $ findExecutable menv (compilerExeName wc) newestDir <- parseRelDir $ versionString newest let installRoot = toFilePath $ parent (parent compilerPath) $(mkRelDir "new-cabal") @@ -393,7 +390,7 @@ upgradeCabal menv wc = do Nothing -> error $ "upgradeCabal: Invariant violated, dir missing" Just dir -> return dir - runIn dir compilerName menv ["Setup.hs"] Nothing + runIn dir (compilerExeName wc) menv ["Setup.hs"] Nothing let setupExe = toFilePath $ dir $(mkRelFile "Setup") dirArgument name' = concat [ "--" diff --git a/src/Stack/Types/Compiler.hs b/src/Stack/Types/Compiler.hs index 2e24ca4ecb..9e76fbc1ac 100644 --- a/src/Stack/Types/Compiler.hs +++ b/src/Stack/Types/Compiler.hs @@ -71,3 +71,7 @@ isWantedCompiler check (GhcVersion wanted) (GhcVersion actual) = isWantedCompiler check (GhcjsVersion wanted wantedGhc) (GhcjsVersion actual actualGhc) = checkVersion check wanted actual && checkVersion check wantedGhc actualGhc isWantedCompiler _ _ _ = False + +compilerExeName :: WhichCompiler -> String +compilerExeName Ghc = "ghc" +compilerExeName Ghcjs = "ghcjs"