Don't crash on empty cabal file
This commit is contained in:
parent
984d7c216d
commit
580adcdf74
@ -12,7 +12,7 @@ module CabalApi (
|
|||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Exception (throwIO)
|
import Control.Exception (throwIO)
|
||||||
import Data.List (intercalate)
|
import Data.List (intercalate)
|
||||||
import Data.Maybe (fromJust, maybeToList, listToMaybe)
|
import Data.Maybe (maybeToList, listToMaybe)
|
||||||
import Data.Set (fromList, toList)
|
import Data.Set (fromList, toList)
|
||||||
import Distribution.Package (Dependency(Dependency), PackageName(PackageName))
|
import Distribution.Package (Dependency(Dependency), PackageName(PackageName))
|
||||||
import Distribution.PackageDescription
|
import Distribution.PackageDescription
|
||||||
@ -71,7 +71,7 @@ getGHCOptions ghcOptions binfo = ghcOptions ++ exts ++ [lang] ++ libs ++ libDirs
|
|||||||
|
|
||||||
-- Causes error, catched in the upper function.
|
-- Causes error, catched in the upper function.
|
||||||
cabalBuildInfo :: GenericPackageDescription -> BuildInfo
|
cabalBuildInfo :: GenericPackageDescription -> BuildInfo
|
||||||
cabalBuildInfo pd = fromJust $ fromLibrary pd <|> fromExecutable pd
|
cabalBuildInfo pd = maybe emptyBuildInfo id $ fromLibrary pd <|> fromExecutable pd
|
||||||
where
|
where
|
||||||
fromLibrary c = libBuildInfo . condTreeData <$> condLibrary c
|
fromLibrary c = libBuildInfo . condTreeData <$> condLibrary c
|
||||||
fromExecutable c = buildInfo . condTreeData . snd <$> listToMaybe (condExecutables c)
|
fromExecutable c = buildInfo . condTreeData . snd <$> listToMaybe (condExecutables c)
|
||||||
|
Loading…
Reference in New Issue
Block a user