-
Notifications
You must be signed in to change notification settings - Fork 697
2.0 migration guide
Cabal 2.0 comes with a number of backwards-compatibility breaking changes. This page documents some of them and gives advice on how to adjust your code for the new APIs. When possible, we will give guidance on how to write your code in a way that is simultaneously compatible with 2.0 and earlier versions, but in many cases you will have to use CPP to handle the differences.
We now generate a macro file for each component which contains only information about the direct dependencies of that component. Consequently, dist/build/autogen/cabal_macros.h
contains only the macros for the library, and is not generated if a package has no library; to find the macros for an executable named foobar
, look in dist/build/foobar/autogen/cabal_macros.h
. Similarly, if you used autogenModulesDir
you should now use autogenComponentModulesDir
, which now requires a ComponentLocalBuildInfo
argument as well in order to disambiguate which component the autogenerated files are for.
The following data types are now opaque (in order to support a more efficient underlying representation):
PackageName
ComponentId
FlagName
AbiHash
Version
To construct these types, use mkXXXXX
; to destruct them, use unXXXXX
(e.g., for PackageName
that'll be mkPackageName
/unPackageName
). These types can also be converted back into strings using display
, which is backwards compatible with old versions of Cabal.
-
GenericPackageDescription
used to have fieldscondExecutables
,condTestSuites
andcondBenchmarks
of type[(String, CondTree ConfVar [Dependency] x)]
. TheString
field is now has typeUnqualComponentName
. -
TestSuite
andBenchmark
no longer havetestEnabled
andbenchmarkEnabled
. If you usedenabledTests
orenabledBenchmarks
, please instead useenabledTestLBIs
andenabledBenchLBIs
(you will need aLocalBuildInfo
for these functions.) Additionally, the semantics ofwithTest
andwithBench
have changed: they now iterate over all buildable such components, regardless of whether or not they have been enabled; if you only want enabled components, usewithTestLBI
andwithBenchLBI
.
-
readPackageDescription
(fromDistribution.PackageDescription.Parse
) is deprecated in favor ofreadGenericPackageDescription
. -
The function in
PPSuffixHandler
now takes an additionalComponentLocalBuildInfo
specifying the build information of the component being preprocessed.
-
readPackageDescription
(fromDistribution.PackageDescription.Parse
) is deprecated in favour ofreadGenericPackageDescription
. -
getComponentLocalBuildInfo
,withComponentsInBuildOrder
andcomponentsInBuildOrder
are deprecated in favour of a new interface in"Distribution.Types.LocalBuildInfo"
. -
finalizePackageDescription
is deprecated: its replacementfinalizePD
now takes an extra argumentComponentRequestedSpec
which specifies what components are to be enabled: use this instead of modifying theComponent
in aGenericPackageDescription
. (As it's not possible now,finalizePackageDescription
will assume tests/benchmarks are disabled.) If you only need to test if a component is buildable (i.e., it is marked buildable in the Cabal file) use the new functioncomponentBuildable
.