summary refs log tree commit diff
path: root/pkgs/build-support/cabal
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2015-01-08 11:55:11 -0600
committerJohn Wiegley <johnw@newartisans.com>2015-01-08 11:55:11 -0600
commit268da0167788160a9136df88771a5792374e5a5e (patch)
treee67b0a85e659c8058974c4a2b55f9f062b9b0d6c /pkgs/build-support/cabal
parentd0efcfa55ebe7a95d3b88039452e8f79945b972b (diff)
downloadnixpkgs-268da0167788160a9136df88771a5792374e5a5e.tar
nixpkgs-268da0167788160a9136df88771a5792374e5a5e.tar.gz
nixpkgs-268da0167788160a9136df88771a5792374e5a5e.tar.bz2
nixpkgs-268da0167788160a9136df88771a5792374e5a5e.tar.lz
nixpkgs-268da0167788160a9136df88771a5792374e5a5e.tar.xz
nixpkgs-268da0167788160a9136df88771a5792374e5a5e.tar.zst
nixpkgs-268da0167788160a9136df88771a5792374e5a5e.zip
cabal: Allow optional use of cpphs as a preprocessor
Pinging @peti.  This is needed on Darwin/Yosemite because clang's
preprocessor is broken there.
Diffstat (limited to 'pkgs/build-support/cabal')
-rw-r--r--pkgs/build-support/cabal/default.nix17
1 files changed, 15 insertions, 2 deletions
diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix
index 0243fcff099..bf88a0d48e2 100644
--- a/pkgs/build-support/cabal/default.nix
+++ b/pkgs/build-support/cabal/default.nix
@@ -1,13 +1,14 @@
 # generic builder for Cabal packages
 
 { stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales
-, gnugrep, coreutils, hscolour
+, gnugrep, coreutils, hscolour, cpphs
 , enableLibraryProfiling ? false
 , enableSharedLibraries ? false
 , enableSharedExecutables ? false
 , enableStaticLibraries ? true
 , enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
 , enableHyperlinkSource ? true
+, enableCpphs ? false
 , extension ? (self : super : {})
 }:
 
@@ -56,6 +57,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
                 propagatedBuildInputs = filter (y : ! (y == null)) x.propagatedBuildInputs;
                 propagatedUserEnvPkgs = filter (y : ! (y == null)) x.propagatedUserEnvPkgs;
                 doCheck               = enableCheckPhase && x.doCheck;
+                useCpphs              = enableCpphs && x.useCpphs;
                 hyperlinkSource       = enableHyperlinkSource && x.hyperlinkSource;
                 # Disable Darwin builds: <https://github.com/NixOS/nixpkgs/issues/2689>.
                 meta                  = let meta = x.meta or {};
@@ -105,6 +107,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
             extraBuildInputs = self.buildTools ++
                                (optionals self.doCheck self.testDepends) ++
                                (optional self.hyperlinkSource hscolour) ++
+                               (optional self.useCpphs cpphs) ++
                                (if self.pkgconfigDepends == [] then [] else [pkgconfig]) ++
                                (if self.isLibrary then [] else self.buildDepends ++ self.extraLibraries ++ self.pkgconfigDepends);
 
@@ -153,6 +156,10 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
             # and run any regression test suites the package might have
             doCheck = enableCheckPhase;
 
+            # force cpphs instead of the C compiler's preprocessor; sometimes
+            # needed due to clang's wacky behavior
+            useCpphs = false;
+
             # pass the '--hyperlink-source' flag to ./Setup haddock
             hyperlinkSource = enableHyperlinkSource;
 
@@ -231,6 +238,9 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
               ${optionalString (versionOlder "7.8" ghc.version && !self.isLibrary) ''
                 configureFlags+=" --ghc-option=-j$NIX_BUILD_CORES"
               ''}
+              ${optionalString self.useCpphs ''
+                configureFlags+=" --ghc-option=-pgmPcpphs --ghc-option=-optP--cpp"
+              ''}
 
               ${optionalString self.stdenv.isDarwin ''
                 configureFlags+=" --with-gcc=clang"
@@ -259,7 +269,10 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
               export GHC_PACKAGE_PATH=$(${ghc.GHCPackages})
               test -n "$noHaddock" || ./Setup haddock --html --hoogle \
                   ${optionalString (stdenv.lib.versionOlder "6.12" ghc.version) "--ghc-options=-optP-P"} \
-                  ${optionalString self.hyperlinkSource "--hyperlink-source"}
+                  ${optionalString self.hyperlinkSource "--hyperlink-source"} \
+                  ${optionalString self.useCpphs ''
+                    --haddock-options="--optghc=-pgmPcpphs --optghc=-optP--cpp"
+                  ''}
 
               eval "$postBuild"
             '';