try to load persistbuildconfig, even if cabal library version is not the same
This commit is contained in:
parent
6bec7d342a
commit
174ac36719
@ -359,17 +359,37 @@ ghcPackageArgs opts ghcVer cabal lib = do
|
|||||||
cabalDevConf = "-package-confcabal-dev/packages-" ++ ghcVer ++ ".conf"
|
cabalDevConf = "-package-confcabal-dev/packages-" ++ ghcVer ++ ".conf"
|
||||||
inplaceConf = "-package-confdist/package.conf.inplace"
|
inplaceConf = "-package-confdist/package.conf.inplace"
|
||||||
|
|
||||||
getPersistBuildConfig :: FilePath ->IO D.LocalBuildInfo
|
getPersistBuildConfig :: FilePath -> IO D.LocalBuildInfo
|
||||||
getPersistBuildConfig path = fromMaybeErr errLbi =<< D.maybeGetPersistBuildConfig path
|
getPersistBuildConfig path = fromRightErr errLbi =<< getPersistConfigLenient path -- D.maybeGetPersistBuildConfig path
|
||||||
where
|
where
|
||||||
errLbi = "Could not read BuildInfo file: " ++ D.localBuildInfoFile "dist" ++
|
errLbi = "Could not read BuildInfo file: " ++ D.localBuildInfoFile "dist" ++
|
||||||
"\nMake sure that cabal-install has been compiled with the same GHC version as yesod."
|
"\nMake sure that cabal-install has been compiled with the same GHC version as yesod." ++
|
||||||
|
"\nand that the Cabal library used by GHC is the same version"
|
||||||
|
|
||||||
|
-- there can be slight differences in the cabal version, ignore those when loading the file as long as we can parse it
|
||||||
|
getPersistConfigLenient :: FilePath -> IO (Either String D.LocalBuildInfo)
|
||||||
|
getPersistConfigLenient fp = do
|
||||||
|
let file = fp ++ "/setup-config"
|
||||||
|
exists <- doesFileExist file
|
||||||
|
if not exists
|
||||||
|
then return (Left $ "file does not exist: " ++ fp)
|
||||||
|
else do
|
||||||
|
xs <- readFile file
|
||||||
|
return $ case lines xs of
|
||||||
|
[_,l2] -> -- two lines, header and serialized rest
|
||||||
|
case reads l2 of
|
||||||
|
[(bi,_)] -> Right bi
|
||||||
|
_ -> (Left "cannot parse contents")
|
||||||
|
_ -> (Left "not a valid header/content file")
|
||||||
|
|
||||||
fromMaybeErr :: String -> Maybe b -> IO b
|
fromMaybeErr :: String -> Maybe b -> IO b
|
||||||
fromMaybeErr err Nothing = failWith err
|
fromMaybeErr err Nothing = failWith err
|
||||||
fromMaybeErr _ (Just x) = return x
|
fromMaybeErr _ (Just x) = return x
|
||||||
|
|
||||||
|
fromRightErr :: String -> Either String b -> IO b
|
||||||
|
fromRightErr str (Left err) = failWith (str ++ "\n" ++ err)
|
||||||
|
fromRightErr _ (Right b) = return b
|
||||||
|
|
||||||
lookupDevelLib :: D.GenericPackageDescription -> D.CondTree D.ConfVar c a -> Maybe a
|
lookupDevelLib :: D.GenericPackageDescription -> D.CondTree D.ConfVar c a -> Maybe a
|
||||||
lookupDevelLib gpd ct | found = Just (D.condTreeData ct)
|
lookupDevelLib gpd ct | found = Just (D.condTreeData ct)
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user