-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #5916
- Loading branch information
Showing
18 changed files
with
188 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
VERSION=2.5.0.0 | ||
VERSION=3.0.0.0 | ||
|
||
#KIND=devel | ||
KIND=rc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,78 @@ | ||
{-# LANGUAGE Haskell2010 #-} | ||
module Main (main) where | ||
|
||
import Distribution.Backpack | ||
import Distribution.Simple | ||
import Distribution.Simple.BuildPaths | ||
import Distribution.Simple.LocalBuildInfo | ||
import Distribution.Simple.Setup | ||
import Distribution.Simple.Utils | ||
import Distribution.Types.LocalBuildInfo | ||
import Distribution.Types.ModuleRenaming | ||
import Distribution.Types.UnqualComponentName | ||
|
||
import System.Directory | ||
import System.FilePath | ||
|
||
main :: IO () | ||
main = defaultMain | ||
|
||
-- Although this looks like the Simple build type, it is in fact vital that | ||
-- we use this Setup.hs because we need to compile against the very same | ||
-- version of the Cabal library that the test suite will be compiled | ||
-- against. When this happens, it will mean that we'll be able to | ||
-- read the LocalBuildInfo of our build environment, which we will | ||
-- subsequently use to make decisions about PATHs etc. Important! | ||
main = defaultMainWithHooks simpleUserHooks | ||
{ buildHook = \pkg lbi hooks flags -> do | ||
generateScriptEnvModule lbi flags | ||
buildHook simpleUserHooks pkg lbi hooks flags | ||
} | ||
|
||
generateScriptEnvModule :: LocalBuildInfo -> BuildFlags -> IO () | ||
generateScriptEnvModule lbi flags = do | ||
lbiPackageDbStack <- mapM canonicalizePackageDB (withPackageDB lbi) | ||
|
||
createDirectoryIfMissing True moduledir | ||
rewriteFileEx verbosity (moduledir </> "ScriptEnv0.hs") $ unlines | ||
[ "module Test.Cabal.ScriptEnv0 where" | ||
, "" | ||
, "import Distribution.Simple" | ||
, "import Distribution.System (Platform(..), Arch(..), OS(..))" | ||
, "import Distribution.Types.ModuleRenaming" | ||
, "import Distribution.Simple.Program.Db" | ||
, "import Distribution.Backpack (OpenUnitId)" | ||
, "import Data.Map (fromList)" | ||
, "" | ||
, "lbiPackageDbStack :: PackageDBStack" | ||
, "lbiPackageDbStack = " ++ show lbiPackageDbStack | ||
, "" | ||
, "lbiPlatform :: Platform" | ||
, "lbiPlatform = " ++ show (hostPlatform lbi) | ||
, "" | ||
, "lbiCompiler :: Compiler" | ||
, "lbiCompiler = " ++ show (compiler lbi) | ||
, "" | ||
, "lbiPackages :: [(OpenUnitId, ModuleRenaming)]" | ||
, "lbiPackages = read " ++ show (show (cabalTestsPackages lbi)) | ||
, "" | ||
, "lbiProgramDb :: ProgramDb" | ||
, "lbiProgramDb = read " ++ show (show (withPrograms lbi)) | ||
, "" | ||
, "lbiWithSharedLib :: Bool" | ||
, "lbiWithSharedLib = " ++ show (withSharedLib lbi) | ||
] | ||
where | ||
verbosity = fromFlagOrDefault minBound (buildVerbosity flags) | ||
moduledir = libAutogenDir </> "Test" </> "Cabal" | ||
-- fixme: use component-specific folder | ||
libAutogenDir = autogenPackageModulesDir lbi | ||
|
||
-- | Convert package database into absolute path, so that | ||
-- if we change working directories in a subprocess we get the correct database. | ||
canonicalizePackageDB :: PackageDB -> IO PackageDB | ||
canonicalizePackageDB (SpecificPackageDB path) | ||
= SpecificPackageDB `fmap` canonicalizePath path | ||
canonicalizePackageDB x = return x | ||
|
||
-- | Compute the set of @-package-id@ flags which would be passed when | ||
-- building the public library. Assumes that the public library is | ||
-- non-Backpack. | ||
cabalTestsPackages :: LocalBuildInfo -> [(OpenUnitId, ModuleRenaming)] | ||
cabalTestsPackages lbi = | ||
case componentNameCLBIs lbi (CExeName (mkUnqualComponentName "cabal-tests")) of | ||
[clbi] -> -- [ (unUnitId $ unDefUnitId duid,rn) | (DefiniteUnitId duid, rn) <- componentIncludes clbi ] | ||
componentIncludes clbi | ||
_ -> error "cabalTestsPackages" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main (main) where | ||
|
||
import Distribution.Simple | ||
|
||
main :: IO () | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.