From f03e60f73844afe81bdefddce28733ac16da3c4a Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Thu, 14 Dec 2017 16:00:59 +0200 Subject: Tests pass for backpack --- src/CabalHelper/Runtime/Main.hs | 22 ++++++++++++++++------ tests/GhcSession.hs | 11 +++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/CabalHelper/Runtime/Main.hs b/src/CabalHelper/Runtime/Main.hs index e2829b3..5c2b9fb 100644 --- a/src/CabalHelper/Runtime/Main.hs +++ b/src/CabalHelper/Runtime/Main.hs @@ -338,7 +338,6 @@ main = do "ghc-options":flags -> do res <- componentOptions lvd True flags id - -- putStrLn $ "\n*************ghc-options:" ++ show res return $ Just $ ChResponseCompList (res ++ [(ChSetupHsName, [])]) "ghc-src-options":flags -> do @@ -510,8 +509,11 @@ componentOptions' (lbi, v, distdir) inplaceFlag flags rf f = do componentsMap lbi v distdir $ \c clbi bi -> let - -- outdir = componentOutDir lbi c +#if CH_MIN_VERSION_Cabal(2,0,0) outdir = componentBuildDir lbi clbi +#else + outdir = componentOutDir lbi c +#endif (clbi', adopts) = case flags of _ | not inplaceFlag -> (clbi, mempty) ["--with-inplace"] -> (clbi, mempty) @@ -568,18 +570,20 @@ removeInplaceDeps _v lbi pd clbi includeDirs = let opts { ghcOptSourcePath = ghcOptSourcePath opts <> toNubListR extraIncludes , ghcOptPackages = ghcOptPackages opts <> toNubListR extraDeps } - (hasIdeps,clbi') = removeInplace clbi + (hasIdeps,clbi') = case needsBuild of + NoBuildOutput -> removeInplace clbi + ProduceBuildOutput -> (False, clbi) libopts = -- AZ:TODO: we already have the clbi, use it rather case (getLibraryClbi pd lbi,getExeClbi pd lbi) of - (Just (lib, libclbi),_) | hasIdeps && (needsBuild == NoBuildOutput) -> + (Just (lib, libclbi),_) | hasIdeps -> let libbi = libBuildInfo lib opts = cleanRecursiveOpts (CLib lib) libbi libclbi in -- ghcOptInputModules = toNubListR $ allLibModules lib clbi, opts { ghcOptInputModules = ghcOptInputModules opts <> (toNubListR $ allLibModules lib libclbi) } - (_,Just (exe,execlbi)) | hasIdeps && (needsBuild == NoBuildOutput) -> + (_,Just (exe,execlbi)) | hasIdeps -> let exebi = buildInfo exe in @@ -757,7 +761,13 @@ componentEntrypoints (CFLib (ForeignLib{..})) [] #endif componentEntrypoints (CExe Executable {..}) - = ChExeEntrypoint modulePath (map gmModuleName $ otherModules buildInfo) + = ChExeEntrypoint +#if CH_MIN_VERSION_Cabal(2,0,0) + ( head ((hsSourceDirs buildInfo) ++ ["."]) modulePath) +#else + modulePath +#endif + (map gmModuleName $ otherModules buildInfo) componentEntrypoints (CTest TestSuite { testInterface = TestSuiteExeV10 _ fp, ..}) = ChExeEntrypoint fp (map gmModuleName $ otherModules testBuildInfo) componentEntrypoints (CTest TestSuite { testInterface = TestSuiteLibV09 _ mn, ..}) diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index ab07e85..442fccd 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -23,6 +23,16 @@ import System.Process (readProcess) import Distribution.Helper +import Distribution.Types.Executable + ( Executable(..), + exeModules + ) +import qualified Distribution.ModuleName as ModuleName +import Distribution.Types.BuildInfo +import System.FilePath ( (), takeExtension + , takeDirectory, replaceExtension + ,isRelative ) + import CabalHelper.Shared.Common @@ -119,6 +129,7 @@ test dir = do | "-" `isPrefixOf` x = "\n "++x | otherwise = x + compileModule :: NeedsBuildOutput -> ChEntrypoint -> [String] -> IO Bool compileModule nb ep opts = do -- cgit v1.2.3