Skip to content

Commit d02be62

Browse files
committed
Add note about reading the project configuration
1 parent dc21335 commit d02be62

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

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

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,37 @@ sanityCheckElaboratedPackage
331331
`optStanzaSetIsSubset` pkgStanzasEnabled
332332
)
333333

334-
------------------------------------------------------------------------------
335-
336-
-- * Deciding what to do: making an 'ElaboratedInstallPlan'
337-
338-
------------------------------------------------------------------------------
334+
-- Note [reading project configuration]
335+
--
336+
-- The project configuration is assembled into a ProjectConfig as follows:
337+
--
338+
-- CLI arguments are converted using commandLineFlagsToProjectConfig in the
339+
-- v2 command entrypoints and passed to establishProjectBaseContext which
340+
-- then calls rebuildProjectConfig.
341+
--
342+
-- rebuildProjectConfig then calls readProjectConfig to read the project
343+
-- files. Because of conditionals, this output is in the form of a
344+
-- ProjectConfigSkeleton and will be resolved by rebuildProjectConfig using
345+
-- instantiateProjectConfigSkeletonFetchingCompiler.
346+
--
347+
-- readProjectConfig also loads the global configuration, which is read with
348+
-- loadConfig and convertd to a ProjectConfig with convertLegacyGlobalConfig.
349+
--
350+
-- *Important*
351+
--
352+
-- You can notice how some project config options are needed to read the
353+
-- project config! This is evident by the fact that rebuildProjectConfig
354+
-- takes HttpTransport and DistDirLayout as parameters. Two arguments are
355+
-- infact determined from the CLI alone (in establishProjectBaseContext).
356+
-- Consequently, project files (including global configuration) cannot
357+
-- affect those parameters.
358+
--
359+
-- Furthermore, the project configuration can specify a compiler to use,
360+
-- which we need to resolve the conditionals in the project configuration!
361+
-- To solve this, we configure the compiler from what is obtained by applying
362+
-- the CLI configuration over the the configuration obtained by "flattening"
363+
-- ProjectConfigSkeleton. This means collapsing all conditionals by taking
364+
-- both branches.
339365

340366
-- | Return the up-to-date project config and information about the local
341367
-- packages within the project.
@@ -513,6 +539,11 @@ configureCompiler
513539
)
514540
$ defaultProgramDb
515541

542+
543+
------------------------------------------------------------------------------
544+
-- * Deciding what to do: making an 'ElaboratedInstallPlan'
545+
------------------------------------------------------------------------------
546+
516547
-- | Return an up-to-date elaborated install plan.
517548
--
518549
-- Two variants of the install plan are returned: with and without packages

0 commit comments

Comments
 (0)