Skip to content
Open
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
21 changes: 16 additions & 5 deletions cabal-install/src/Distribution/Client/CmdPath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Distribution.Client.Config
, defaultStoreDir
, getConfigFilePath
)
import Distribution.Client.DistDirLayout (CabalDirLayout (..), distProjectRootDirectory)
import Distribution.Client.DistDirLayout (CabalDirLayout (..), StoreDirLayout (..), distProjectRootDirectory)
import Distribution.Client.Errors
import Distribution.Client.GlobalFlags
import Distribution.Client.NixStyleOptions
Expand Down Expand Up @@ -244,10 +244,17 @@ pathAction flags@NixStyleFlags{extraFlags = pathFlags'} cliTargetStrings globalF
if not $ fromFlagOrDefault False (pathCompiler pathFlags)
then pure Nothing
else do
(compiler, _, progDb) <- runRebuild (distProjectRootDirectory . distDirLayout $ baseCtx) $ configureCompiler verbosity (distDirLayout baseCtx) (projectConfig baseCtx)
(compiler, _, progDb) <-
runRebuild (distProjectRootDirectory . distDirLayout $ baseCtx) $
configureCompiler verbosity (distDirLayout baseCtx) (projectConfig baseCtx)
compilerProg <- requireCompilerProg verbosity compiler
(configuredCompilerProg, _) <- requireProgram verbosity compilerProg progDb
pure $ Just $ mkCompilerInfo configuredCompilerProg compiler

let compilerInfo' =
mkCompilerInfo configuredCompilerProg compiler $
cabalStoreDirLayout (cabalDirLayout baseCtx)

pure $ Just compilerInfo'

paths <- for (fromFlagOrDefault [] $ pathDirectories pathFlags) $ \p -> do
t <- getPathLocation verbosity baseCtx p
Expand Down Expand Up @@ -318,15 +325,17 @@ data PathCompilerInfo = PathCompilerInfo
{ pathCompilerInfoFlavour :: CompilerFlavor
, pathCompilerInfoId :: CompilerId
, pathCompilerInfoPath :: FilePath
, pathCompilerInfoStorePath :: FilePath
}
deriving (Show, Eq, Ord)

mkCompilerInfo :: ConfiguredProgram -> Compiler -> PathCompilerInfo
mkCompilerInfo compilerProgram compiler =
mkCompilerInfo :: ConfiguredProgram -> Compiler -> StoreDirLayout -> PathCompilerInfo
mkCompilerInfo compilerProgram compiler storeLayout =
PathCompilerInfo
{ pathCompilerInfoFlavour = compilerFlavor compiler
, pathCompilerInfoId = compilerId compiler
, pathCompilerInfoPath = programPath compilerProgram
, pathCompilerInfoStorePath = storeDirectory storeLayout compiler
}

-- ----------------------------------------------------------------------------
Expand Down Expand Up @@ -372,6 +381,7 @@ compilerInfoToJson pci =
[ "flavour" .= jdisplay (pathCompilerInfoFlavour pci)
, "id" .= jdisplay (pathCompilerInfoId pci)
, "path" .= Json.String (pathCompilerInfoPath pci)
, "store-path" .= Json.String (pathCompilerInfoStorePath pci)
]
]

Expand Down Expand Up @@ -401,4 +411,5 @@ compilerInfoToKeyValue pci =
[ ("compiler-flavour", prettyShow $ pathCompilerInfoFlavour pci)
, ("compiler-id", prettyShow $ pathCompilerInfoId pci)
, ("compiler-path", pathCompilerInfoPath pci)
, ("compiler-store-path", pathCompilerInfoStorePath pci)
]
16 changes: 12 additions & 4 deletions cabal-testsuite/PackageTests/Path/All/cabal.out
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# cabal path
{"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"}
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","store-path":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"logs-dir":"<ROOT>/cabal.dist/home/.cabal/logs","installdir":"<ROOT>/cabal.dist/home/.cabal/bin"}
# cabal path
{"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"}
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","store-path":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"store-dir":"<ROOT>/cabal.dist/home/.cabal/store","config-file":"<ROOT>/cabal.dist/home/.cabal/config"}
# cabal path
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"},"remote-repo-cache":"<ROOT>/cabal.dist/home/.cabal/packages"}
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","store-path":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"},"remote-repo-cache":"<ROOT>/cabal.dist/home/.cabal/packages"}
# cabal path
{"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"}
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","store-path":"<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"}
# cabal path
{"cabal-version":"<CABAL_INSTALL_VER>","cache-home":"<ROOT>/cabal.dist/home/.cabal"}
# cabal path
Expand All @@ -22,23 +22,27 @@
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
installdir: <ROOT>/cabal.dist/home/.cabal/bin
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
store-dir: <ROOT>/cabal.dist/home/.cabal/store
config-file: <ROOT>/cabal.dist/home/.cabal/config
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
remote-repo-cache: <ROOT>/cabal.dist/home/.cabal/packages
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <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
Expand All @@ -61,23 +65,27 @@ installdir: <ROOT>/cabal.dist/home/.cabal/bin
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
installdir: <ROOT>/cabal.dist/home/.cabal/bin
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
store-dir: <ROOT>/cabal.dist/home/.cabal/store
config-file: <ROOT>/cabal.dist/home/.cabal/config
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
remote-repo-cache: <ROOT>/cabal.dist/home/.cabal/packages
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <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
Expand Down
4 changes: 3 additions & 1 deletion cabal-testsuite/PackageTests/Path/Compiler/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
# cabal path
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"}}
{"cabal-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>","store-path":"<ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>"}}
# cabal path
compiler-flavour: ghc
compiler-id: ghc-<GHCVER>
compiler-path: <GHCPATH>
compiler-store-path: <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>
11 changes: 11 additions & 0 deletions changelog.d/pr-11266
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: "Add GHC Project Unit ID store to `cabal path` output"
packages: cabal-install
prs: #11266
issues: #10165
description: {

This addds the GHC Project Unit ID store path to the cabal path output as
"project-unit-id". The GHC Project Unit ID store path has been used in cabal-install
since 3.12.1.0.

}
Loading