[commit: ghc] wip/nfs-locking: Detect the right patch command and use it when building gmp. (79cf2e3)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:39:57 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/79cf2e3d1f5d48ff731060f4c0f17cd7e8310514/ghc

>---------------------------------------------------------------

commit 79cf2e3d1f5d48ff731060f4c0f17cd7e8310514
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Thu Jan 14 23:41:31 2016 +0000

    Detect the right patch command and use it when building gmp.
    
    See #158.


>---------------------------------------------------------------

79cf2e3d1f5d48ff731060f4c0f17cd7e8310514
 cfg/system.config.in |  5 +++--
 src/Builder.hs       |  2 ++
 src/Rules/Actions.hs | 11 ++++++++++-
 src/Rules/Gmp.hs     |  6 +-----
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/cfg/system.config.in b/cfg/system.config.in
index 8b5b553..4539979 100644
--- a/cfg/system.config.in
+++ b/cfg/system.config.in
@@ -1,6 +1,6 @@
 # This file is processed by the configure script
-# See 'Settings/User.hs' for user-defined settings
-#=================================================
+# See 'src/Settings/User.hs' for user-defined settings
+#=====================================================
 
 # Paths to builders:
 #===================
@@ -40,6 +40,7 @@ nm               = @NmCmd@
 objdump          = @ObjdumpCmd@
 ranlib           = @REAL_RANLIB_CMD@
 tar              = @TarCmd@
+patch            = @PatchCmd@
 perl             = @PerlCmd@
 
 # Information about builders:
diff --git a/src/Builder.hs b/src/Builder.hs
index efc3216..353c00f 100644
--- a/src/Builder.hs
+++ b/src/Builder.hs
@@ -40,6 +40,7 @@ data Builder = Alex
              | Ld
              | Nm
              | Objdump
+             | Patch
              | Perl
              | Ranlib
              | Tar
@@ -82,6 +83,7 @@ builderKey builder = case builder of
     Ld               -> "ld"
     Nm               -> "nm"
     Objdump          -> "objdump"
+    Patch            -> "patch"
     Perl             -> "perl"
     Ranlib           -> "ranlib"
     Tar              -> "tar"
diff --git a/src/Rules/Actions.hs b/src/Rules/Actions.hs
index eb37630..7692c86 100644
--- a/src/Rules/Actions.hs
+++ b/src/Rules/Actions.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE RecordWildCards #-}
 module Rules.Actions (
     build, buildWithResources, copyFile, createDirectory, removeDirectory, moveDirectory,
-    fixFile, runConfigure, runMake, runBuilder, makeExecutable
+    fixFile, runConfigure, runMake, applyPatch, runBuilder, makeExecutable
     ) where
 
 import qualified System.Directory as IO
@@ -108,6 +108,15 @@ runMake dir args = do
     putBuild $ "| Run make" ++ note ++ " in " ++ dir ++ "..."
     quietly $ cmd Shell (EchoStdout False) makeCommand ["-C", dir] args
 
+applyPatch :: FilePath -> FilePath -> Action ()
+applyPatch dir patch = do
+    let file = dir -/- patch
+    need [file]
+    needBuilder False Patch
+    path <- builderPath Patch
+    putBuild $ "| Apply patch " ++ file
+    quietly $ cmd Shell (EchoStdout False) [Cwd dir] [path, "-p0 <", patch]
+
 runBuilder :: Builder -> [String] -> Action ()
 runBuilder builder args = do
     needBuilder laxDependencies builder
diff --git a/src/Rules/Gmp.hs b/src/Rules/Gmp.hs
index 069dd28..eb1158e 100644
--- a/src/Rules/Gmp.hs
+++ b/src/Rules/Gmp.hs
@@ -73,7 +73,6 @@ gmpRules = do
     gmpLibraryH %> \_ -> do
         when trackBuildSystem $ need [sourcePath -/- "Rules/Gmp.hs"]
 
-        -- Do we need this step?
         liftIO $ removeFiles gmpBuildPath ["//*"]
 
         -- Note: We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
@@ -86,17 +85,14 @@ gmpRules = do
                      ++ "(found: " ++ show tarballs ++ ")."
 
         need tarballs
-
         createDirectory gmpBuildPath
         build $ fullTarget gmpTarget Tar tarballs [gmpBuildPath]
 
-        -- TODO: replace "patch" with PATCH_CMD
         forM_ gmpPatches $ \src -> do
             let patch     = takeFileName src
                 patchPath = gmpBuildPath -/- patch
             copyFile src patchPath
-            putBuild $ "| Apply " ++ patchPath
-            unit . quietly $ cmd Shell (EchoStdout False) [Cwd gmpBuildPath] "patch -p0 <" [patch]
+            applyPatch gmpBuildPath patch
 
         -- TODO: What's `chmod +x libraries/integer-gmp/gmp/ln` for?
 



More information about the ghc-commits mailing list