-
Notifications
You must be signed in to change notification settings - Fork 721
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):
PackageNameComponentIdFlagNameAbiHashVersion
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.
-
GenericPackageDescriptionused to have fieldscondExecutables,condTestSuitesandcondBenchmarksof type[(String, CondTree ConfVar [Dependency] x)]. TheStringfield is now has typeUnqualComponentName. -
TestSuiteandBenchmarkno longer havetestEnabledandbenchmarkEnabled. If you usedenabledTestsorenabledBenchmarks, please instead useenabledTestLBIsandenabledBenchLBIs(you will need aLocalBuildInfofor these functions.) Additionally, the semantics ofwithTestandwithBenchhave changed: they now iterate over all buildable such components, regardless of whether or not they have been enabled; if you only want enabled components, usewithTestLBIandwithBenchLBI.
-
readPackageDescription(fromDistribution.PackageDescription.Parse) is deprecated in favor ofreadGenericPackageDescription. -
The function in
PPSuffixHandlernow takes an additionalComponentLocalBuildInfospecifying the build information of the component being preprocessed.
-
readPackageDescription(fromDistribution.PackageDescription.Parse) is deprecated in favour ofreadGenericPackageDescription. -
getComponentLocalBuildInfo,withComponentsInBuildOrderandcomponentsInBuildOrderare deprecated in favour of a new interface in"Distribution.Types.LocalBuildInfo". -
finalizePackageDescriptionis deprecated: its replacementfinalizePDnow takes an extra argumentComponentRequestedSpecwhich specifies what components are to be enabled: use this instead of modifying theComponentin aGenericPackageDescription. (As it's not possible now,finalizePackageDescriptionwill 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.