Skip to content

Commit 19bebc9

Browse files
committed
refactor(cabal-install): seprate build directories and drop -inplace
1 parent cdee761 commit 19bebc9

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import Distribution.Client.Config
3333
( defaultLogsDir
3434
, defaultStoreDir
3535
)
36+
import Distribution.Client.Toolchain (Stage)
3637
import Distribution.Compiler
3738
import Distribution.Package
3839
( ComponentId
@@ -48,15 +49,15 @@ import Distribution.Simple.Compiler
4849
)
4950
import Distribution.System
5051
import Distribution.Types.ComponentName
51-
import Distribution.Types.LibraryName
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,28 +195,10 @@ 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-
)
201+
</> prettyShow (distParamUnitId params)
219202

220203
distUnpackedSrcRootDirectory :: FilePath
221204
distUnpackedSrcRootDirectory = distDirectory </> "src"

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,21 +1948,21 @@ elaborateInstallPlan
19481948
elab0
19491949
{ elabPkgOrComp = ElabComponent elab_comp
19501950
}
1951+
1952+
-- This is where the component id is computed.
19511953
cid = case elabBuildStyle elab0 of
19521954
BuildInplaceOnly{} ->
19531955
mkComponentId $
1954-
prettyShow pkgid
1955-
++ "-inplace"
1956-
++ ( case Cabal.componentNameString cname of
1957-
Nothing -> ""
1958-
Just s -> "-" ++ prettyShow s
1959-
)
1956+
case Cabal.componentNameString cname of
1957+
Nothing -> prettyShow pkgid
1958+
Just n -> prettyShow pkgid ++ "-" ++ prettyShow n
19601959
BuildAndInstall ->
19611960
hashedInstalledPackageId
19621961
( packageHashInputs
19631962
elaboratedSharedConfig
19641963
elab1 -- knot tied
19651964
)
1965+
19661966
cc = cc0{cc_ann_id = fmap (const cid) (cc_ann_id cc0)}
19671967

19681968
infoProgress $ hang (text "configured component:") 4 (dispConfiguredComponent cc)
@@ -2181,7 +2181,7 @@ elaborateInstallPlan
21812181

21822182
pkgInstalledId
21832183
| shouldBuildInplaceOnly pkg =
2184-
mkComponentId (prettyShow srcpkgPackageId ++ "-inplace")
2184+
mkComponentId (prettyShow srcpkgPackageId)
21852185
| otherwise =
21862186
assert (isJust elabPkgSourceHash) $
21872187
hashedInstalledPackageId

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ elabConfiguredName verbosity elab
565565
elabDistDirParams :: ElaboratedSharedConfig -> ElaboratedConfiguredPackage -> DistDirParams
566566
elabDistDirParams shared elab =
567567
DistDirParams
568-
{ distParamUnitId = installedUnitId elab
568+
{ distParamStage = elabStage elab
569+
, distParamUnitId = installedUnitId elab
569570
, distParamComponentId = elabComponentId elab
570571
, distParamPackageId = elabPkgSourceId elab
571572
, 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
@@ -431,7 +431,8 @@ scriptExeFileName scriptPath = "cabal-script-" ++ takeFileName scriptPath
431431
scriptDistDirParams :: FilePath -> ProjectBaseContext -> Compiler -> Platform -> DistDirParams
432432
scriptDistDirParams scriptPath ctx compiler platform =
433433
DistDirParams
434-
{ distParamUnitId = newSimpleUnitId cid
434+
{ distParamStage = Host
435+
, distParamUnitId = newSimpleUnitId cid
435436
, distParamPackageId = fakePackageId
436437
, distParamComponentId = cid
437438
, distParamComponentName = Just $ CExeName cn

0 commit comments

Comments
 (0)