Skip to content

Commit 80a0c0d

Browse files
committed
refactor: seprate build directories and drop -inplace
refactor: simplify distBuildDirectory
1 parent 787e051 commit 80a0c0d

File tree

4 files changed

+13
-28
lines changed

4 files changed

+13
-28
lines changed

cabal-install/src/Distribution/Client/DistDirLayout.hs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ import Distribution.Simple.Compiler
4848
)
4949
import Distribution.System
5050
import Distribution.Types.ComponentName
51-
import Distribution.Types.LibraryName
51+
import Distribution.Client.Toolchain (Stage)
5252

5353
-- | Information which can be used to construct the path to
5454
-- the build directory of a build. This is LESS fine-grained
5555
-- than what goes into the hashed 'InstalledPackageId',
5656
-- and for good reason: we don't want this path to change if
5757
-- the user, say, adds a dependency to their project.
5858
data DistDirParams = DistDirParams
59-
{ distParamUnitId :: UnitId
59+
{ distParamStage :: Stage
60+
, distParamUnitId :: UnitId
6061
, distParamPackageId :: PackageId
6162
, distParamComponentId :: ComponentId
6263
, distParamComponentName :: Maybe ComponentName
@@ -194,29 +195,11 @@ defaultDistDirLayout projectRoot mdistDirectory haddockOutputDir =
194195
distBuildDirectory :: DistDirParams -> FilePath
195196
distBuildDirectory params =
196197
distBuildRootDirectory
198+
</> prettyShow (distParamStage params)
197199
</> prettyShow (distParamPlatform params)
198200
</> prettyShow (distParamCompilerId params)
199-
</> prettyShow (distParamPackageId params)
200-
</> ( case distParamComponentName params of
201-
Nothing -> ""
202-
Just (CLibName LMainLibName) -> ""
203-
Just (CLibName (LSubLibName name)) -> "l" </> prettyShow name
204-
Just (CFLibName name) -> "f" </> prettyShow name
205-
Just (CExeName name) -> "x" </> prettyShow name
206-
Just (CTestName name) -> "t" </> prettyShow name
207-
Just (CBenchName name) -> "b" </> prettyShow name
208-
)
209-
</> ( case distParamOptimization params of
210-
NoOptimisation -> "noopt"
211-
NormalOptimisation -> ""
212-
MaximumOptimisation -> "opt"
213-
)
214-
</> ( let uid_str = prettyShow (distParamUnitId params)
215-
in if uid_str == prettyShow (distParamComponentId params)
216-
then ""
217-
else uid_str
218-
)
219-
201+
</> prettyShow (distParamUnitId params)
202+
220203
distUnpackedSrcRootDirectory :: FilePath
221204
distUnpackedSrcRootDirectory = distDirectory </> "src"
222205

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ elaborateInstallPlan
18731873
BuildInplaceOnly{} ->
18741874
mkComponentId $
18751875
prettyShow pkgid
1876-
++ "-inplace"
1876+
++ prettyShow (elabStage elab0)
18771877
++ ( case Cabal.componentNameString cname of
18781878
Nothing -> ""
18791879
Just s -> "-" ++ prettyShow s
@@ -2051,7 +2051,7 @@ elaborateInstallPlan
20512051
-> LogProgress ElaboratedConfiguredPackage
20522052
elaborateSolverToPackage
20532053
pkgWhyNotPerComponent
2054-
pkg@SolverPackage {solverPkgSource = SourcePackage {srcpkgPackageId}}
2054+
pkg@SolverPackage {solverPkgSource = SourcePackage {srcpkgPackageId}, solverPkgStage}
20552055
compGraph
20562056
comps = do
20572057
-- Knot tying: the final elab includes the
@@ -2099,7 +2099,7 @@ elaborateInstallPlan
20992099

21002100
pkgInstalledId
21012101
| shouldBuildInplaceOnly pkg =
2102-
mkComponentId (prettyShow srcpkgPackageId ++ "-inplace")
2102+
mkComponentId (prettyShow srcpkgPackageId ++ "-" ++ prettyShow solverPkgStage)
21032103
| otherwise =
21042104
assert (isJust elabPkgSourceHash) $
21052105
hashedInstalledPackageId

cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ elabConfiguredName verbosity elab
567567
elabDistDirParams :: ElaboratedSharedConfig -> ElaboratedConfiguredPackage -> DistDirParams
568568
elabDistDirParams shared elab =
569569
DistDirParams
570-
{ distParamUnitId = installedUnitId elab
570+
{ distParamStage = elabStage elab
571+
, distParamUnitId = installedUnitId elab
571572
, distParamComponentId = elabComponentId elab
572573
, distParamPackageId = elabPkgSourceId elab
573574
, distParamComponentName = case elabPkgOrComp elab of

cabal-install/src/Distribution/Client/ScriptUtils.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@ scriptExeFileName scriptPath = "cabal-script-" ++ takeFileName scriptPath
438438
scriptDistDirParams :: FilePath -> ProjectBaseContext -> Compiler -> Platform -> DistDirParams
439439
scriptDistDirParams scriptPath ctx compiler platform =
440440
DistDirParams
441-
{ distParamUnitId = newSimpleUnitId cid
441+
{ distParamStage = Host
442+
, distParamUnitId = newSimpleUnitId cid
442443
, distParamPackageId = fakePackageId
443444
, distParamComponentId = cid
444445
, distParamComponentName = Just $ CExeName cn

0 commit comments

Comments
 (0)