haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.61k stars 690 forks source link

Add support for `configure-options` to `program-defaults-options`-section #2122

Open hvr opened 9 years ago

hvr commented 9 years ago

Currently, the cabal config file does not allow to persist settings such as

--configure-option=--build=x86_64-w64-mingw32

which are essential when using a cygwin environment with a mingw crosscompiler (as otherwise config.guess would report an inappropriate platform tuple)

(see also https://github.com/haskell/cabal/issues/1950#issuecomment-56495108 )

hvr commented 9 years ago

@dcoutts suggested on IRC:

hvr: ok, so I think it should be as simple as...

diff --git a/cabal-install/Distribution/Client/Config.hs b/cabal-install/Distribution/Client/Config.hs
index 679ba49..b485665 100644
--- a/cabal-install/Distribution/Client/Config.hs
+++ b/cabal-install/Distribution/Client/Config.hs
@@ -376,7 +376,7 @@ configFieldDescriptions =

   ++ toSavedConfig liftConfigFlag
        (configureOptions ParseArgs)
-       (["builddir", "configure-option", "constraint", "dependency"]
+       (["builddir", "constraint", "dependency"]
         ++ map fieldName installDirsFields)

ie stop deliberately removing that option from the set
and then you'll be able to use configure-option in the config file
note you can use it multiple times if necessary
it's a list monoid

...and that allows me to use

configure-option: --build=x86_64-w64-mingw32

in the global config section (i.e. not inside the program-defaults-options section)

hvr commented 9 years ago

While the commit I just pushed solves my problem, I'm not sure if the inconsistency of configure-option being special (i.e. by not being part of the program-defaults-options section) needs to be addressed long-term.