Fix install rules by untracking copy files and use relative path (#396)
authorZhen Zhang <izgzhen@gmail.com>
Sat, 19 Aug 2017 01:39:25 +0000 (09:39 +0800)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 19 Aug 2017 01:39:25 +0000 (02:39 +0100)
src/Hadrian/Oracles/DirectoryContents.hs
src/Rules/Install.hs

index 19a5192..f302af9 100644 (file)
@@ -1,6 +1,6 @@
 {-# LANGUAGE TypeFamilies #-}
 module Hadrian.Oracles.DirectoryContents (
-    directoryContents, copyDirectoryContents, directoryContentsOracle,
+    directoryContents, copyDirectoryContents, directoryContentsOracle, copyDirectoryContentsUntracked,
     Match (..), matches, matchAll
     ) where
 
@@ -45,6 +45,14 @@ copyDirectoryContents expr source target = do
     let cp file = copyFile file $ target -/- makeRelative source file
     mapM_ cp =<< directoryContents expr source
 
+-- | Copy the contents of the source directory that matches a given 'Match'
+-- expression into the target directory. The copied contents is untracked.
+copyDirectoryContentsUntracked :: Match -> FilePath -> FilePath -> Action ()
+copyDirectoryContentsUntracked expr source target = do
+    putProgressInfo =<< renderAction "Copy directory contents (untracked)" source target
+    let cp file = copyFileUntracked file $ target -/- makeRelative source file
+    mapM_ cp =<< directoryContents expr source
+
 newtype DirectoryContents = DirectoryContents (Match, FilePath)
     deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
 type instance RuleResult DirectoryContents = [FilePath]
index 12135b4..2400933 100644 (file)
@@ -186,7 +186,9 @@ installPackages = do
             withLatestBuildStage pkg $ \stage -> do
                 let context = vanillaContext stage pkg
                 top <- topDirectory
-                installDistDir <- (top -/-) <$> buildPath context
+                installDistDir <- buildPath context
+                let absInstallDistDir = top -/- installDistDir
+
                 need =<< packageTargets stage pkg
                 docDir <- installDocDir
                 ghclibDir <- installGhcLibDir
@@ -203,7 +205,7 @@ installPackages = do
                 need [cabalFile, pkgConf] -- TODO: check if need pkgConf
 
                 -- HACK (#318): copy stuff back to the place favored by ghc-cabal
-                quietly $ copyDirectoryContents (Not excluded)
+                quietly $ copyDirectoryContentsUntracked (Not excluded)
                     installDistDir (installDistDir -/- "build")
 
                 whenM (isSpecified HsColour) $
@@ -212,7 +214,7 @@ installPackages = do
                 pref <- setting InstallPrefix
                 unit $ cmd ghcCabalInplace [ "copy"
                                            , pkgPath pkg
-                                           , installDistDir
+                                           , absInstallDistDir
                                            , strip
                                            , destDir
                                            , pref