-
Notifications
You must be signed in to change notification settings - Fork 710
Add feature to generate cabal_macros.h #2209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This uses `cabal configure` to determine which exact dependency versions we are compiling against. MIN_VERSION_* macros are the standard way to build CPP dependency switches in Haskell packages, and they replace our custom macros (like PARALLEL3). We can now conditionally compile against any version of our dependencies, without first having to manually add a flag via autoconf. All ghc and hlint invocations were adjusted to take these macros into account. We now require hlint >= 1.8.60, which support the --cpp-file option, and any installed version of cabal. In addition to providing MIN_VERSION_* macros, the `cabal configure` step makes the build fail at configuration time if the user tries to compile against a dependency version we don't support; before, this case led to type errors which were not clearly user errors. In order to obtain the sought cabal_macros.h, we have to work around the fact that cabal does not yet provide a way to build only the macros (see haskell/cabal#2209). Ideally, they would be created as part of `cabal configure`, but unfortunately they are created as the first step of `cabal build`. Thus we `cabal build` a dummy executable (HaskellPackageVersionsDummy) in a temporary directory to obtain cabal_macros.h.
This uses `cabal configure` to determine which exact dependency versions we are compiling against. MIN_VERSION_* macros are the standard way to build CPP dependency switches in Haskell packages, and they replace our custom macros (like PARALLEL3). We can now conditionally compile against any version of our dependencies, without first having to manually add a flag via autoconf. All ghc and hlint invocations were adjusted to take these macros into account. We now require hlint >= 1.8.60, which support the --cpp-file option, and any installed version of cabal. In addition to providing MIN_VERSION_* macros, the `cabal configure` step makes the build fail at configuration time if the user tries to compile against a dependency version we don't support; before, this case led to type errors which were not clearly user errors. This fixes issue ganeti#988. In order to obtain the sought cabal_macros.h, we have to work around the fact that cabal does not yet provide a way to build only the macros (see haskell/cabal#2209). Ideally, they would be created as part of `cabal configure`, but unfortunately they are created as the first step of `cabal build`. Thus we `cabal build` a dummy executable (HaskellPackageVersionsDummy) in a temporary directory to obtain cabal_macros.h.
IMO, this makes more sense than the current situation. @dcoutts, is there any reason this is done at |
This is a really old one but we are hitting it in the haskell-ide-engine branch that uses |
We would like to generate and use
cabal_macros.h
(e.g. forhlint
or ourghc -M
based build system) without actually runningcabal build
.I was surprised that
cabal_macros.h
is created bycabal build
only, and not bycabal configure
.Also, while you can do
cabal build mytarget
, there isn't an empty target, so there currently is no way to tell cabal to only generatecabal_macros.h
and do no further compilation.It would be great to have a way to generate only
cabal_macros.h
; maybe via one of these alternatives:cabal configure
cabal build
cabal build ""
)The text was updated successfully, but these errors were encountered: