[commit: ghc] wip/nfs-locking: Move gmp library instead of copying it. Add moveFile. (de4f7bc)

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


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

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

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

commit de4f7bcc27596946d26f708782f74a6266706842
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Mon May 2 03:59:52 2016 +0100

    Move gmp library instead of copying it. Add moveFile.
    
    See #163.


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

de4f7bcc27596946d26f708782f74a6266706842
 src/Rules/Actions.hs | 13 ++++++++++---
 src/Rules/Gmp.hs     |  3 +--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/Rules/Actions.hs b/src/Rules/Actions.hs
index f006947..edf98eb 100644
--- a/src/Rules/Actions.hs
+++ b/src/Rules/Actions.hs
@@ -1,7 +1,8 @@
 module Rules.Actions (
-    build, buildWithResources, buildWithCmdOptions, copyFile, createDirectory,
-    removeDirectory, copyDirectory, moveDirectory, applyPatch, fixFile, runMake,
-    runMakeVerbose, renderLibrary, renderProgram, runBuilder, makeExecutable
+    build, buildWithResources, buildWithCmdOptions, copyFile, moveFile,
+    createDirectory, removeDirectory, copyDirectory, moveDirectory,
+    applyPatch, fixFile, runMake, runMakeVerbose, renderLibrary, renderProgram,
+    runBuilder, makeExecutable
     ) where
 
 import qualified System.Directory       as IO
@@ -87,6 +88,12 @@ copyFile source target = do
     putProgressInfo $ renderAction "Copy file" source target
     copyFileChanged source target
 
+-- Note, moveFile cannot track the source, because it is moved.
+moveFile :: FilePath -> FilePath -> Action ()
+moveFile source target = do
+    putProgressInfo $ renderAction "Move file" source target
+    liftIO $ IO.renameFile source target
+
 createDirectory :: FilePath -> Action ()
 createDirectory dir = do
     putBuild $ "| Create directory " ++ dir
diff --git a/src/Rules/Gmp.hs b/src/Rules/Gmp.hs
index e2502dd..1e962ec 100644
--- a/src/Rules/Gmp.hs
+++ b/src/Rules/Gmp.hs
@@ -103,8 +103,7 @@ gmpRules = do
 
             copyFile (libPath -/- "gmp.h") gmpLibraryInTreeH
             copyFile (libPath -/- "gmp.h") gmpLibraryH
-            -- TODO: why copy library, can we move it instead?
-            copyFile (libPath -/- ".libs/libgmp.a") gmpLibrary
+            moveFile (libPath -/- ".libs/libgmp.a") gmpLibrary
 
             createDirectory gmpObjects
             build $ Target gmpContext Ar [gmpLibrary] [gmpObjects]



More information about the ghc-commits mailing list