@@ -461,11 +461,7 @@ configureCompiler
461461 , projectConfigHcPath
462462 , projectConfigHcPkg
463463 }
464- , projectConfigLocalPackages =
465- PackageConfig
466- { packageConfigProgramPaths
467- , packageConfigProgramPathExtra
468- }
464+ , projectConfigLocalPackages
469465 } = do
470466 let fileMonitorCompiler = newFileMonitor $ distProjectCacheFile " compiler"
471467
@@ -477,35 +473,26 @@ configureCompiler
477473 , hcPath
478474 , hcPkg
479475 , progsearchpath
480- , packageConfigProgramPaths
481- , packageConfigProgramPathExtra
476+ , projectConfigLocalPackages
482477 )
483478 $ do
484479 liftIO $ info verbosity " Compiler settings changed, reconfiguring..."
485- let extraPath = fromNubList packageConfigProgramPathExtra
486- progdb <- liftIO $ prependProgramSearchPath verbosity extraPath [] defaultProgramDb
487- let progdb' = userSpecifyPaths (Map. toList (getMapLast packageConfigProgramPaths)) progdb
488- (comp, plat, progdb'') <-
489- liftIO $
490- Cabal. configCompilerEx
491- hcFlavor
492- hcPath
493- hcPkg
494- progdb'
495- verbosity
480+ progdb <- liftIO $ resolveProgramDb verbosity projectConfigLocalPackages
481+ (comp, plat, progdb') <-
482+ liftIO $ Cabal. configCompilerEx hcFlavor hcPath hcPkg progdb verbosity
496483
497484 -- Note that we added the user-supplied program locations and args
498485 -- for /all/ programs, not just those for the compiler prog and
499486 -- compiler-related utils. In principle we don't know which programs
500487 -- the compiler will configure (and it does vary between compilers).
501488 -- We do know however that the compiler will only configure the
502489 -- programs it cares about, and those are the ones we monitor here.
503- monitorFiles (programsMonitorFiles progdb'' )
490+ monitorFiles (programsMonitorFiles progdb')
504491
505492 -- Configure the unconfigured programs in the program database,
506493 -- as we can't serialise unconfigured programs.
507494 -- See also #2241 and #9840.
508- finalProgDb <- liftIO $ configureAllKnownPrograms verbosity progdb''
495+ finalProgDb <- liftIO $ configureAllKnownPrograms verbosity progdb'
509496
510497 return (comp, plat, finalProgDb)
511498 where
@@ -557,9 +544,14 @@ rebuildInstallPlan
557544 { cabalStoreDirLayout
558545 } = \ projectConfig localPackages mbInstalledPackages ->
559546 runRebuild distProjectRootDirectory $ do
560- progsearchpath <- liftIO $ getSystemSearchPath
547+ progsearchpath <- liftIO getSystemSearchPath
561548 let projectConfigMonitored = projectConfig{projectConfigBuildOnly = mempty }
562549
550+ progdb <- liftIO $ resolveProgramDb verbosity (projectConfigLocalPackages projectConfig)
551+ monitorFiles (programsMonitorFiles progdb)
552+
553+ pkgConfigDB <- getPkgConfigDb verbosity distDirLayout progdb
554+
563555 -- The overall improved plan is cached
564556 rerunIfChanged
565557 verbosity
@@ -580,15 +572,15 @@ rebuildInstallPlan
580572 $ do
581573 compilerEtc <- phaseConfigureCompiler projectConfig
582574 _ <- phaseConfigurePrograms projectConfig compilerEtc
583- (solverPlan, pkgConfigDB, totalIndexState, activeRepos) <-
575+ (solverPlan, totalIndexState, activeRepos) <-
584576 phaseRunSolver
585577 projectConfig
586578 compilerEtc
579+ pkgConfigDB
587580 localPackages
588581 (fromMaybe mempty mbInstalledPackages)
589- ( elaboratedPlan
590- , elaboratedShared
591- ) <-
582+
583+ (elaboratedPlan, elaboratedShared) <-
592584 phaseElaboratePlan
593585 projectConfig
594586 compilerEtc
@@ -622,7 +614,8 @@ rebuildInstallPlan
622614 phaseConfigureCompiler
623615 :: ProjectConfig
624616 -> Rebuild (Compiler , Platform , ProgramDb )
625- phaseConfigureCompiler = configureCompiler verbosity distDirLayout
617+ phaseConfigureCompiler projectConfig =
618+ configureCompiler verbosity distDirLayout projectConfig
626619
627620 -- Configuring other programs.
628621 --
@@ -662,15 +655,17 @@ rebuildInstallPlan
662655 phaseRunSolver
663656 :: ProjectConfig
664657 -> (Compiler , Platform , ProgramDb )
658+ -> PkgConfigDb
665659 -> [PackageSpecifier UnresolvedSourcePackage ]
666660 -> InstalledPackageIndex
667- -> Rebuild (SolverInstallPlan , PkgConfigDb , IndexUtils. TotalIndexState , IndexUtils. ActiveRepos )
661+ -> Rebuild (SolverInstallPlan , IndexUtils. TotalIndexState , IndexUtils. ActiveRepos )
668662 phaseRunSolver
669663 projectConfig@ ProjectConfig
670664 { projectConfigShared
671665 , projectConfigBuildOnly
672666 }
673667 (compiler, platform, progdb)
668+ pkgConfigDB
674669 localPackages
675670 installedPackages =
676671 rerunIfChanged
@@ -697,7 +692,6 @@ rebuildInstallPlan
697692 withRepoCtx
698693 (solverSettingIndexState solverSettings)
699694 (solverSettingActiveRepos solverSettings)
700- pkgConfigDB <- getPkgConfigDb verbosity progdb
701695
702696 -- TODO: [code cleanup] it'd be better if the Compiler contained the
703697 -- ConfiguredPrograms that it needs, rather than relying on the progdb
@@ -722,7 +716,7 @@ rebuildInstallPlan
722716 Left msg -> do
723717 reportPlanningFailure projectConfig compiler platform localPackages
724718 dieWithException verbosity $ PhaseRunSolverErr msg
725- Right plan -> return (plan, pkgConfigDB, tis, ar)
719+ Right plan -> return (plan, tis, ar)
726720 where
727721 corePackageDbs :: [PackageDB ]
728722 corePackageDbs =
@@ -1010,13 +1004,23 @@ getSourcePackages verbosity withRepoCtx idxState activeRepos = do
10101004 $ repos
10111005 return sourcePkgDbWithTIS
10121006
1013- getPkgConfigDb :: Verbosity -> ProgramDb -> Rebuild PkgConfigDb
1014- getPkgConfigDb verbosity progdb = do
1015- dirs <- liftIO $ getPkgConfigDbDirs verbosity progdb
1016- -- Just monitor the dirs so we'll notice new .pc files.
1017- -- Alternatively we could monitor all the .pc files too.
1018- traverse_ monitorDirectoryStatus dirs
1019- liftIO $ readPkgConfigDb verbosity progdb
1007+ getPkgConfigDb :: Verbosity -> DistDirLayout -> ProgramDb -> Rebuild PkgConfigDb
1008+ getPkgConfigDb verbosity distDirLayout progdb = do
1009+ mpkgConfig <- liftIO $ needProgram verbosity pkgConfigProgram progdb
1010+ case mpkgConfig of
1011+ Nothing -> do
1012+ liftIO $ info verbosity " Cannot find pkg-config program. Cabal will continue without solving for pkg-config constraints."
1013+ return NoPkgConfigDb
1014+ Just (pkgConfig, progdb') -> do
1015+ dirs <- liftIO $ getPkgConfigDbDirs verbosity progdb'
1016+ rerunIfChanged verbosity fileMonitorPkgConfigDb (pkgConfig, dirs) $ do
1017+ -- By monitoring the dirs, we'll notice new .pc files. We do not monitor changes in the .pc files themselves.
1018+ traverse_ monitorDirectoryStatus dirs
1019+ liftIO $ do
1020+ info verbosity " Querying pkg-config database..."
1021+ readPkgConfigDb verbosity progdb'
1022+ where
1023+ fileMonitorPkgConfigDb = newFileMonitor $ distProjectCacheFile distDirLayout " pkg-config-db"
10201024
10211025-- | Select the config values to monitor for changes package source hashes.
10221026packageLocationsSignature
0 commit comments