
On Fri, 2009-11-13 at 15:24 +0000, Jeremy O'Donoghue wrote:
So I take it that these modules are generated "from nothing" rather than something like happy/alex pre-processors where the .hs files are generated from .y/.x files. Cabal supports the latter fairly well and you can add custom pre-processors in this style. It doesn't really support generating modules out of thin-air in the build step (though it does this internally for the Paths_pkgname module).
They don't come from nothing as they are derived from a C header file and an Eiffel interface (for historical reasons).
Ok, but not files in a 1:1 correspondence with the modules you generate. It's more like a bunch of files used to generate another bunch of files, with no simple naming convention to relate the two.
It sounds as though the custom preprocessor approach is closest to what we have/need.
Cabal's simple notion of preprocessor really only covers the case where you've got: Foo/Bar.hs generated from Foo/Bar.some-other-extension The pre-processors are registered by the extension and the Cabal pre-processing step decides what pre-processors to run by looking for files with known extensions.
We have a custom config hook containing the following:
myConfHook :: (Either GenericPackageDescription PackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo myConfHook (pkg0, pbi) flags = do createDirectoryIfMissing True wxcoreDirectory system $ "wxdirect -t --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile system $ "wxdirect -i --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile system $ "wxdirect -c --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile system $ "wxdirect -d --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ intercalate " " eiffelFiles
In this case, wxcoreDirectory resolves to "dist/build/autogen/Graphics/UI/WXCore".
The calls to wxdirect generate a number of haskell files as output (currently in dist/build/autogen).
Regards Jeremy