Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit b4c5f05

Browse files
committed
Allow a GhcInstallAction to skip directory enumeration
The Windows build is different from the other builds in a few ways, one of which is very important for this commit: * Windows installs HP and GHC in a single directory, so creating dependencies too early on the contents of the target GHC directory contents will cause Shake to complain that the directory contents have changed since making a dependency on them (which they have, since later, the HP-built packages need to come into that set of directories). So, after building the ghcVirtualTarget, we do not want the directory contents accounted for as dependencies just yet (it is done later for the entire target directory). In the osGhcTargetInstall function in the Windows builds, the directory is not completed at the point this action is used, so we cannot have the Shake system enumerating this directory for dependencies too soon. So we must make its osGhcTargetInstall no longer returns a directory, which prevents the vTarget code in Dirs.hs from making dependencies of the directory contents too soon. This change is part of a larger change but it is separated here as this isolates any effects on the common code. The Windows-specific changes will be in a separate commit for bookkeeping reasons. The GhcInstallAction type is only used internally to GhcDist and for the Windows case where it is the only build (currently) to use the GhcInstallCustom variant of the GhcInstall type. * hptool/src/OS/Win.hs * With this change to GhcInstallAction, the osGhcTargetInstall function can now elide the (incomplete) FilePath. * hptool/src/Types.hs * Allow the FilePath returned by a GhcInstallAction, to be optional. * hptool/src/OS/Win/WinRules.hs * Track GhcInstallAction change * hptool/src/GhcDist.hs * Allow the handling of ghcVirtualTarget to accomodate the case of not providing a FilePath, which will prevent the vdir code from creating dependencies on the contents.
1 parent 0ad0b1c commit b4c5f05

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

hptool/src/GhcDist.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ cppCommandFlags cpp = case cpp of
3939

4040

4141
ghcInstall :: GhcInstall ->
42-
FilePath -> Maybe (BuildConfig -> FilePath) -> Action FilePath
42+
FilePath -> Maybe (BuildConfig -> FilePath) -> Action (Maybe FilePath)
4343
ghcInstall postUntarAction base mfPrefix = do
4444
tarFile <- askGhcBinDistTarFile
4545
conf <- askBuildConfig
@@ -74,7 +74,7 @@ ghcInstallConfigure base mfPrefix conf distDir = do
7474
Just cppCommand <- getCppCommand settings settingsFile
7575
writeSettings settingsFile (updateCppFlags cppCommand settings)
7676

77-
return destDir
77+
return . Just $ destDir
7878
where
7979
layout Nothing = (base, base)
8080
layout (Just p) = (p, base </+> p)
@@ -113,7 +113,7 @@ ghcDistRules = do
113113
ghcInstall postUntar ghcLocalDir Nothing >> return ()
114114
ghcVirtualTarget ~/> do
115115
postUntar <- osGhcTargetInstall . osFromConfig <$> askBuildConfig
116-
ghcInstall postUntar targetDir (Just targetPrefix) >>= return . Just
116+
ghcInstall postUntar targetDir (Just targetPrefix)
117117
where
118118
targetPrefix = osGhcPrefix . osFromConfig
119119

hptool/src/OS/Win.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ winOsFromConfig BuildConfig{..} = os
5454
-- dependencies on the contents of winGhcTargetDir won't account
5555
-- for the HP pieces. Also, for Windows, the ghc-bindist/local and
5656
-- the GHC installed into the targetDir should be identical.
57-
-- osTargetAction is the right place to do the targetDir snapshot.
57+
-- It is incorrect to return anything here since the
58+
-- dir which we just processed is not completed yet (as mentioned
59+
-- above, we need to await the hp-specific packages to be built).
5860
GhcInstallCustom $ \bc distDir -> do
5961
void $ winGhcInstall winGhcTargetDir bc distDir
60-
return ghcLocalDir
62+
return Nothing
6163

6264
osPackageTargetDir p = winHpPrefix </> packagePattern p
6365

hptool/src/OS/Win/WinRules.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ winGhcInstall destDir bc distDir = do
5656
winGlutIncSrcs
5757
needContents winGlutIncludeInstallDir
5858

59-
return destDir
59+
return . Just $ destDir
6060

6161

6262
copyWinTargetExtras :: BuildConfig -> Action ()

hptool/src/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ data BuildConfig = BuildConfig
116116
-- | A function that is used for the actions after untar-ing GHC.
117117
-- The build configuration and file path of the untar-ed directory is
118118
-- provided, and the file path of the installed directory is returned.
119-
type GhcInstallAction = BuildConfig -> FilePath -> Action FilePath
119+
type GhcInstallAction = BuildConfig -> FilePath -> Action (Maybe FilePath)
120120

121121
-- | After untar-ing GHC, some platforms require configure-make, while
122122
-- other platforms need other custom steps.

0 commit comments

Comments
 (0)