
I'm trying to use the Cabal api to preprocess a .cabal file and have it run the preprocessors. But preprocessSources takes a PackageDescription (which I get from a GenericPackageDescription) so this does not contain any information on the Executables or Libraries in the cabal file. So nothing gets executed. What is the correct way to use it? For reference, my code is preprocessPackage :: Context -> String -> IO () preprocessPackage env file = do info <- maybeGetPersistBuildConfig configName outdated <- case info of Just i -> safeCheckPersistBuildConfig "dist" file Nothing -> return True pkg_info <- case outdated of False -> return $ fromJust info True -> do new_info <- configurePackage env writePersistBuildConfig configName new_info return new_info withContext env (\cfg -> preprocessSources (packageDescription cfg) pkg_info False deafening knownSuffixHandlers)

On Thu, 2010-07-29 at 20:54 +0200, Phyx wrote:
I’m trying to use the Cabal api to preprocess a .cabal file and have it run the preprocessors.
But preprocessSources takes a PackageDescription (which I get from a GenericPackageDescription) so this does not contain any information on the Executables or Libraries in the cabal file. So nothing gets executed.
The GenericPackageDescription is a bit confusing. It contains a PackageDescription but you should really ignore that one. That one only contains the top level meta info about the package. To get a PackageDescription from a GenericPackageDescription you either need to flatten it, or to pick a particular configuration, ie resolve all the conditionals. If you want to build the package then flattening does not make sense, you must instead finalise it, using finalizePackageDescription. Duncan
participants (2)
-
Duncan Coutts
-
Phyx