diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-07-31 17:07:39 +0200 |
---|---|---|
committer | Daniel Gröber (dxld) <dxld@darkboxed.org> | 2019-09-17 17:48:26 +0200 |
commit | a93ed8c7d93df1860d2e56b400b724ac47edf470 (patch) | |
tree | 85360f0ca82a0e920ffd38b0aaa0318555d9b072 /src/CabalHelper | |
parent | 5ab34761ed8789286cd382273503129cc7a7134f (diff) |
Merge CompPrograms back into Programs
We need to support passing down the path to ghc to new-build/stack in order
to support using a non-default 'ghc' executable.
Diffstat (limited to 'src/CabalHelper')
-rw-r--r-- | src/CabalHelper/Compiletime/Program/CabalInstall.hs | 14 | ||||
-rw-r--r-- | src/CabalHelper/Compiletime/Program/GHC.hs | 18 | ||||
-rw-r--r-- | src/CabalHelper/Compiletime/Program/Stack.hs | 6 | ||||
-rw-r--r-- | src/CabalHelper/Compiletime/Types.hs | 19 |
4 files changed, 23 insertions, 34 deletions
diff --git a/src/CabalHelper/Compiletime/Program/CabalInstall.hs b/src/CabalHelper/Compiletime/Program/CabalInstall.hs index 4411bc3..2af1cdc 100644 --- a/src/CabalHelper/Compiletime/Program/CabalInstall.hs +++ b/src/CabalHelper/Compiletime/Program/CabalInstall.hs @@ -180,7 +180,7 @@ compileSetupHs (GhcVersion ghcVer) db srcdir = do file = srcdir </> "Setup" - callProcessStderr (Just srcdir) (ghcProgram ?cprogs) $ concat + callProcessStderr (Just srcdir) (ghcProgram ?progs) $ concat [ [ "--make" , "-package-conf", db ] @@ -193,11 +193,11 @@ compileSetupHs (GhcVersion ghcVer) db srcdir = do cabalWithGHCProgOpts :: Progs => [String] cabalWithGHCProgOpts = concat - [ [ "--with-ghc=" ++ ghcProgram ?cprogs ] + [ [ "--with-ghc=" ++ ghcProgram ?progs ] -- Only pass ghc-pkg if it was actually set otherwise we -- might break cabal's guessing logic - , if ghcPkgProgram ?cprogs /= ghcPkgProgram defaultCompPrograms - then [ "--with-ghc-pkg=" ++ ghcPkgProgram ?cprogs ] + , if ghcPkgProgram ?progs /= ghcPkgProgram defaultPrograms + then [ "--with-ghc-pkg=" ++ ghcPkgProgram ?progs ] else [] ] @@ -238,9 +238,9 @@ installCabalLibV2 _ghcVer cv (PackageEnvFile env_file) = do cabalV2WithGHCProgOpts :: Progs => [String] cabalV2WithGHCProgOpts = concat - [ [ "--with-compiler=" ++ ghcProgram ?cprogs ] - , if ghcPkgProgram ?cprogs /= ghcPkgProgram defaultCompPrograms - then [ "--with-hc-pkg=" ++ ghcPkgProgram ?cprogs ] + [ [ "--with-compiler=" ++ ghcProgram ?progs ] + , if ghcPkgProgram ?progs /= ghcPkgProgram defaultPrograms + then [ "--with-hc-pkg=" ++ ghcPkgProgram ?progs ] else [] ] diff --git a/src/CabalHelper/Compiletime/Program/GHC.hs b/src/CabalHelper/Compiletime/Program/GHC.hs index 547911f..e45d921 100644 --- a/src/CabalHelper/Compiletime/Program/GHC.hs +++ b/src/CabalHelper/Compiletime/Program/GHC.hs @@ -66,25 +66,25 @@ newtype GhcVersion = GhcVersion { unGhcVersion :: Version } showGhcVersion :: GhcVersion -> String showGhcVersion (GhcVersion v) = showVersion v -ghcVersion :: (Verbose, CProgs) => IO GhcVersion +ghcVersion :: (Verbose, Progs) => IO GhcVersion ghcVersion = GhcVersion . - parseVer . trim <$> readProcess' (ghcProgram ?cprogs) ["--numeric-version"] "" + parseVer . trim <$> readProcess' (ghcProgram ?progs) ["--numeric-version"] "" -ghcPkgVersion :: (Verbose, CProgs) => IO Version +ghcPkgVersion :: (Verbose, Progs) => IO Version ghcPkgVersion = parseVer . trim . dropWhile (not . isDigit) - <$> readProcess' (ghcPkgProgram ?cprogs) ["--version"] "" + <$> readProcess' (ghcPkgProgram ?progs) ["--version"] "" -createPkgDb :: (Verbose, CProgs) => UnpackedCabalVersion -> IO PackageDbDir +createPkgDb :: (Verbose, Progs) => UnpackedCabalVersion -> IO PackageDbDir createPkgDb cabalVer = do db@(PackageDbDir db_path) <- getPrivateCabalPkgDb $ unpackedToResolvedCabalVersion cabalVer exists <- doesDirectoryExist db_path when (not exists) $ - callProcessStderr Nothing (ghcPkgProgram ?cprogs) ["init", db_path] + callProcessStderr Nothing (ghcPkgProgram ?progs) ["init", db_path] return db -getPrivateCabalPkgDb :: (Verbose, CProgs) => ResolvedCabalVersion -> IO PackageDbDir +getPrivateCabalPkgDb :: (Verbose, Progs) => ResolvedCabalVersion -> IO PackageDbDir getPrivateCabalPkgDb cabalVer = do appdir <- appCacheDir ghcVer <- ghcVersion @@ -113,7 +113,7 @@ listCabalVersions mdb = do let mdbopt = ("--package-conf="++) <$> mdb_path args = ["list", "--simple-output", "Cabal"] ++ maybeToList mdbopt catMaybes . map (fmap snd . parsePkgId) . words - <$> readProcess' (ghcPkgProgram ?cprogs) args "" + <$> readProcess' (ghcPkgProgram ?progs) args "" _ -> mzero cabalVersionExistsInPkgDb @@ -136,7 +136,7 @@ cabalVersionExistsInPkgDb cabalVer db@(PackageDbDir db_path) = do invokeGhc :: Env => GhcInvocation -> IO (Either ExitCode FilePath) invokeGhc GhcInvocation {..} = do - rv <- callProcessStderr' Nothing (ghcProgram ?cprogs) $ concat + rv <- callProcessStderr' Nothing (ghcProgram ?progs) $ concat [ [ "-outputdir", giOutDir , "-o", giOutput ] diff --git a/src/CabalHelper/Compiletime/Program/Stack.hs b/src/CabalHelper/Compiletime/Program/Stack.hs index 353e8f1..3cdf87b 100644 --- a/src/CabalHelper/Compiletime/Program/Stack.hs +++ b/src/CabalHelper/Compiletime/Program/Stack.hs @@ -127,6 +127,6 @@ callStackCmd :: QueryEnvI c 'Stack -> Maybe FilePath -> [String] -> IO () readStackCmd = doStackCmd (\qe -> qeReadProcess qe "") callStackCmd = doStackCmd qeCallProcess -patchCompPrograms :: StackProjPaths -> CompPrograms -> CompPrograms -patchCompPrograms StackProjPaths{sppCompExe} cprogs = - cprogs { ghcProgram = sppCompExe } +patchCompPrograms :: StackProjPaths -> Programs -> Programs +patchCompPrograms StackProjPaths{sppCompExe} progs = + progs { ghcProgram = sppCompExe } diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs index e79c812..1f3bd3d 100644 --- a/src/CabalHelper/Compiletime/Types.hs +++ b/src/CabalHelper/Compiletime/Types.hs @@ -241,9 +241,6 @@ data QueryEnvI c (pt :: ProjType) = QueryEnv , qePrograms :: !Programs -- ^ Field accessor for 'QueryEnv'. - , qeCompPrograms :: !CompPrograms - -- ^ Field accessor for 'QueryEnv'. - , qeProjLoc :: !(ProjLoc pt) -- ^ Field accessor for 'QueryEnv'. Defines path to the project directory, -- i.e. a directory containing a @cabal.project@ file @@ -460,11 +457,9 @@ data StackProjPaths = StackProjPaths -- Beware: GHC 8.0.2 doesn't like these being recursively defined for some -- reason so just keep them unrolled. type Verbose = (?verbose :: Word -> Bool) -type Env = ( ?cprogs :: CompPrograms - , ?progs :: Programs +type Env = ( ?progs :: Programs , ?verbose :: Word -> Bool) -type Progs = (?cprogs :: CompPrograms, ?progs :: Programs) -type CProgs = (?cprogs :: CompPrograms) +type Progs = (?progs :: Programs) -- | Configurable paths to various programs we use. data Programs = Programs @@ -477,11 +472,8 @@ data Programs = Programs -- ^ The path to the @stack@ program. , stackArgsBefore :: ![String] , stackArgsAfter :: ![String] - } deriving (Eq, Ord, Show, Read, Generic, Typeable) --- | Configurable paths to programs only used during helper compilation. -data CompPrograms = CompPrograms - { ghcProgram :: !FilePath + , ghcProgram :: !FilePath -- ^ The path to the @ghc@ program. , ghcPkgProgram :: !FilePath @@ -492,10 +484,7 @@ data CompPrograms = CompPrograms -- | By default all programs use their unqualified names, i.e. they will be -- searched for on @PATH@. defaultPrograms :: Programs -defaultPrograms = Programs "cabal" [] [] "stack" [] [] - -defaultCompPrograms :: CompPrograms -defaultCompPrograms = CompPrograms "ghc" "ghc-pkg" +defaultPrograms = Programs "cabal" [] [] "stack" [] [] "ghc" "ghc-pkg" data CompileOptions = CompileOptions { oVerbose :: Bool |