[cabal] Extract simple static information from PackageDescription

Jakob Schöttl jschoett at gmail.com
Sat Nov 7 02:19:18 UTC 2015


On 06.11.2015 12:04, Henning Thielemann wrote:
>
> On Fri, 6 Nov 2015, Jakob Schöttl wrote:
>
>> I am trying to extract a simple static information out of the cabal 
>> file: the hs-source-dirs
>>
>> Is there a way to get this without resolving conditionals, or with 
>> minimal effort? (I don't even understand how to resolving conditionals.)
>
> If you write in a package description:
>
> Â  If flag(foo)
> Â Â Â  Hs-Source-Dirs: foo
> Â  Else
> Â Â Â  Hs-Source-Dirs: bar
>
> then Hs-Source-Dirs depends on conditionals. I use this technique in 
> order to select specific modules for Unix and Windows without CPP. How 
> do you want to extract Hs-Source-Dirs without knowing the flag values?
Thank you, Henning. I see, I need to handle this conditionals even if I 
don't have such conditionals and flags in my cabal file.

How can I resolve the conditionals?

Can I somehow update the GenericPackageDescription i.e. set all flag 
values and then fetch the complete PackageDescription in using 
packageDescription? 
https://hackage.haskell.org/package/Cabal-1.22.4.0/docs/Distribution-PackageDescription.html#t:GenericPackageDescription

Or are condLibrary, condExecutable, ... the only way to access this data?




More information about the Libraries mailing list