
On Tue, May 01, 2007 at 12:02:18 +0100, Duncan Coutts wrote:
On Tue, 2007-05-01 at 09:34 +0100, Magnus Therning wrote:
I'm trying to create a single cabal file containing specs for both a library and an executable using that library. I'm not having much luck though :(
This is what I have so far:
name: foo version: 0.1 exposed-modules: Foo.Bar other-modules: Foo.Qux Foo.C2HS hs-source-dirs: src include-dirs: csrc c-sources: csrc/qux.c extensions: ForeignFunctionInterface build-depends: base, haskell98
executable: foo hs-source-dirs: test-src main-is: foo.hs other-modules: Foo.Bar
When built this is the message I get: test-src/foo.hs:5:7: Could not find module `Foo.Bar': Use -v to see a list of the files searched for.
How do I specify that Foo.Bar is found where cabal puts it (./dist/build/)?
But surely Foo.Bar is in src, it is afterall exactly the same module as the one you're using in the library, no?
Yes.
So if foo.hs is in test-src and Foo/Bar.hs is in src then I think you just need:
hs-source-dirs: test-src, src
No, that's not enough, I also have to add the following lines to make the executable compile and link: extensions: ForeignFunctionInterface c-sources: csrc/ptrace.c That is, I end up compiling the library a second time! Can't I get the executable to link against the library that was just created?
You cannot specify that things are found in dist/build since that dir can placed anywhere by the user. But I don't see that you'd want to, I can't see how it makes any sense.
I was just expecting to not have to repeat myself in the cabal file. Not such a strange thing to expect from a build system, I think :-) Also, I don't really see what you mean by "that dir can be placed anywhere by the user". That dir is created as part of the build process and it's location is, AFAICS, always going to be ./dist/build. Finding the library after installation is another matter, but that problem should be taken care of during the `./Setup.hs configure` stage. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus.therning@gmail.com http://therning.org/magnus