diff options
| author | Daniel Gröber <dxld@darkboxed.org> | 2016-07-11 06:15:28 +0200 | 
|---|---|---|
| committer | Daniel Gröber <dxld@darkboxed.org> | 2016-07-11 06:15:28 +0200 | 
| commit | 9f6b9c53ccf1c0d3bb6d3aa4e183da9936d8e9ec (patch) | |
| tree | 89b3a1a4cfa2e9d89ed49e4aa555897272c3315f | |
| parent | 7f8753420d14af8c8a545de4c0d64f54dfe5bbc4 (diff) | |
Fix "empty IORef"
..when component depends on non-existing internal library
| -rw-r--r-- | CabalHelper/Main.hs | 29 | 
1 files 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  | 
