Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out what flags we are building with in Setup.hs

Tags:

haskell

cabal

I need to find out what flags (the type found in cabal files) are being built with in Setup.hs. I think I'm looking for something with type FlagAssignment. How can I get this?

like image 360
Peter Avatar asked Nov 14 '22 04:11

Peter


1 Answers

Idris has to do this, you can see the code here. In short, read the configConfigurationsFlags of ConfigFlags which you can get from the configFlags field of the LocalBuildInfo record. LocalBuildInfo is passed to every hook when you use defaultMainWithHooks.

N.B. This information is just the flags passed to configure, so any of them that aren't specified won't be there, rather than having their default values. I think this is a bug, but as of Jan 2016 it's not fixed.

UPDATE October 2016: In Cabal-1.24 there is a flagAssignment field in LocalBuildInfo that has the flags after they're resolved by configuration.

like image 111
Echo Nolan Avatar answered Dec 26 '22 19:12

Echo Nolan