Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
a4bb2388
Commit
a4bb2388
authored
Dec 19, 2014
by
tibbe
Browse files
Merge branch 'master' of github.com:haskell/cabal
parents
a7acd899
b1ab9585
Changes
38
Hide whitespace changes
Inline
Side-by-side
Cabal/.gitignore
0 → 100644
View file @
a4bb2388
/dist/
/tests/PackageTests/TestSuiteExeV10/dist-*
Cabal/Distribution/Simple/Configure.hs
View file @
a4bb2388
...
...
@@ -601,8 +601,12 @@ configure (pkg_descr0, pbi) cfg
not
(
GHCJS
.
isDynamic
comp
)
_
->
False
let
sharedLibsByDefault
=
case
compilerId
comp
of
let
sharedLibsByDefault
|
fromFlag
(
configDynExe
cfg
)
=
-- build a shared library if dynamically-linked
-- executables are requested
True
|
otherwise
=
case
compilerId
comp
of
CompilerId
GHC
_
->
-- if ghc is dynamic, then ghci needs a shared
-- library, so we build one by default.
...
...
@@ -610,6 +614,24 @@ configure (pkg_descr0, pbi) cfg
CompilerId
GHCJS
_
->
GHCJS
.
isDynamic
comp
_
->
False
withSharedLib_
=
-- build shared libraries if required by GHC or by the
-- executable linking mode, but allow the user to force
-- building only static library archives with
-- --disable-shared.
fromFlagOrDefault
sharedLibsByDefault
$
configSharedLib
cfg
withDynExe_
=
fromFlag
$
configDynExe
cfg
when
(
withDynExe_
&&
not
withSharedLib_
)
$
warn
verbosity
$
"Executables will use dynamic linking, but a shared library "
++
"is not being built. Linking will fail if any executables "
++
"depend on the library."
let
withProfExe_
=
fromFlagOrDefault
False
$
configProfExe
cfg
withProfLib_
=
fromFlagOrDefault
withProfExe_
$
configProfLib
cfg
when
(
withProfExe_
&&
not
withProfLib_
)
$
warn
verbosity
$
"Executables will be built with profiling, but library "
++
"profiling is disabled. Linking will fail if any executables "
++
"depend on the library."
reloc
<-
if
not
(
fromFlag
$
configRelocatable
cfg
)
...
...
@@ -633,11 +655,10 @@ configure (pkg_descr0, pbi) cfg
instantiatedWith
=
hole_insts
,
withPrograms
=
programsConfig'''
,
withVanillaLib
=
fromFlag
$
configVanillaLib
cfg
,
withProfLib
=
fromFlag
$
configProfLib
cfg
,
withSharedLib
=
fromFlagOrDefault
sharedLibsByDefault
$
configSharedLib
cfg
,
withDynExe
=
fromFlag
$
configDynExe
cfg
,
withProfExe
=
fromFlag
$
configProfExe
cfg
,
withProfLib
=
withProfLib_
,
withSharedLib
=
withSharedLib_
,
withDynExe
=
withDynExe_
,
withProfExe
=
withProfExe_
,
withOptimization
=
fromFlag
$
configOptimization
cfg
,
withGHCiLib
=
fromFlagOrDefault
ghciLibByDefault
$
configGHCiLib
cfg
,
...
...
Cabal/Distribution/Simple/GHC.hs
View file @
a4bb2388
...
...
@@ -86,7 +86,7 @@ import Distribution.Simple.Program.GHC
import
Distribution.Simple.Setup
(
toFlag
,
fromFlag
,
configCoverage
,
configDistPref
)
import
qualified
Distribution.Simple.Setup
as
Cabal
(
Flag
)
(
Flag
(
..
)
)
import
Distribution.Simple.Compiler
(
CompilerFlavor
(
..
),
CompilerId
(
..
),
Compiler
(
..
),
compilerVersion
,
PackageDB
(
..
),
PackageDBStack
,
AbiTag
(
..
)
)
...
...
@@ -445,28 +445,30 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
-- that GHC gives Haskell libraries.
cname
=
display
$
PD
.
package
$
localPkgDescr
lbi
distPref
=
fromFlag
$
configDistPref
$
configFlags
lbi
hpcdir
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
cname
|
otherwise
=
mempty
hpcdir
way
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
way
cname
|
otherwise
=
mempty
createDirectoryIfMissingVerbose
verbosity
True
libTargetDir
-- TODO: do we need to put hs-boot files into place for mutually recursive
-- modules?
let
cObjs
=
map
(`
replaceExtension
`
objExtension
)
(
cSources
libBi
)
baseOpts
=
componentGhcOptions
verbosity
lbi
libBi
clbi
libTargetDir
`
mappend
`
mempty
{
ghcOptHPCDir
=
hpcdir
}
vanillaOpts
=
baseOpts
`
mappend
`
mempty
{
ghcOptMode
=
toFlag
GhcModeMake
,
ghcOptNumJobs
=
numJobs
,
ghcOptPackageKey
=
toFlag
(
pkgKey
lbi
),
ghcOptSigOf
=
hole_insts
,
ghcOptInputModules
=
toNubListR
$
libModules
lib
ghcOptInputModules
=
toNubListR
$
libModules
lib
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Vanilla
}
profOpts
=
vanillaOpts
`
mappend
`
mempty
{
ghcOptProfilingMode
=
toFlag
True
,
ghcOptHiSuffix
=
toFlag
"p_hi"
,
ghcOptObjSuffix
=
toFlag
"p_o"
,
ghcOptExtra
=
toNubListR
$
hcProfOptions
GHC
libBi
ghcOptExtra
=
toNubListR
$
hcProfOptions
GHC
libBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Prof
}
sharedOpts
=
vanillaOpts
`
mappend
`
mempty
{
...
...
@@ -474,7 +476,8 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ghcOptFPic
=
toFlag
True
,
ghcOptHiSuffix
=
toFlag
"dyn_hi"
,
ghcOptObjSuffix
=
toFlag
"dyn_o"
,
ghcOptExtra
=
toNubListR
$
hcSharedOptions
GHC
libBi
ghcOptExtra
=
toNubListR
$
hcSharedOptions
GHC
libBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
linkerOpts
=
mempty
{
ghcOptLinkOptions
=
toNubListR
$
PD
.
ldOptions
libBi
,
...
...
@@ -499,7 +502,8 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
vanillaSharedOpts
=
vanillaOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcStaticAndDynamic
,
ghcOptDynHiSuffix
=
toFlag
"dyn_hi"
,
ghcOptDynObjSuffix
=
toFlag
"dyn_o"
ghcOptDynObjSuffix
=
toFlag
"dyn_o"
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
unless
(
forRepl
||
null
(
libModules
lib
))
$
...
...
@@ -510,9 +514,21 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
(
forceSharedLib
||
withSharedLib
lbi
)
&&
null
(
hcSharedOptions
GHC
libBi
)
if
useDynToo
then
runGhcProg
vanillaSharedOpts
else
if
isGhcDynamic
then
do
shared
;
vanilla
else
do
vanilla
;
shared
then
do
runGhcProg
vanillaSharedOpts
case
(
hpcdir
Hpc
.
Dyn
,
hpcdir
Hpc
.
Vanilla
)
of
(
Cabal
.
Flag
dynDir
,
Cabal
.
Flag
vanillaDir
)
->
do
-- When the vanilla and shared library builds are done
-- in one pass, only one set of HPC module interfaces
-- are generated. This set should suffice for both
-- static and dynamically linked executables. We copy
-- the modules interfaces so they are available under
-- both ways.
copyDirectoryRecursive
verbosity
dynDir
vanillaDir
_
->
return
()
else
if
isGhcDynamic
then
do
shared
;
vanilla
else
do
vanilla
;
shared
whenProfLib
(
runGhcProg
profOpts
)
-- build any C sources
...
...
@@ -705,8 +721,9 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
-- '-hpcdir' should be.
let
isCoverageEnabled
=
fromFlag
$
configCoverage
$
configFlags
lbi
distPref
=
fromFlag
$
configDistPref
$
configFlags
lbi
hpcdir
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
exeName'
|
otherwise
=
mempty
hpcdir
way
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
way
exeName'
|
otherwise
=
mempty
-- build executables
...
...
@@ -724,29 +741,32 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
ghcOptInputFiles
=
toNubListR
[
srcMainFile
|
isHaskellMain
],
ghcOptInputModules
=
toNubListR
[
m
|
not
isHaskellMain
,
m
<-
exeModules
exe
],
ghcOptHPCDir
=
hpcdir
[
m
|
not
isHaskellMain
,
m
<-
exeModules
exe
]
}
staticOpts
=
baseOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcStaticOnly
ghcOptDynLinkMode
=
toFlag
GhcStaticOnly
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Vanilla
}
profOpts
=
baseOpts
`
mappend
`
mempty
{
ghcOptProfilingMode
=
toFlag
True
,
ghcOptHiSuffix
=
toFlag
"p_hi"
,
ghcOptObjSuffix
=
toFlag
"p_o"
,
ghcOptExtra
=
toNubListR
$
hcProfOptions
GHC
exeBi
ghcOptExtra
=
toNubListR
$
hcProfOptions
GHC
exeBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Prof
}
dynOpts
=
baseOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcDynamicOnly
,
ghcOptHiSuffix
=
toFlag
"dyn_hi"
,
ghcOptObjSuffix
=
toFlag
"dyn_o"
,
ghcOptExtra
=
toNubListR
$
hcSharedOptions
GHC
exeBi
hcSharedOptions
GHC
exeBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
dynTooOpts
=
staticOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcStaticAndDynamic
,
ghcOptDynHiSuffix
=
toFlag
"dyn_hi"
,
ghcOptDynObjSuffix
=
toFlag
"dyn_o"
ghcOptDynObjSuffix
=
toFlag
"dyn_o"
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
linkerOpts
=
mempty
{
ghcOptLinkOptions
=
toNubListR
$
PD
.
ldOptions
exeBi
,
...
...
Cabal/Distribution/Simple/GHCJS.hs
View file @
a4bb2388
...
...
@@ -53,7 +53,7 @@ import Distribution.Simple.Program.GHC
import
Distribution.Simple.Setup
(
toFlag
,
fromFlag
,
configCoverage
,
configDistPref
)
import
qualified
Distribution.Simple.Setup
as
Cabal
(
Flag
)
(
Flag
(
..
)
)
import
Distribution.Simple.Compiler
(
CompilerFlavor
(
..
),
CompilerId
(
..
),
Compiler
(
..
)
,
PackageDB
(
..
),
PackageDBStack
,
AbiTag
(
..
)
)
...
...
@@ -340,8 +340,9 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
-- that GHC gives Haskell libraries.
cname
=
display
$
PD
.
package
$
localPkgDescr
lbi
distPref
=
fromFlag
$
configDistPref
$
configFlags
lbi
hpcdir
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
cname
|
otherwise
=
mempty
hpcdir
way
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
way
cname
|
otherwise
=
mempty
createDirectoryIfMissingVerbose
verbosity
True
libTargetDir
-- TODO: do we need to put hs-boot files into place for mutually recursive
...
...
@@ -349,7 +350,6 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
let
cObjs
=
map
(`
replaceExtension
`
objExtension
)
(
cSources
libBi
)
jsSrcs
=
jsSources
libBi
baseOpts
=
componentGhcOptions
verbosity
lbi
libBi
clbi
libTargetDir
`
mappend
`
mempty
{
ghcOptHPCDir
=
hpcdir
}
linkJsLibOpts
=
mempty
{
ghcOptExtra
=
toNubListR
$
[
"-link-js-lib"
,
(
\
(
LibraryName
l
)
->
l
)
libName
...
...
@@ -361,20 +361,23 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
ghcOptNumJobs
=
numJobs
,
ghcOptPackageKey
=
toFlag
(
pkgKey
lbi
),
ghcOptSigOf
=
hole_insts
,
ghcOptInputModules
=
toNubListR
$
libModules
lib
ghcOptInputModules
=
toNubListR
$
libModules
lib
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Vanilla
}
vanillaOpts
=
vanillaOptsNoJsLib
`
mappend
`
linkJsLibOpts
profOpts
=
adjustExts
"p_hi"
"p_o"
vanillaOpts
`
mappend
`
mempty
{
ghcOptProfilingMode
=
toFlag
True
,
ghcOptExtra
=
toNubListR
$
ghcjsProfOptions
libBi
ghcjsProfOptions
libBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Prof
}
sharedOpts
=
adjustExts
"dyn_hi"
"dyn_o"
vanillaOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcDynamicOnly
,
ghcOptFPic
=
toFlag
True
,
ghcOptExtra
=
toNubListR
$
ghcjsSharedOptions
libBi
ghcjsSharedOptions
libBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
linkerOpts
=
mempty
{
ghcOptLinkOptions
=
toNubListR
$
PD
.
ldOptions
libBi
,
...
...
@@ -400,7 +403,8 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcStaticAndDynamic
,
ghcOptDynHiSuffix
=
toFlag
"dyn_hi"
,
ghcOptDynObjSuffix
=
toFlag
"dyn_o"
ghcOptDynObjSuffix
=
toFlag
"dyn_o"
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
unless
(
forRepl
||
(
null
(
libModules
lib
)
&&
null
jsSrcs
&&
null
cObjs
))
$
...
...
@@ -411,9 +415,21 @@ buildOrReplLib forRepl verbosity numJobs _pkg_descr lbi lib clbi = do
(
forceSharedLib
||
withSharedLib
lbi
)
&&
null
(
ghcjsSharedOptions
libBi
)
if
useDynToo
then
runGhcjsProg
vanillaSharedOpts
else
if
isGhcjsDynamic
then
do
shared
;
vanilla
else
do
vanilla
;
shared
then
do
runGhcjsProg
vanillaSharedOpts
case
(
hpcdir
Hpc
.
Dyn
,
hpcdir
Hpc
.
Vanilla
)
of
(
Cabal
.
Flag
dynDir
,
Cabal
.
Flag
vanillaDir
)
->
do
-- When the vanilla and shared library builds are done
-- in one pass, only one set of HPC module interfaces
-- are generated. This set should suffice for both
-- static and dynamically linked executables. We copy
-- the modules interfaces so they are available under
-- both ways.
copyDirectoryRecursive
verbosity
dynDir
vanillaDir
_
->
return
()
else
if
isGhcjsDynamic
then
do
shared
;
vanilla
else
do
vanilla
;
shared
whenProfLib
(
runGhcjsProg
profOpts
)
-- build any C sources
...
...
@@ -564,8 +580,9 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
-- '-hpcdir' should be.
let
isCoverageEnabled
=
fromFlag
$
configCoverage
$
configFlags
lbi
distPref
=
fromFlag
$
configDistPref
$
configFlags
lbi
hpcdir
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
exeName'
|
otherwise
=
mempty
hpcdir
way
|
isCoverageEnabled
=
toFlag
$
Hpc
.
mixDir
distPref
way
exeName'
|
otherwise
=
mempty
-- build executables
...
...
@@ -587,25 +604,28 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
[
srcMainFile
|
isHaskellMain
],
ghcOptInputModules
=
toNubListR
$
[
m
|
not
isHaskellMain
,
m
<-
exeModules
exe
],
ghcOptHPCDir
=
hpcdir
,
ghcOptExtra
=
if
buildRunner
then
toNubListR
[
"-build-runner"
]
else
mempty
}
staticOpts
=
baseOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcStaticOnly
ghcOptDynLinkMode
=
toFlag
GhcStaticOnly
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Vanilla
}
profOpts
=
adjustExts
"p_hi"
"p_o"
baseOpts
`
mappend
`
mempty
{
ghcOptProfilingMode
=
toFlag
True
,
ghcOptExtra
=
toNubListR
$
ghcjsProfOptions
exeBi
ghcOptExtra
=
toNubListR
$
ghcjsProfOptions
exeBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Prof
}
dynOpts
=
adjustExts
"dyn_hi"
"dyn_o"
baseOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcDynamicOnly
,
ghcOptExtra
=
toNubListR
$
ghcjsSharedOptions
exeBi
ghcjsSharedOptions
exeBi
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
dynTooOpts
=
adjustExts
"dyn_hi"
"dyn_o"
staticOpts
`
mappend
`
mempty
{
ghcOptDynLinkMode
=
toFlag
GhcStaticAndDynamic
ghcOptDynLinkMode
=
toFlag
GhcStaticAndDynamic
,
ghcOptHPCDir
=
hpcdir
Hpc
.
Dyn
}
linkerOpts
=
mempty
{
ghcOptLinkOptions
=
toNubListR
$
PD
.
ldOptions
exeBi
,
...
...
Cabal/Distribution/Simple/Hpc.hs
View file @
a4bb2388
...
...
@@ -12,8 +12,9 @@
-- build test suites with HPC enabled.
module
Distribution.Simple.Hpc
(
mixDir
(
Way
(
..
),
guessWay
,
htmlDir
,
mixDir
,
tixDir
,
tixFilePath
,
markupPackage
...
...
@@ -41,30 +42,51 @@ import System.FilePath
-- -------------------------------------------------------------------------
-- Haskell Program Coverage
data
Way
=
Vanilla
|
Prof
|
Dyn
deriving
(
Bounded
,
Enum
,
Eq
,
Read
,
Show
)
hpcDir
::
FilePath
-- ^ \"dist/\" prefix
->
Way
->
FilePath
-- ^ Directory containing component's HPC .mix files
hpcDir
distPref
=
distPref
</>
"hpc"
hpcDir
distPref
way
=
distPref
</>
"hpc"
</>
wayDir
where
wayDir
=
case
way
of
Vanilla
->
"vanilla"
Prof
->
"prof"
Dyn
->
"dyn"
mixDir
::
FilePath
-- ^ \"dist/\" prefix
->
Way
->
FilePath
-- ^ Component name
->
FilePath
-- ^ Directory containing test suite's .mix files
mixDir
distPref
name
=
hpcDir
distPref
</>
"mix"
</>
name
mixDir
distPref
way
name
=
hpcDir
distPref
way
</>
"mix"
</>
name
tixDir
::
FilePath
-- ^ \"dist/\" prefix
->
Way
->
FilePath
-- ^ Component name
->
FilePath
-- ^ Directory containing test suite's .tix files
tixDir
distPref
name
=
hpcDir
distPref
</>
"tix"
</>
name
tixDir
distPref
way
name
=
hpcDir
distPref
way
</>
"tix"
</>
name
-- | Path to the .tix file containing a test suite's sum statistics.
tixFilePath
::
FilePath
-- ^ \"dist/\" prefix
->
Way
->
FilePath
-- ^ Component name
->
FilePath
-- ^ Path to test suite's .tix file
tixFilePath
distPref
name
=
tixDir
distPref
name
</>
name
<.>
"tix"
tixFilePath
distPref
way
name
=
tixDir
distPref
way
name
</>
name
<.>
"tix"
htmlDir
::
FilePath
-- ^ \"dist/\" prefix
->
Way
->
FilePath
-- ^ Component name
->
FilePath
-- ^ Path to test suite's HTML markup directory
htmlDir
distPref
name
=
hpcDir
distPref
</>
"html"
</>
name
htmlDir
distPref
way
name
=
hpcDir
distPref
way
</>
"html"
</>
name
-- | Attempt to guess the way the test suites in this package were compiled
-- and linked with the library so the correct module interfaces are found.
guessWay
::
LocalBuildInfo
->
Way
guessWay
lbi
|
withProfExe
lbi
=
Prof
|
withDynExe
lbi
=
Dyn
|
otherwise
=
Vanilla
-- | Generate the HTML markup for a test suite.
markupTest
::
Verbosity
...
...
@@ -74,21 +96,22 @@ markupTest :: Verbosity
->
TestSuite
->
IO
()
markupTest
verbosity
lbi
distPref
libName
suite
=
do
tixFileExists
<-
doesFileExist
$
tixFilePath
distPref
$
testName
suite
tixFileExists
<-
doesFileExist
$
tixFilePath
distPref
way
$
testName
suite
when
tixFileExists
$
do
-- behaviour of 'markup' depends on version, so we need *a* version
-- but no particular one
(
hpc
,
hpcVer
,
_
)
<-
requireProgramVersion
verbosity
hpcProgram
anyVersion
(
withPrograms
lbi
)
let
htmlDir_
=
htmlDir
distPref
way
$
testName
suite
markup
hpc
hpcVer
verbosity
(
tixFilePath
distPref
$
testName
suite
)
mixDirs
(
htmlDir
distPref
$
testName
suite
)
(
tixFilePath
distPref
way
$
testName
suite
)
mixDirs
htmlDir
_
(
testModules
suite
++
[
main
])
notice
verbosity
$
"Test coverage report written to "
++
htmlDir
distPref
(
testName
suite
)
</>
"hpc_index"
<.>
"html"
++
htmlDir_
</>
"hpc_index"
<.>
"html"
where
mixDirs
=
map
(
mixDir
distPref
)
[
testName
suite
,
libName
]
way
=
guessWay
lbi
mixDirs
=
map
(
mixDir
distPref
way
)
[
testName
suite
,
libName
]
-- | Generate the HTML markup for all of a package's test suites.
markupPackage
::
Verbosity
...
...
@@ -98,15 +121,15 @@ markupPackage :: Verbosity
->
[
TestSuite
]
->
IO
()
markupPackage
verbosity
lbi
distPref
libName
suites
=
do
let
tixFiles
=
map
(
tixFilePath
distPref
.
testName
)
suites
let
tixFiles
=
map
(
tixFilePath
distPref
way
.
testName
)
suites
tixFilesExist
<-
mapM
doesFileExist
tixFiles
when
(
and
tixFilesExist
)
$
do
-- behaviour of 'markup' depends on version, so we need *a* version
-- but no particular one
(
hpc
,
hpcVer
,
_
)
<-
requireProgramVersion
verbosity
hpcProgram
anyVersion
(
withPrograms
lbi
)
let
outFile
=
tixFilePath
distPref
libName
htmlDir'
=
htmlDir
distPref
libName
let
outFile
=
tixFilePath
distPref
way
libName
htmlDir'
=
htmlDir
distPref
way
libName
excluded
=
concatMap
testModules
suites
++
[
main
]
createDirectoryIfMissing
True
$
takeDirectory
outFile
union
hpc
verbosity
tixFiles
outFile
excluded
...
...
@@ -114,4 +137,5 @@ markupPackage verbosity lbi distPref libName suites = do
notice
verbosity
$
"Package coverage report written to "
++
htmlDir'
</>
"hpc_index.html"
where
mixDirs
=
map
(
mixDir
distPref
)
$
libName
:
map
testName
suites
way
=
guessWay
lbi
mixDirs
=
map
(
mixDir
distPref
way
)
$
libName
:
map
testName
suites
Cabal/Distribution/Simple/Setup.hs
View file @
a4bb2388
...
...
@@ -336,10 +336,10 @@ defaultConfigFlags progConf = emptyConfigFlags {
configPrograms
=
progConf
,
configHcFlavor
=
maybe
NoFlag
Flag
defaultCompilerFlavor
,
configVanillaLib
=
Flag
True
,
configProfLib
=
Flag
False
,
configProfLib
=
No
Flag
,
configSharedLib
=
NoFlag
,
configDynExe
=
Flag
False
,
configProfExe
=
Flag
False
,
configProfExe
=
No
Flag
,
configOptimization
=
Flag
NormalOptimisation
,
configProgPrefix
=
Flag
(
toPathTemplate
""
),
configProgSuffix
=
Flag
(
toPathTemplate
""
),
...
...
@@ -450,8 +450,8 @@ configureOptions showOrParseArgs =
configDynExe
(
\
v
flags
->
flags
{
configDynExe
=
v
})
(
boolOpt
[]
[]
)
,
option
""
[
"executable-profiling"
]
"Executable profiling"
,
option
""
[
"profiling"
,
"executable-profiling"
]
"Executable profiling
(requires library profiling)
"
configProfExe
(
\
v
flags
->
flags
{
configProfExe
=
v
})
(
boolOpt
[]
[]
)
...
...
Cabal/Distribution/Simple/Test/ExeV10.hs
View file @
a4bb2388
...
...
@@ -8,7 +8,7 @@ import qualified Distribution.PackageDescription as PD
import
Distribution.Simple.Build.PathsModule
(
pkgPathEnvVar
)
import
Distribution.Simple.BuildPaths
(
exeExtension
)
import
Distribution.Simple.Compiler
(
compilerInfo
)
import
Distribution.Simple.Hpc
(
markupTest
,
tixDir
,
tixFilePath
)
import
Distribution.Simple.Hpc
(
guessWay
,
markupTest
,
tixDir
,
tixFilePath
)
import
Distribution.Simple.InstallDirs
(
fromPathTemplate
,
initialPathTemplateEnv
,
PathTemplateVariable
(
..
)
,
substPathTemplate
,
toPathTemplate
,
PathTemplate
)
...
...
@@ -39,6 +39,8 @@ runTest :: PD.PackageDescription
->
IO
TestSuiteLog
runTest
pkg_descr
lbi
flags
suite
=
do
let
isCoverageEnabled
=
fromFlag
$
configCoverage
$
LBI
.
configFlags
lbi
way
=
guessWay
lbi
tixDir_
=
tixDir
distPref
way
$
PD
.
testName
suite
pwd
<-
getCurrentDirectory
existingEnv
<-
getEnvironment
...
...
@@ -52,12 +54,11 @@ runTest pkg_descr lbi flags suite = do
-- Remove old .tix files if appropriate.
unless
(
fromFlag
$
testKeepTix
flags
)
$
do
let
tDir
=
tixDir
distPref
$
PD
.
testName
suite
exists'
<-
doesDirectoryExist
tDir
when
exists'
$
removeDirectoryRecursive
tDir
exists'
<-
doesDirectoryExist
tixDir_
when
exists'
$
removeDirectoryRecursive
tixDir_
-- Create directory for HPC files.
createDirectoryIfMissing
True
$
tixDir
distPref
$
PD
.
testName
suite
createDirectoryIfMissing
True
tixDir
_
-- Write summary notices indicating start of test suite
notice
verbosity
$
summarizeSuiteStart
$
PD
.
testName
suite
...
...
@@ -76,7 +77,7 @@ runTest pkg_descr lbi flags suite = do
let
opts
=
map
(
testOption
pkg_descr
lbi
suite
)
(
testOptions
flags
)
dataDirPath
=
pwd
</>
PD
.
dataDir
pkg_descr
tixFile
=
pwd
</>
tixFilePath
distPref
(
PD
.
testName
suite
)
tixFile
=
pwd
</>
tixFilePath
distPref
way
(
PD
.
testName
suite
)
pkgPathEnv
=
(
pkgPathEnvVar
pkg_descr
"datadir"
,
dataDirPath
)
:
existingEnv
shellEnv
=
[(
"HPCTIXFILE"
,
tixFile
)
|
isCoverageEnabled
]
++
pkgPathEnv
...
...
Cabal/Distribution/Simple/Test/LibV09.hs
View file @
a4bb2388
...
...
@@ -14,7 +14,7 @@ import qualified Distribution.PackageDescription as PD
import
Distribution.Simple.Build.PathsModule
(
pkgPathEnvVar
)
import
Distribution.Simple.BuildPaths
(
exeExtension
)
import
Distribution.Simple.Compiler
(
compilerInfo
)
import
Distribution.Simple.Hpc
(
markupTest
,
tixDir
,
tixFilePath
)
import
Distribution.Simple.Hpc
(
guessWay
,
markupTest
,
tixDir
,
tixFilePath
)
import
Distribution.Simple.InstallDirs
(
fromPathTemplate
,
initialPathTemplateEnv
,
PathTemplateVariable
(
..
)
,
substPathTemplate
,
toPathTemplate
,
PathTemplate
)
...
...
@@ -47,6 +47,7 @@ runTest :: PD.PackageDescription
->
IO
TestSuiteLog
runTest
pkg_descr
lbi
flags
suite
=
do
let
isCoverageEnabled
=
fromFlag
$
configCoverage
$
LBI
.
configFlags
lbi
way
=
guessWay
lbi
pwd
<-
getCurrentDirectory
existingEnv
<-
getEnvironment
...
...
@@ -60,12 +61,12 @@ runTest pkg_descr lbi flags suite = do
-- Remove old .tix files if appropriate.
unless
(
fromFlag
$
testKeepTix
flags
)
$
do
let
tDir
=
tixDir
distPref
$
PD
.
testName
suite
let
tDir
=
tixDir
distPref
way
$
PD
.
testName
suite
exists'
<-
doesDirectoryExist
tDir
when
exists'
$
removeDirectoryRecursive
tDir
-- Create directory for HPC files.
createDirectoryIfMissing
True
$
tixDir
distPref
$
PD
.
testName
suite
createDirectoryIfMissing
True
$
tixDir
distPref
way
$
PD
.
testName
suite
-- Write summary notices indicating start of test suite
notice
verbosity
$
summarizeSuiteStart
$
PD
.
testName
suite
...
...
@@ -83,7 +84,7 @@ runTest pkg_descr lbi flags suite = do
-- Run test executable
_
<-
do
let
opts
=
map
(
testOption
pkg_descr
lbi
suite
)
$
testOptions
flags
dataDirPath
=
pwd
</>
PD
.
dataDir
pkg_descr
tixFile
=
pwd
</>
tixFilePath
distPref
(
PD
.
testName
suite
)
tixFile
=
pwd
</>
tixFilePath
distPref
way
(
PD
.
testName
suite
)
pkgPathEnv
=
(
pkgPathEnvVar
pkg_descr
"datadir"
,
dataDirPath
)
:
existingEnv
shellEnv
=
[(
"HPCTIXFILE"
,
tixFile
)
|
isCoverageEnabled
]
...
...
Cabal/Distribution/Simple/Utils.hs
View file @
a4bb2388
...
...
@@ -54,6 +54,7 @@ module Distribution.Simple.Utils (
installExecutableFiles
,
installMaybeExecutableFiles
,
installDirectoryContents
,
copyDirectoryRecursive
,
-- * File permissions
doesExecutableExist
,
...
...
@@ -944,6 +945,13 @@ installDirectoryContents verbosity srcDir destDir = do
srcFiles
<-
getDirectoryContentsRecursive
srcDir
installOrdinaryFiles
verbosity
destDir
[
(
srcDir
,
f
)
|
f
<-
srcFiles
]
-- | Recursively copy the contents of one directory to another path.
copyDirectoryRecursive
::
Verbosity
->
FilePath
->
FilePath
->
IO
()
copyDirectoryRecursive
verbosity
srcDir
destDir
=
do
info
verbosity
(
"copy directory '"
++
srcDir
++
"' to '"
++
destDir
++
"'."
)
srcFiles
<-
getDirectoryContentsRecursive
srcDir
copyFilesWith
(
const
copyFile
)
verbosity
destDir
[
(
srcDir
,
f
)
|
f
<-
srcFiles
]
-------------------
-- File permissions
...
...
Cabal/changelog
View file @
a4bb2388
...
...
@@ -23,6 +23,8 @@
* Drop support for Haddock < 2.0 (#1808, #1718).
* Make 'cabal test'/'cabal bench' build only what's needed for
running tests/benchmarks (#1821).
* Build shared libraries by default when linking executables dynamically.
* Build profiled libraries by default when profiling executables.
1.20.0.1 Johan Tibell <johan.tibell@gmail.com> May 2014
* Fix streaming test output.
...
...
Cabal/doc/installing-packages.markdown
View file @
a4bb2388
...
...
@@ -577,6 +577,14 @@ be controlled with the following command line options.
Do not check for dependencies required only by the test suites. It will not
be possible to invoke the
`test`
command without reconfiguring the package.
`--enable-coverage`
: Build libraries and executables (including test suites) with Haskell
Program Coverage enabled. Running the test suites will automatically
generate coverage reports with HPC.
`--disable-coverage`
: (default) Do not enable Haskell Program Coverage.