Skip to content

Change dist-newstyle layout from build/pid to build/ipkgid. #3652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cabal-install/Distribution/Client/DistDirLayout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Distribution.Client.DistDirLayout where

import System.FilePath
import Distribution.Package
( PackageId )
( PackageId, UnitId )
import Distribution.Compiler
import Distribution.Simple.Compiler (PackageDB(..))
import Distribution.Text
Expand All @@ -31,11 +31,11 @@ data DistDirLayout = DistDirLayout {
-- | The directory under dist where we keep the build artifacts for a
-- package we're building from a local directory.
--
-- This uses a 'PackageId' not just a 'PackageName' because technically
-- This uses a 'UnitId' not just a 'PackageName' because technically
-- we can have multiple instances of the same package in a solution
-- (e.g. setup deps).
--
distBuildDirectory :: PackageId -> FilePath,
distBuildDirectory :: UnitId -> FilePath,
distBuildRootDirectory :: FilePath,

-- | The directory under dist where we put the unpacked sources of
Expand All @@ -55,8 +55,8 @@ data DistDirLayout = DistDirLayout {
-- | The location for package-specific cache files (e.g. state used in
-- incremental rebuilds).
--
distPackageCacheFile :: PackageId -> String -> FilePath,
distPackageCacheDirectory :: PackageId -> FilePath,
distPackageCacheFile :: UnitId -> String -> FilePath,
distPackageCacheDirectory :: UnitId -> FilePath,

distTempDirectory :: FilePath,
distBinDirectory :: FilePath,
Expand Down Expand Up @@ -88,7 +88,7 @@ defaultDistDirLayout projectRootDirectory =
--TODO: switch to just dist at some point, or some other new name

distBuildRootDirectory = distDirectory </> "build"
distBuildDirectory pkgid = distBuildRootDirectory </> display pkgid
distBuildDirectory uid = distBuildRootDirectory </> display uid

distUnpackedSrcRootDirectory = distDirectory </> "src"
distUnpackedSrcDirectory pkgid = distUnpackedSrcRootDirectory
Expand All @@ -97,8 +97,8 @@ defaultDistDirLayout projectRootDirectory =
distProjectCacheDirectory = distDirectory </> "cache"
distProjectCacheFile name = distProjectCacheDirectory </> name

distPackageCacheDirectory pkgid = distBuildDirectory pkgid </> "cache"
distPackageCacheFile pkgid name = distPackageCacheDirectory pkgid </> name
distPackageCacheDirectory uid = distBuildDirectory uid </> "cache"
distPackageCacheFile uid name = distPackageCacheDirectory uid </> name

distTempDirectory = distDirectory </> "tmp"

Expand Down
41 changes: 22 additions & 19 deletions cabal-install/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ rebuildTargetsDryRun distDirLayout@DistDirLayout{..} = \installPlan -> do
return (BuildStatusUpToDate buildSuccess)
where
packageFileMonitor =
newPackageFileMonitor distDirLayout (packageId pkg)
newPackageFileMonitor distDirLayout (installedUnitId pkg)


-- | A specialised traversal over the packages in an install plan.
Expand Down Expand Up @@ -390,22 +390,22 @@ data PackageFileMonitor = PackageFileMonitor {
--
type BuildSuccessMisc = (DocsResult, TestsResult)

newPackageFileMonitor :: DistDirLayout -> PackageId -> PackageFileMonitor
newPackageFileMonitor DistDirLayout{distPackageCacheFile} pkgid =
newPackageFileMonitor :: DistDirLayout -> UnitId -> PackageFileMonitor
newPackageFileMonitor DistDirLayout{distPackageCacheFile} ipkgid =
PackageFileMonitor {
pkgFileMonitorConfig =
newFileMonitor (distPackageCacheFile pkgid "config"),
newFileMonitor (distPackageCacheFile ipkgid "config"),

pkgFileMonitorBuild =
FileMonitor {
fileMonitorCacheFile = distPackageCacheFile pkgid "build",
fileMonitorCacheFile = distPackageCacheFile ipkgid "build",
fileMonitorKeyValid = \componentsToBuild componentsAlreadyBuilt ->
componentsToBuild `Set.isSubsetOf` componentsAlreadyBuilt,
fileMonitorCheckIfOnlyValueChanged = True
},

pkgFileMonitorReg =
newFileMonitor (distPackageCacheFile pkgid "registration")
newFileMonitor (distPackageCacheFile ipkgid "registration")
}

-- | Helper function for 'checkPackageFileMonitorChanged',
Expand Down Expand Up @@ -683,7 +683,7 @@ rebuildTarget verbosity
unpackTarballPhase tarball =
withTarballLocalDirectory
verbosity distDirLayout tarball
(packageId pkg) (pkgBuildStyle pkg)
(packageId pkg) (installedPackageId pkg) (pkgBuildStyle pkg)
(pkgDescriptionOverride pkg) $

case pkgBuildStyle pkg of
Expand All @@ -701,7 +701,7 @@ rebuildTarget verbosity

buildInplace buildStatus srcdir builddir
where
builddir = distBuildDirectory (packageId pkg)
builddir = distBuildDirectory (installedUnitId pkg)

buildAndInstall srcdir builddir =
buildAndInstallUnpackedPackage
Expand Down Expand Up @@ -787,19 +787,22 @@ downloadedSourceLocation pkgloc =


-- | Ensure that the package is unpacked in an appropriate directory, either
-- a temporary one or a persistent one under the shared dist directory.
-- a temporary one or a persistent one under the shared dist directory.
--
withTarballLocalDirectory
:: Verbosity
-> DistDirLayout
-> FilePath
-> PackageId
-> UnitId
-> BuildStyle
-> Maybe CabalFileText
-> (FilePath -> FilePath -> IO a)
-> (FilePath -> -- Source directory
FilePath -> -- Build directory
IO a)
-> IO a
withTarballLocalDirectory verbosity distDirLayout@DistDirLayout{..}
tarball pkgid buildstyle pkgTextOverride
tarball pkgid ipkgid buildstyle pkgTextOverride
buildPkg =
case buildstyle of
-- In this case we make a temp dir, unpack the tarball to there and
Expand All @@ -819,15 +822,15 @@ withTarballLocalDirectory verbosity distDirLayout@DistDirLayout{..}
BuildInplaceOnly -> do
let srcrootdir = distUnpackedSrcRootDirectory
srcdir = distUnpackedSrcDirectory pkgid
builddir = distBuildDirectory pkgid
builddir = distBuildDirectory ipkgid
-- TODO: [nice to have] use a proper file monitor rather than this dir exists test
exists <- doesDirectoryExist srcdir
unless exists $ do
createDirectoryIfMissingVerbose verbosity False srcrootdir
unpackPackageTarball verbosity tarball srcrootdir
pkgid pkgTextOverride
moveTarballShippedDistDirectory verbosity distDirLayout
srcrootdir pkgid
srcrootdir pkgid ipkgid
buildPkg srcdir builddir


Expand Down Expand Up @@ -873,9 +876,9 @@ unpackPackageTarball verbosity tarball parentdir pkgid pkgTextOverride =
-- system, though we'll still need to keep this hack for older packages.
--
moveTarballShippedDistDirectory :: Verbosity -> DistDirLayout
-> FilePath -> PackageId -> IO ()
-> FilePath -> PackageId -> UnitId -> IO ()
moveTarballShippedDistDirectory verbosity DistDirLayout{distBuildDirectory}
parentdir pkgid = do
parentdir pkgid uid = do
distDirExists <- doesDirectoryExist tarballDistDir
when distDirExists $ do
debug verbosity $ "Moving '" ++ tarballDistDir ++ "' to '"
Expand All @@ -884,7 +887,7 @@ moveTarballShippedDistDirectory verbosity DistDirLayout{distBuildDirectory}
renameDirectory tarballDistDir targetDistDir
where
tarballDistDir = parentdir </> display pkgid </> "dist"
targetDistDir = distBuildDirectory pkgid
targetDistDir = distBuildDirectory uid


buildAndInstallUnpackedPackage :: Verbosity
Expand Down Expand Up @@ -1074,8 +1077,9 @@ buildInplaceUnpackedPackage verbosity

--TODO: [code cleanup] there is duplication between the distdirlayout and the builddir here
-- builddir is not enough, we also need the per-package cachedir
let uid = installedUnitId pkg
createDirectoryIfMissingVerbose verbosity False builddir
createDirectoryIfMissingVerbose verbosity False (distPackageCacheDirectory pkgid)
createDirectoryIfMissingVerbose verbosity False (distPackageCacheDirectory uid)

-- Configure phase
--
Expand Down Expand Up @@ -1193,12 +1197,11 @@ buildInplaceUnpackedPackage verbosity
return (BuildOk docsResult testsResult ipkgs)

where
pkgid = packageId rpkg
ipkgid = installedPackageId rpkg

isParallelBuild = buildSettingNumJobs >= 2

packageFileMonitor = newPackageFileMonitor distDirLayout pkgid
packageFileMonitor = newPackageFileMonitor distDirLayout ipkgid

whenReConfigure action = case buildStatus of
BuildStatusConfigure _ -> action
Expand Down