[Haskell-cafe] Maintaining test-suite dependencies with cabal
Bram Neijt
bneijt at gmail.com
Sat Sep 6 10:19:47 UTC 2014
I have split up my dependencies and placed them in separate
directories. This was all pretty easy to do, however I do have one
thing I don't understand.
My Main.hs[1] includes: import After (afterPartialCmdline, afterPid)
And my after.cabal[2] has a library exposing the After module.
It looks like me that Main.hs only uses functions from After, however
if I don't list "Process" in the "exposed-modules:" I get a linker
error:
Linking dist/build/after/after ...
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.text+0x90a):
undefined reference to `afterzm0zi1zi2zi0_Process_psCmdLine4_closure'
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.text+0x945):
undefined reference to `afterzm0zi1zi2zi0_Process_psListing2_closure'
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.text+0x4a3):
undefined reference to `afterzm0zi1zi2zi0_Process_psCmdLine1_info'
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.text+0x6ca):
undefined reference to `afterzm0zi1zi2zi0_Process_psCmdLine1_info'
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.data+0xf0):
undefined reference to `afterzm0zi1zi2zi0_Process_psCmdLine1_closure'
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.data+0x108):
undefined reference to `afterzm0zi1zi2zi0_Process_psListing2_closure'
/home/bram/program/after/dist/build/libHSafter-0.1.2.0.a(After.o):(.data+0x118):
undefined reference to `afterzm0zi1zi2zi0_Process_psCmdLine4_closure'
collect2: error: ld returned 1 exit status
Why do I have to mention "Process" in the exposed modules list?
Doesn't this mean that I eventuall have to mention all my modules in
the exposed modules list, and then what is the point of having to
mention them in the first place?
Greetings,
Bram
[1] https://github.com/bneijt/after/blob/master/src/main/Main.hs
[2] https://github.com/bneijt/after/blob/master/after.cabal
On Thu, Sep 4, 2014 at 10:36 PM, Rogan Creswick <creswick at gmail.com> wrote:
>
> On Fri, Aug 22, 2014 at 10:22 AM, Omari Norman <omari at smileystation.com>
> wrote:
>>
>>
>> But a tool like Cartel does nothing about compile times. If compile times
>> are really a concern, I would just put the library in a completely separate
>> package and package the executables and tests separately.
>
>
> One way to help reduce compile times (a bit anyway) is to separate the
> executables and tests into parallel source directories from your library
> code. I generally use a layout like this:
>
> <project dir>/
> - project.cabal
> - src/
> - apps/
> - tests/resources/
> - tests/src/
>
> Library code goes in src, application Main's go in apps/, test source goes
> in tests/src/ and any necessary data files go in tests/resources.
>
> Then tests and apps defined in the cabal file depend on the library, and the
> source for the library is not rebuilt for each executable/test declaration
> in the cabal file (generally speaking; with flags and custom builds you can
> cause just about anything...)
>
> --Rogan
>
More information about the Haskell-Cafe
mailing list