Skip to content

Commit 7d56c9b

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 7d56c9b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

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

Lines changed: 17 additions & 10 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 (..), distProjectRootDirectory, StoreDirLayout (..))
2929
import Distribution.Client.Errors
3030
import Distribution.Client.GlobalFlags
3131
import Distribution.Client.NixStyleOptions
@@ -208,6 +208,7 @@ data ConfigPath
208208
| ConfigPathStoreDir
209209
| ConfigPathConfigFile
210210
| ConfigPathInstallDir
211+
| ConfigPathProjectUnitId
211212
deriving (Eq, Ord, Show, Enum, Bounded)
212213

213214
-- | The configuration name for this path.
@@ -218,6 +219,7 @@ pathName ConfigPathLogsDir = "logs-dir"
218219
pathName ConfigPathStoreDir = "store-dir"
219220
pathName ConfigPathConfigFile = "config-file"
220221
pathName ConfigPathInstallDir = "installdir"
222+
pathName ConfigPathProjectUnitId = "project-unit-id"
221223

222224
-------------------------------------------------------------------------------
223225
-- Action
@@ -240,17 +242,20 @@ pathAction flags@NixStyleFlags{extraFlags = pathFlags'} cliTargetStrings globalF
240242
when (buildSettingDryRun (buildSettings baseCtx)) $
241243
dieWithException verbosity CmdPathCommandDoesn'tSupportDryRun
242244

245+
(compiler, _, progDb) <-
246+
runRebuild (distProjectRootDirectory . distDirLayout $ baseCtx) $
247+
configureCompiler verbosity (distDirLayout baseCtx) (projectConfig baseCtx)
248+
243249
compilerPathOutputs <-
244250
if not $ fromFlagOrDefault False (pathCompiler pathFlags)
245251
then pure Nothing
246252
else do
247-
(compiler, _, progDb) <- runRebuild (distProjectRootDirectory . distDirLayout $ baseCtx) $ configureCompiler verbosity (distDirLayout baseCtx) (projectConfig baseCtx)
248253
compilerProg <- requireCompilerProg verbosity compiler
249254
(configuredCompilerProg, _) <- requireProgram verbosity compilerProg progDb
250255
pure $ Just $ mkCompilerInfo configuredCompilerProg compiler
251256

252257
paths <- for (fromFlagOrDefault [] $ pathDirectories pathFlags) $ \p -> do
253-
t <- getPathLocation verbosity baseCtx p
258+
t <- getPathLocation verbosity baseCtx compiler p
254259
pure (pathName p, t)
255260

256261
let pathOutputs =
@@ -272,23 +277,25 @@ pathAction flags@NixStyleFlags{extraFlags = pathFlags'} cliTargetStrings globalF
272277
-- | Find the FilePath location for common configuration paths.
273278
--
274279
-- TODO: this should come from a common source of truth to avoid code path divergence
275-
getPathLocation :: Verbosity -> ProjectBaseContext -> ConfigPath -> IO FilePath
276-
getPathLocation _ _ ConfigPathCacheHome =
280+
getPathLocation :: Verbosity -> ProjectBaseContext -> Compiler -> ConfigPath -> IO FilePath
281+
getPathLocation _ _ _ ConfigPathCacheHome =
277282
defaultCacheHome
278-
getPathLocation _ baseCtx ConfigPathRemoteRepoCache =
283+
getPathLocation _ baseCtx _ ConfigPathRemoteRepoCache =
279284
pure $ buildSettingCacheDir (buildSettings baseCtx)
280-
getPathLocation _ baseCtx ConfigPathLogsDir =
285+
getPathLocation _ baseCtx _ ConfigPathLogsDir =
281286
pure $ cabalLogsDirectory (cabalDirLayout baseCtx)
282-
getPathLocation _ baseCtx ConfigPathStoreDir =
287+
getPathLocation _ baseCtx _ ConfigPathStoreDir =
283288
fromFlagOrDefault
284289
defaultStoreDir
285290
(pure <$> projectConfigStoreDir (projectConfigShared (projectConfig baseCtx)))
286-
getPathLocation verbosity baseCtx ConfigPathConfigFile =
291+
getPathLocation verbosity baseCtx _ ConfigPathConfigFile =
287292
getConfigFilePath verbosity (projectConfigConfigFile (projectConfigShared (projectConfig baseCtx)))
288-
getPathLocation _ baseCtx ConfigPathInstallDir =
293+
getPathLocation _ baseCtx _ ConfigPathInstallDir =
289294
fromFlagOrDefault
290295
defaultInstallPath
291296
(pure <$> cinstInstalldir (projectConfigClientInstallFlags $ projectConfigBuildOnly (projectConfig baseCtx)))
297+
getPathLocation _ baseCtx compiler ConfigPathProjectUnitId =
298+
pure $ storeDirectory (cabalStoreDirLayout (cabalDirLayout baseCtx)) compiler
292299

293300
-- ----------------------------------------------------------------------------
294301
-- Helpers for determining compiler information

0 commit comments

Comments
 (0)