From 9f6b9c53ccf1c0d3bb6d3aa4e183da9936d8e9ec Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Mon, 11 Jul 2016 06:15:28 +0200 Subject: Fix "empty IORef" ..when component depends on non-existing internal library --- CabalHelper/Main.hs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/CabalHelper/Main.hs b/CabalHelper/Main.hs index 7c0d15a..a48c2bc 100644 --- a/CabalHelper/Main.hs +++ b/CabalHelper/Main.hs @@ -306,10 +306,10 @@ getLibrary pd = unsafePerformIO $ do readIORef lr getLibraryClbi pd lbi = unsafePerformIO $ do - lr <- newIORef (error "getLibraryClbi: empty IORef") + lr <- newIORef Nothing withLibLBI pd lbi $ \ lib clbi -> - writeIORef lr (lib,clbi) + writeIORef lr $ Just (lib,clbi) readIORef lr @@ -417,21 +417,26 @@ removeInplaceDeps :: Verbosity -> ComponentLocalBuildInfo -> (ComponentLocalBuildInfo, GhcOptions) removeInplaceDeps v lbi pd clbi = let - (lib, libclbi) = getLibraryClbi pd lbi - libbi = libBuildInfo lib - liboutdir = componentOutDir lbi (CLib lib) - libopts = (componentGhcOptions normal lbi libbi libclbi liboutdir) { - ghcOptPackageDBs = [] + (ideps, deps) = partition isInplaceDep (componentPackageDeps clbi) + hasIdeps = not $ null ideps + libopts = + case getLibraryClbi pd lbi of + Just (lib, libclbi) | hasIdeps -> + let + libbi = libBuildInfo lib + liboutdir = componentOutDir lbi (CLib lib) + in + (componentGhcOptions normal lbi libbi libclbi liboutdir) { + ghcOptPackageDBs = [] #if CABAL_MAJOR == 1 && CABAL_MINOR > 22 && CABAL_MINOR < 23 - , ghcOptComponentId = NoFlag + , ghcOptComponentId = NoFlag #endif - } - (ideps, deps) = partition isInplaceDep (componentPackageDeps clbi) - hasIdeps = not $ null ideps + } + _ -> mempty clbi' = clbi { componentPackageDeps = deps } - in (clbi', if hasIdeps then libopts else mempty) + in (clbi', libopts) where isInplaceDep :: (InstalledPackageId, PackageId) -> Bool -- cgit v1.2.3