waf-ghc

waf-ghc allows compiling directly with the Glasgow Haskell Compiler (GHC) from the build framework waf, without having to rely on Cabal. This allows easily integration with the rest of the toolchain in multi-language projects.

Download

ghc.py

Install

To use, just copy ghc.py in your project source directory, and make it accessible to waf.

def options(opt):
    opt.load('ghc', tooldir='share/waf-tools')

You can specify packages to be searched for, in order for their compiler options to be added to specific use variables.

def configure(conf):
  conf.ghc_pkgs = 'repa'
  conf.load('ghc')

Finally, build your objects or program in the familiar way. Make sure to add the use variables for your Haskell packages, and duplicate that list in the packages field. The former being used by the standard linker, the latter by the Haskell compiler to build the objects.

def build(bld):
  bld.program(source   = bld.path.ant_glob('src/*.cc src/*.hs'),
              target   = myprogram,
              ghcflags = ['-rtsopts', '-O2'],
              uselib   = 'QT5QUICK REPA',
              packages = 'repa')

Yeah, that’s three times the same variables inputted everywhere, so you could enhance it for sure.

Have fun!

News

2014-03-19 Initial release under the simplified BSD license.