parent
30b8366526
commit
7d75787ae3
@ -39,10 +39,14 @@ import System.FilePath (dropExtension, takeFileName, (</>))
|
|||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
-- | Getting necessary 'CompilerOptions' from three information sources.
|
-- | Getting necessary 'CompilerOptions' from three information sources.
|
||||||
getCompilerOptions :: [GHCOption] -> Cradle -> PackageDescription -> IO CompilerOptions
|
getCompilerOptions :: [GHCOption]
|
||||||
|
-> Cradle
|
||||||
|
-> PackageDescription
|
||||||
|
-> IO CompilerOptions
|
||||||
getCompilerOptions ghcopts cradle pkgDesc = do
|
getCompilerOptions ghcopts cradle pkgDesc = do
|
||||||
gopts <- getGHCOptions ghcopts cradle rdir $ head buildInfos
|
gopts <- getGHCOptions ghcopts cradle rdir $ head buildInfos
|
||||||
return $ CompilerOptions gopts idirs depPkgs
|
dbPkgs <- getPackageDbPackages rdir
|
||||||
|
return $ CompilerOptions gopts idirs (depPkgs dbPkgs)
|
||||||
where
|
where
|
||||||
wdir = cradleCurrentDir cradle
|
wdir = cradleCurrentDir cradle
|
||||||
rdir = cradleRootDir cradle
|
rdir = cradleRootDir cradle
|
||||||
@ -50,7 +54,12 @@ getCompilerOptions ghcopts cradle pkgDesc = do
|
|||||||
pkgs = cradlePackages cradle
|
pkgs = cradlePackages cradle
|
||||||
buildInfos = cabalAllBuildInfo pkgDesc
|
buildInfos = cabalAllBuildInfo pkgDesc
|
||||||
idirs = includeDirectories rdir wdir $ cabalSourceDirs buildInfos
|
idirs = includeDirectories rdir wdir $ cabalSourceDirs buildInfos
|
||||||
depPkgs = attachPackageIds pkgs $ removeThem problematicPackages $ removeMe cfile $ cabalDependPackages buildInfos
|
depPkgs ps = attachPackageIds pkgs
|
||||||
|
$ removeThem problematicPackages
|
||||||
|
$ removeMe cfile
|
||||||
|
$ filter (`elem` ps) -- remove packages not available in any
|
||||||
|
-- package dbs
|
||||||
|
$ cabalDependPackages buildInfos
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
-- Dependent packages
|
-- Dependent packages
|
||||||
@ -212,4 +221,3 @@ cabalAllTargets pd = do
|
|||||||
getExecutableTarget exe = do
|
getExecutableTarget exe = do
|
||||||
let maybeExes = [p </> e | p <- P.hsSourceDirs $ P.buildInfo exe, e <- [P.modulePath exe]]
|
let maybeExes = [p </> e | p <- P.hsSourceDirs $ P.buildInfo exe, e <- [P.modulePath exe]]
|
||||||
liftIO $ filterM doesFileExist maybeExes
|
liftIO $ filterM doesFileExist maybeExes
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ spec = do
|
|||||||
}
|
}
|
||||||
res' `shouldBe` CompilerOptions {ghcOptions = ["-global-package-db", "-no-user-package-db","-package-db",cwd </> "test/data/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d","-XHaskell98"], includeDirs = ["test/data","test/data/dist/build","test/data/dist/build/autogen","test/data/subdir1/subdir2","test/data/test"], depPackages = [("Cabal", Nothing), ("base", Nothing) , ("template-haskell", Nothing)]}
|
res' `shouldBe` CompilerOptions {ghcOptions = ["-global-package-db", "-no-user-package-db","-package-db",cwd </> "test/data/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d","-XHaskell98"], includeDirs = ["test/data","test/data/dist/build","test/data/dist/build/autogen","test/data/subdir1/subdir2","test/data/test"], depPackages = [("Cabal", Nothing), ("base", Nothing) , ("template-haskell", Nothing)]}
|
||||||
|
|
||||||
|
|
||||||
describe "cabalDependPackages" $ do
|
describe "cabalDependPackages" $ do
|
||||||
it "extracts dependent packages" $ do
|
it "extracts dependent packages" $ do
|
||||||
pkgs <- cabalDependPackages . cabalAllBuildInfo <$> parseCabalFile "test/data/cabalapi.cabal"
|
pkgs <- cabalDependPackages . cabalAllBuildInfo <$> parseCabalFile "test/data/cabalapi.cabal"
|
||||||
|
Loading…
Reference in New Issue
Block a user