git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #5645 from jwiegley/allow-cpphs

cabal: Allow optional use of cpphs as a preprocessor

commit597393052c60769f17a7d820f6d8f958ad7083e0 authorJohn Wiegley <johnw@newartisans.com> dateThu 8 Jan 2015, 14:45 (12 years ago) parent50b2fab268da01
1 file changed+15−2
pkgs/build-support/cabal/default.nix+15−2
pkgs/build-support/cabal/default.nix+15−2
@@ -1,13 +1,14 @@
11# generic builder for Cabal packages
22
33{ stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales
4−, gnugrep, coreutils, hscolour
4+, gnugrep, coreutils, hscolour, cpphs
55, enableLibraryProfiling ? false
66, enableSharedLibraries ? false
77, enableSharedExecutables ? false
88, enableStaticLibraries ? true
99, enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
1010, enableHyperlinkSource ? true
11+, enableCpphs ? false
1112, extension ? (self : super : {})
1213}:
1314
@@ -56,6 +57,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
5657 propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
5758 propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs;
5859 doCheck = enableCheckPhase && x.doCheck;
60+ useCpphs = enableCpphs && x.useCpphs;
5961 hyperlinkSource = enableHyperlinkSource && x.hyperlinkSource;
6062 # Disable Darwin builds: <https://github.com/NixOS/nixpkgs/issues/2689>.
6163 meta = let meta = x.meta or {};
@@ -105,6 +107,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
105107 extraBuildInputs = self.buildTools ++
106108 (optionals self.doCheck self.testDepends) ++
107109 (optional self.hyperlinkSource hscolour) ++
110+ (optional self.useCpphs cpphs) ++
108111 (if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++
109112 (if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends);
110113
@@ -153,6 +156,10 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
153156 # and run any regression test suites the package might have
154157 doCheck = enableCheckPhase;
155158
159+ # force cpphs instead of the C compiler's preprocessor; sometimes
160+ # needed due to clang's wacky behavior
161+ useCpphs = false;
162+
156163 # pass the '--hyperlink-source' flag to ./Setup haddock
157164 hyperlinkSource = enableHyperlinkSource;
158165
@@ -231,6 +238,9 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
231238 ${optionalString (versionOlder "7.8" ghc.version && !self.isLibrary) ''
232239 configureFlags+=" --ghc-option=-j$NIX_BUILD_CORES"
233240 ''}
241+ ${optionalString self.useCpphs ''
242+ configureFlags+=" --ghc-option=-pgmPcpphs --ghc-option=-optP--cpp"
243+ ''}
234244
235245 ${optionalString self.stdenv.isDarwin ''
236246 configureFlags+=" --with-gcc=clang"
@@ -259,7 +269,10 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
259269 export GHC_PACKAGE_PATH=$(${ghc.GHCPackages})
260270 test -n "$noHaddock" || ./Setup haddock --html --hoogle \
261271 ${optionalString (stdenv.lib.versionOlder "6.12" ghc.version) "--ghc-options=-optP-P"} \
262− ${optionalString self.hyperlinkSource "--hyperlink-source"}
272+ ${optionalString self.hyperlinkSource "--hyperlink-source"} \
273+ ${optionalString self.useCpphs ''
274+ --haddock-options="--optghc=-pgmPcpphs --optghc=-optP--cpp"
275+ ''}
263276
264277 eval "$postBuild"
265278 '';