diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2018-01-06 14:47:07 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2018-01-18 14:10:26 +0100 |
commit | 0f5127e695c81bff09c0ddeba503a63d0b4c58d6 (patch) | |
tree | 55bebcffce9cd8c7a5a671a1fe556d8be195bc5d | |
parent | 4cb20eebfcc8b5d9aff91af9b8bd171d9281229d (diff) |
When a component uses an internal backpack module, use cabal opts
Which includes inserting the inplace directory for package includes
-rw-r--r-- | src/CabalHelper/Runtime/Main.hs | 31 | ||||
-rw-r--r-- | tests/GhcSession.hs | 8 |
2 files changed, 16 insertions, 23 deletions
diff --git a/src/CabalHelper/Runtime/Main.hs b/src/CabalHelper/Runtime/Main.hs index b17e91d..e71b450 100644 --- a/src/CabalHelper/Runtime/Main.hs +++ b/src/CabalHelper/Runtime/Main.hs @@ -78,6 +78,9 @@ import Distribution.Simple.Program.GHC ( GhcOptions(..) , renderGhcOptions ) +import Distribution.Simple.Register + ( internalPackageDBPath + ) import Distribution.Simple.Setup ( ConfigFlags(..) , Flag(..) @@ -500,15 +503,7 @@ componentsMap lbi _v _distdir f = do componentOptions' (lbi, v, distdir) inplaceFlag flags rf f = do let pd = localPkgDescr lbi #if CH_MIN_VERSION_Cabal(2,0,0) - let distDir = fromFlagOrDefault ("." </> "dist") (configDistPref $ configFlags lbi) - packageDbDir = distDir </> "package.conf.inplace" - cd <- getCurrentDirectory - -- putStrLn $ "*****************componentOptions':(cd,packageDbDir)=" ++ show (cd,packageDbDir) - existsLocalPackageDb <- doesDirectoryExist packageDbDir includeDirMap <- recursiveDepInfo lbi v distdir -#else - let existsLocalPackageDb = False - packageDbDir = "." -- never used #endif componentsMap lbi v distdir $ \c clbi bi -> @@ -526,11 +521,7 @@ componentOptions' (lbi, v, distdir) inplaceFlag flags rf f = do #else [] -> removeInplaceDeps v lbi pd clbi #endif - opts1 = componentGhcOptions normal lbi bi clbi' outdir - opts = if existsLocalPackageDb - then opts1 { ghcOptPackageDBs = ghcOptPackageDBs opts1 - <> [SpecificPackageDB packageDbDir] } - else opts1 + opts = componentGhcOptions normal lbi bi clbi' outdir opts' = f opts in rf lbi v $ nubPackageFlags $ opts' `mappend` adopts @@ -576,9 +567,6 @@ removeInplaceDeps _v lbi pd clbi includeDirs = let opts { ghcOptSourcePath = ghcOptSourcePath opts <> toNubListR extraIncludes , ghcOptPackages = ghcOptPackages opts <> toNubListR extraDeps } - (hasIdeps,clbi') = case needsBuild of - NoBuildOutput -> removeInplace clbi - ProduceBuildOutput -> (False, clbi) libopts = case (getLibraryClbi pd lbi,getExeClbi pd lbi) of (Just (lib, libclbi),_) | hasIdeps -> @@ -593,7 +581,16 @@ removeInplaceDeps _v lbi pd clbi includeDirs = let in cleanRecursiveOpts (CExe exe) exebi execlbi _ -> mempty - in (clbi', libopts) + + distDir = fromFlagOrDefault ("." </> "dist") (configDistPref $ configFlags lbi) + packageDbDir = internalPackageDBPath lbi distDir + (hasIdeps,clbi') = case needsBuild of + NoBuildOutput -> removeInplace clbi + ProduceBuildOutput -> (False, clbi) + libopts' = case needsBuild of + NoBuildOutput -> libopts + ProduceBuildOutput -> mempty { ghcOptPackageDBs = [SpecificPackageDB packageDbDir] } + in (clbi', libopts') #else removeInplaceDeps :: Verbosity -> LocalBuildInfo diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index 12b9b6f..939fd7a 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -69,6 +69,7 @@ setup topdir act (srcdir, min_cabal_ver) = do putStrLn $ "Skipping test '" ++ srcdir ++ "' because " ++ reason ++ "." return [] Nothing -> do + putStrLn $ "Running test '" ++ srcdir ++ "' ------------------------------" withSystemTempDirectory "cabal-helper.ghc-session.test" $ \dir -> do setCurrentDirectory $ topdir </> srcdir run "cabal" [ "sdist", "--output-dir", dir ] @@ -88,7 +89,6 @@ run x xs = do test :: FilePath -> IO [Bool] test dir = do let qe = mkQueryEnv dir (dir </> "dist") - let packageDir = dir </> "dist" </> "package.conf.inplace" cs <- runQuery qe $ components $ (,,,) <$> entrypoints <.> ghcOptions <.> needsBuildOutput forM cs $ \(ep, opts, nb, cn) -> do @@ -97,11 +97,7 @@ test dir = do when (nb == ProduceBuildOutput) $ do run "cabal" [ "build" ] - exists <- doesDirectoryExist packageDir - let opts' = if exists - then ("-package-db " ++ packageDir) : "-Werror" : opts - else "-Werror" : opts - -- let opts' = "-Werror" : opts + let opts' = "-Werror" : opts let sopts = intercalate " " $ map formatArg $ "\nghc" : opts' putStrLn $ "\n" ++ show cn ++ ": " ++ sopts |