Permalink
Browse files

Merge with cabal-1.16

  • Loading branch information...
2 parents 1a8fb83 + 6a6a36e commit bdc999731d8c1e0352cc8d20a9f2e10ac7fc5920 @tibbe tibbe committed Aug 24, 2012
View
1 Cabal/Cabal.cabal
@@ -173,6 +173,7 @@ test-suite package-tests
PackageTests.TestStanza.Check,
PackageTests.TestSuiteExeV10.Check,
PackageTests.BenchmarkStanza.Check,
+ PackageTests.TemplateHaskell.Check,
PackageTests.PackageTester
hs-source-dirs: tests
build-depends:
View
25 Cabal/Distribution/Simple/GHC.hs
@@ -835,29 +835,28 @@ buildExe verbosity _pkg_descr lbi
ghcOptLinkFrameworks = PD.frameworks exeBi
}
- dynamicOpts = vanillaOpts `mappend` mempty {
- ghcOptDynamic = toFlag True,
- ghcOptExtra = ghcSharedOptions exeBi
- }
-
- exeOpts | withDynExe lbi = dynamicOpts
- | otherwise = vanillaOpts
-
- exeProfOpts = exeOpts `mappend` mempty {
+ exeOpts | withProfExe lbi = vanillaOpts `mappend` mempty {
ghcOptProfilingMode = toFlag True,
ghcOptHiSuffix = toFlag "p_hi",
ghcOptObjSuffix = toFlag "p_o",
- ghcOptExtra = ghcProfOptions exeBi,
- ghcOptNoLink = toFlag True
+ ghcOptExtra = ghcProfOptions exeBi
}
+ | withDynExe lbi = vanillaOpts `mappend` mempty {
+ ghcOptDynamic = toFlag True,
+ ghcOptHiSuffix = toFlag "dyn_hi",
+ ghcOptObjSuffix = toFlag "dyn_o",
+ ghcOptExtra = ghcSharedOptions exeBi
+ }
+ | otherwise = vanillaOpts
+
-- For building exe's for profiling that use TH we actually
-- have to build twice, once without profiling and the again
-- with profiling. This is because the code that TH needs to
-- run at compile time needs to be the vanilla ABI so it can
-- be loaded up and run by the compiler.
- when (withProfExe lbi &&
+ when ((withProfExe lbi || withDynExe lbi) &&
EnableExtension TemplateHaskell `elem` allExtensions exeBi) $
- runGhcProg exeProfOpts { ghcOptNoLink = toFlag True }
+ runGhcProg vanillaOpts { ghcOptNoLink = toFlag True }
runGhcProg exeOpts { ghcOptOutputFile = toFlag (targetDir </> exeNameReal) }
View
5 Cabal/tests/PackageTests.hs
@@ -28,6 +28,7 @@ import PackageTests.BuildDeps.InternalLibrary4.Check
import PackageTests.TestOptions.Check
import PackageTests.TestStanza.Check
import PackageTests.TestSuiteExeV10.Check
+import PackageTests.TemplateHaskell.Check
import Distribution.Text (display)
import Distribution.Simple.Utils (cabalVersion)
import Data.Version
@@ -57,7 +58,9 @@ tests cabalVersion = [
-- only for higher versions.
hunit "PackageTests/BenchmarkExeV10/Test"
(PackageTests.BenchmarkExeV10.Check.checkBenchmark cabalVersion),
- hunit "PackageTests/BenchmarkOptions" PackageTests.BenchmarkOptions.Check.suite
+ hunit "PackageTests/BenchmarkOptions" PackageTests.BenchmarkOptions.Check.suite,
+ hunit "PackageTests/TemplateHaskell/profiling" PackageTests.TemplateHaskell.Check.profiling,
+ hunit "PackageTests/TemplateHaskell/dynamic" PackageTests.TemplateHaskell.Check.dynamic
] ++
-- These tests are only required to pass on cabal version >= 1.7
(if cabalVersion >= Version [1, 7] []
View
3 Cabal/tests/PackageTests/PackageTester.hs
@@ -131,7 +131,8 @@ cabal spec cabalArgs = do
wd <- getCurrentDirectory
r <- run (Just $ directory spec) "ghc"
[ "--make"
- , "-fhpc"
+-- HPC causes trouble -- see #1012
+-- , "-fhpc"
, "-package-conf " ++ wd </> "../dist/package.conf.inplace"
, "Setup.hs"
]
View
44 Cabal/tests/PackageTests/TemplateHaskell/Check.hs
@@ -0,0 +1,44 @@
+module PackageTests.TemplateHaskell.Check where
+
+import Test.HUnit
+import System.FilePath
+import PackageTests.PackageTester
+import Data.List (isInfixOf, intercalate)
+import Distribution.Version
+import Distribution.PackageDescription.Parse
+ ( readPackageDescription )
+import Distribution.PackageDescription.Configuration
+ ( finalizePackageDescription )
+import Distribution.Package
+ ( PackageIdentifier(..), PackageName(..), Dependency(..) )
+import Distribution.PackageDescription
+ ( PackageDescription(..), BuildInfo(..), TestSuite(..), Library(..)
+ , TestSuiteInterface(..)
+ , TestType(..), emptyPackageDescription, emptyBuildInfo, emptyLibrary
+ , emptyTestSuite, BuildType(..) )
+import Distribution.Verbosity (silent)
+import Distribution.License (License(..))
+import Distribution.ModuleName (fromString)
+import Distribution.System (buildPlatform)
+import Distribution.Compiler
+ ( CompilerId(..), CompilerFlavor(..) )
+import Distribution.Text
+
+profiling :: Test
+profiling = TestCase $ do
+ let flags = ["--enable-library-profiling"
+-- ,"--disable-library-vanilla"
+ ,"--enable-executable-profiling"]
+ spec = PackageSpec ("PackageTests" </> "TemplateHaskell" </> "profiling") flags
+ result <- cabal_build spec
+ assertEqual "cabal build should succeed - see test-log.txt" True (successful result)
+
+dynamic :: Test
+dynamic = TestCase $ do
+ let flags = ["--enable-shared"
+-- ,"--disable-library-vanilla"
+ ,"--enable-executable-dynamic"]
+ spec = PackageSpec ("PackageTests" </> "TemplateHaskell" </> "dynamic") flags
+ result <- cabal_build spec
+ assertEqual "cabal build should succeed - see test-log.txt" True (successful result)
+
View
6 Cabal/tests/PackageTests/TemplateHaskell/dynamic/Exe.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import TH
+
+main = print $(splice)
View
6 Cabal/tests/PackageTests/TemplateHaskell/dynamic/Lib.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Lib where
+
+import TH
+
+val = $(splice)
View
3 Cabal/tests/PackageTests/TemplateHaskell/dynamic/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+main = defaultMain
+
View
4 Cabal/tests/PackageTests/TemplateHaskell/dynamic/TH.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE TemplateHaskell #-}
+module TH where
+
+splice = [| () |]
View
15 Cabal/tests/PackageTests/TemplateHaskell/dynamic/my.cabal
@@ -0,0 +1,15 @@
+Name: templateHaskell
+Version: 0.1
+Build-Type: Simple
+Cabal-Version: >= 1.2
+
+Library
+ Exposed-Modules: Lib
+ Other-Modules: TH
+ Build-Depends: base, template-haskell
+ Extensions: TemplateHaskell
+
+Executable main
+ Main-is: Exe.hs
+ Build-Depends: base, template-haskell
+ Extensions: TemplateHaskell
View
6 Cabal/tests/PackageTests/TemplateHaskell/profiling/Exe.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import TH
+
+main = print $(splice)
View
6 Cabal/tests/PackageTests/TemplateHaskell/profiling/Lib.hs
@@ -0,0 +1,6 @@
+{-# LANGUAGE TemplateHaskell #-}
+module Lib where
+
+import TH
+
+val = $(splice)
View
3 Cabal/tests/PackageTests/TemplateHaskell/profiling/Setup.hs
@@ -0,0 +1,3 @@
+import Distribution.Simple
+main = defaultMain
+
View
4 Cabal/tests/PackageTests/TemplateHaskell/profiling/TH.hs
@@ -0,0 +1,4 @@
+{-# LANGUAGE TemplateHaskell #-}
+module TH where
+
+splice = [| () |]
View
15 Cabal/tests/PackageTests/TemplateHaskell/profiling/my.cabal
@@ -0,0 +1,15 @@
+Name: templateHaskell
+Version: 0.1
+Build-Type: Simple
+Cabal-Version: >= 1.2
+
+Library
+ Exposed-Modules: Lib
+ Other-Modules: TH
+ Build-Depends: base, template-haskell
+ Extensions: TemplateHaskell
+
+Executable main
+ Main-is: Exe.hs
+ Build-Depends: base, template-haskell
+ Extensions: TemplateHaskell

0 comments on commit bdc9997

Please sign in to comment.