[Haskell-cafe] Cabal and autogenerated files

Jeremy O'Donoghue jeremy.odonoghue at gmail.com
Fri Nov 13 10:24:53 EST 2009



On Thu, 12 Nov 2009 18:16 +0000, "Duncan Coutts"
<duncan.coutts at googlemail.com> wrote:
> On Thu, 2009-11-12 at 17:54 +0000, Jeremy O'Donoghue wrote:
> > Hi all,
> > 
> > Another, probably simple, question regarding cabalization.
> > 
> > Part of wxcore, the low level abstraction in wxHaskell, consists of
> > haskell modules which are generated automatically by parsing C headers
> > using another tool, wxdirect.
> > 
> > When trying to create an sdist package, we run into the problem that
> > because we export modules which are automatically generated, after a
> > 'clean', they do not exist, so the sdist package generation fails.
> 
> 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).

It sounds as though the custom preprocessor approach is closest to what
we have/need.

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
-- 
  Jeremy O'Donoghue
  jeremy.odonoghue at gmail.com



More information about the Haskell-Cafe mailing list