Making cabalBuildInfo pure.
This commit is contained in:
parent
431e3fa904
commit
a8e57615ba
2
Cabal.hs
2
Cabal.hs
@ -38,7 +38,7 @@ fromCabal :: [String] -> IO ([String], [FilePath], [String])
|
||||
fromCabal ghcOptions = do
|
||||
(owdir,cdir,cfile) <- getDirs
|
||||
cabal <- cabalParseFile cfile
|
||||
binfo@BuildInfo{..} <- cabalBuildInfo cabal
|
||||
let binfo@BuildInfo{..} = cabalBuildInfo cabal
|
||||
let exts = map (("-X" ++) . display) $ usedExtensions binfo
|
||||
lang = maybe "-XHaskell98" (("-X" ++) . display) defaultLanguage
|
||||
libs = map ("-l" ++) extraLibs
|
||||
|
@ -24,9 +24,8 @@ cabalParseFile :: FilePath -> IO GenericPackageDescription
|
||||
cabalParseFile = readPackageDescription silent
|
||||
|
||||
-- Causes error, catched in the upper function.
|
||||
cabalBuildInfo :: GenericPackageDescription -> IO BuildInfo
|
||||
cabalBuildInfo pd =
|
||||
return . fromJust $ fromLibrary pd <|> fromExecutable pd
|
||||
cabalBuildInfo :: GenericPackageDescription -> BuildInfo
|
||||
cabalBuildInfo pd = fromJust $ fromLibrary pd <|> fromExecutable pd
|
||||
where
|
||||
fromLibrary c = libBuildInfo . condTreeData <$> condLibrary c
|
||||
fromExecutable c = buildInfo . condTreeData . snd <$> toMaybe (condExecutables c)
|
||||
|
@ -13,6 +13,6 @@ spec = do
|
||||
|
||||
describe "cabalBuildInfo" $ do
|
||||
it "extracts build info" $ do
|
||||
info <- cabalParseFile "test/data/cabalapi.cabal" >>= cabalBuildInfo
|
||||
info <- cabalBuildInfo <$> cabalParseFile "test/data/cabalapi.cabal"
|
||||
let infoStr = show info
|
||||
infoStr `shouldBe` "BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], hsSourceDirs = [], otherModules = [ModuleName [\"Browse\"],ModuleName [\"CabalApi\"],ModuleName [\"Cabal\"],ModuleName [\"CabalDev\"],ModuleName [\"Check\"],ModuleName [\"ErrMsg\"],ModuleName [\"Flag\"],ModuleName [\"GHCApi\"],ModuleName [\"GHCChoice\"],ModuleName [\"Gap\"],ModuleName [\"Info\"],ModuleName [\"Lang\"],ModuleName [\"Lint\"],ModuleName [\"List\"],ModuleName [\"Paths_ghc_mod\"],ModuleName [\"Types\"]], defaultLanguage = Nothing, otherLanguages = [], defaultExtensions = [], otherExtensions = [], oldExtensions = [], extraLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [(GHC,[\"-Wall\"])], ghcProfOptions = [], ghcSharedOptions = [], customFieldsBI = [], targetBuildDepends = []}"
|
||||
|
Loading…
Reference in New Issue
Block a user