Skip to content

Commit 264108d

Browse files
committed
Add GHC Unit ID store to cabal path output
The GHC "Project Unit ID" store path has been used in cabal-install since 3.12.1.0. Resolves: #10165
1 parent 8365cec commit 264108d

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Distribution.Client.Config
2525
, defaultStoreDir
2626
, getConfigFilePath
2727
)
28-
import Distribution.Client.DistDirLayout (CabalDirLayout (..), distProjectRootDirectory)
28+
import Distribution.Client.DistDirLayout (CabalDirLayout (..), StoreDirLayout (..), distProjectRootDirectory)
2929
import Distribution.Client.Errors
3030
import Distribution.Client.GlobalFlags
3131
import Distribution.Client.NixStyleOptions
@@ -244,10 +244,17 @@ pathAction flags@NixStyleFlags{extraFlags = pathFlags'} cliTargetStrings globalF
244244
if not $ fromFlagOrDefault False (pathCompiler pathFlags)
245245
then pure Nothing
246246
else do
247-
(compiler, _, progDb) <- runRebuild (distProjectRootDirectory . distDirLayout $ baseCtx) $ configureCompiler verbosity (distDirLayout baseCtx) (projectConfig baseCtx)
247+
(compiler, _, progDb) <-
248+
runRebuild (distProjectRootDirectory . distDirLayout $ baseCtx) $
249+
configureCompiler verbosity (distDirLayout baseCtx) (projectConfig baseCtx)
248250
compilerProg <- requireCompilerProg verbosity compiler
249251
(configuredCompilerProg, _) <- requireProgram verbosity compilerProg progDb
250-
pure $ Just $ mkCompilerInfo configuredCompilerProg compiler
252+
253+
let compilerInfo' =
254+
mkCompilerInfo configuredCompilerProg compiler $
255+
cabalStoreDirLayout (cabalDirLayout baseCtx)
256+
257+
pure $ Just compilerInfo'
251258

252259
paths <- for (fromFlagOrDefault [] $ pathDirectories pathFlags) $ \p -> do
253260
t <- getPathLocation verbosity baseCtx p
@@ -318,15 +325,17 @@ data PathCompilerInfo = PathCompilerInfo
318325
{ pathCompilerInfoFlavour :: CompilerFlavor
319326
, pathCompilerInfoId :: CompilerId
320327
, pathCompilerInfoPath :: FilePath
328+
, pathCompilerInfoProjectUnitId :: FilePath
321329
}
322330
deriving (Show, Eq, Ord)
323331

324-
mkCompilerInfo :: ConfiguredProgram -> Compiler -> PathCompilerInfo
325-
mkCompilerInfo compilerProgram compiler =
332+
mkCompilerInfo :: ConfiguredProgram -> Compiler -> StoreDirLayout -> PathCompilerInfo
333+
mkCompilerInfo compilerProgram compiler storeLayout =
326334
PathCompilerInfo
327335
{ pathCompilerInfoFlavour = compilerFlavor compiler
328336
, pathCompilerInfoId = compilerId compiler
329337
, pathCompilerInfoPath = programPath compilerProgram
338+
, pathCompilerInfoProjectUnitId = storeDirectory storeLayout compiler
330339
}
331340

332341
-- ----------------------------------------------------------------------------
@@ -372,6 +381,7 @@ compilerInfoToJson pci =
372381
[ "flavour" .= jdisplay (pathCompilerInfoFlavour pci)
373382
, "id" .= jdisplay (pathCompilerInfoId pci)
374383
, "path" .= Json.String (pathCompilerInfoPath pci)
384+
, "project-unit-id" .= Json.String (pathCompilerInfoProjectUnitId pci)
375385
]
376386
]
377387

@@ -401,4 +411,5 @@ compilerInfoToKeyValue pci =
401411
[ ("compiler-flavour", prettyShow $ pathCompilerInfoFlavour pci)
402412
, ("compiler-id", prettyShow $ pathCompilerInfoId pci)
403413
, ("compiler-path", pathCompilerInfoPath pci)
414+
, ("compiler-project-unit-id", pathCompilerInfoProjectUnitId pci)
404415
]

cabal-testsuite/PackageTests/Path/All/cabal.out

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# cabal path
2-
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"},"logs-dir":"<ROOT>/cabal.dist/home/.cabal/logs","installdir":"<ROOT>/cabal.dist/home/.cabal/bin"}
2+
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","project-unit-id":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"logs-dir":"<ROOT>/cabal.dist/home/.cabal/logs","installdir":"<ROOT>/cabal.dist/home/.cabal/bin"}
33
# cabal path
4-
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"},"store-dir":"<ROOT>/cabal.dist/home/.cabal/store","config-file":"<ROOT>/cabal.dist/home/.cabal/config"}
4+
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","project-unit-id":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"store-dir":"<ROOT>/cabal.dist/home/.cabal/store","config-file":"<ROOT>/cabal.dist/home/.cabal/config"}
55
# cabal path
6-
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"},"remote-repo-cache":"<ROOT>/cabal.dist/home/.cabal/packages"}
6+
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","project-unit-id":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"remote-repo-cache":"<ROOT>/cabal.dist/home/.cabal/packages"}
77
# cabal path
8-
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"},"cache-home":"<ROOT>/cabal.dist/home/.cabal","remote-repo-cache":"<ROOT>/cabal.dist/home/.cabal/packages","logs-dir":"<ROOT>/cabal.dist/home/.cabal/logs","store-dir":"<ROOT>/cabal.dist/home/.cabal/store","config-file":"<ROOT>/cabal.dist/home/.cabal/config","installdir":"<ROOT>/cabal.dist/home/.cabal/bin"}
8+
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","project-unit-id":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"cache-home":"<ROOT>/cabal.dist/home/.cabal","remote-repo-cache":"<ROOT>/cabal.dist/home/.cabal/packages","logs-dir":"<ROOT>/cabal.dist/home/.cabal/logs","store-dir":"<ROOT>/cabal.dist/home/.cabal/store","config-file":"<ROOT>/cabal.dist/home/.cabal/config","installdir":"<ROOT>/cabal.dist/home/.cabal/bin"}
99
# cabal path
1010
{"cabal-version":"<CABAL_INSTALL_VER>","cache-home":"<ROOT>/cabal.dist/home/.cabal"}
1111
# cabal path
@@ -22,23 +22,27 @@
2222
compiler-flavour: ghc
2323
compiler-id: ghc-<GHCVER>
2424
compiler-path: <GHCPATH>
25+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
2526
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
2627
installdir: <ROOT>/cabal.dist/home/.cabal/bin
2728
# cabal path
2829
compiler-flavour: ghc
2930
compiler-id: ghc-<GHCVER>
3031
compiler-path: <GHCPATH>
32+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
3133
store-dir: <ROOT>/cabal.dist/home/.cabal/store
3234
config-file: <ROOT>/cabal.dist/home/.cabal/config
3335
# cabal path
3436
compiler-flavour: ghc
3537
compiler-id: ghc-<GHCVER>
3638
compiler-path: <GHCPATH>
39+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
3740
remote-repo-cache: <ROOT>/cabal.dist/home/.cabal/packages
3841
# cabal path
3942
compiler-flavour: ghc
4043
compiler-id: ghc-<GHCVER>
4144
compiler-path: <GHCPATH>
45+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
4246
cache-home: <ROOT>/cabal.dist/home/.cabal
4347
remote-repo-cache: <ROOT>/cabal.dist/home/.cabal/packages
4448
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
@@ -61,23 +65,27 @@ installdir: <ROOT>/cabal.dist/home/.cabal/bin
6165
compiler-flavour: ghc
6266
compiler-id: ghc-<GHCVER>
6367
compiler-path: <GHCPATH>
68+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
6469
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
6570
installdir: <ROOT>/cabal.dist/home/.cabal/bin
6671
# cabal path
6772
compiler-flavour: ghc
6873
compiler-id: ghc-<GHCVER>
6974
compiler-path: <GHCPATH>
75+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
7076
store-dir: <ROOT>/cabal.dist/home/.cabal/store
7177
config-file: <ROOT>/cabal.dist/home/.cabal/config
7278
# cabal path
7379
compiler-flavour: ghc
7480
compiler-id: ghc-<GHCVER>
7581
compiler-path: <GHCPATH>
82+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
7683
remote-repo-cache: <ROOT>/cabal.dist/home/.cabal/packages
7784
# cabal path
7885
compiler-flavour: ghc
7986
compiler-id: ghc-<GHCVER>
8087
compiler-path: <GHCPATH>
88+
compiler-project-unit-id: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
8189
cache-home: <ROOT>/cabal.dist/home/.cabal
8290
remote-repo-cache: <ROOT>/cabal.dist/home/.cabal/packages
8391
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs

0 commit comments

Comments
 (0)