@@ -483,7 +483,7 @@ configureCompiler
483
483
DistDirLayout
484
484
{ distProjectCacheFile
485
485
}
486
- ProjectConfig
486
+ projectConfig @ ProjectConfig
487
487
{ projectConfigShared =
488
488
ProjectConfigShared
489
489
{ projectConfigHcFlavor
@@ -533,15 +533,7 @@ configureCompiler
533
533
hcFlavor = flagToMaybe projectConfigHcFlavor
534
534
hcPath = flagToMaybe projectConfigHcPath
535
535
hcPkg = flagToMaybe projectConfigHcPkg
536
- progdb =
537
- userSpecifyPaths (Map. toList (getMapLast packageConfigProgramPaths))
538
- . modifyProgramSearchPath
539
- ( [ ProgramSearchPathDir dir
540
- | dir <- fromNubList packageConfigProgramPathExtra
541
- ]
542
- ++
543
- )
544
- $ defaultProgramDb
536
+ progdb = resolveProgramDb projectConfig
545
537
546
538
------------------------------------------------------------------------------
547
539
@@ -590,6 +582,9 @@ rebuildInstallPlan
590
582
progsearchpath <- liftIO $ getSystemSearchPath
591
583
let projectConfigMonitored = projectConfig{projectConfigBuildOnly = mempty }
592
584
585
+ let progdb = resolveProgramDb projectConfig
586
+ pkgConfigDB <- getPkgConfigDb verbosity distDirLayout progdb
587
+
593
588
-- The overall improved plan is cached
594
589
rerunIfChanged
595
590
verbosity
@@ -609,16 +604,16 @@ rebuildInstallPlan
609
604
)
610
605
$ do
611
606
compilerEtc <- phaseConfigureCompiler projectConfig
612
- _ <- phaseConfigurePrograms projectConfig compilerEtc
613
- (solverPlan, pkgConfigDB, totalIndexState, activeRepos) <-
607
+
608
+ (solverPlan, totalIndexState, activeRepos) <-
614
609
phaseRunSolver
615
610
projectConfig
616
611
compilerEtc
612
+ pkgConfigDB
617
613
localPackages
618
614
(fromMaybe mempty mbInstalledPackages)
619
- ( elaboratedPlan
620
- , elaboratedShared
621
- ) <-
615
+
616
+ (elaboratedPlan, elaboratedShared) <-
622
617
phaseElaboratePlan
623
618
projectConfig
624
619
compilerEtc
@@ -652,55 +647,37 @@ rebuildInstallPlan
652
647
phaseConfigureCompiler
653
648
:: ProjectConfig
654
649
-> Rebuild (Compiler , Platform , ProgramDb )
655
- phaseConfigureCompiler = configureCompiler verbosity distDirLayout
650
+ phaseConfigureCompiler projectConfig = do
651
+ (compiler, platform, progdb) <- configureCompiler verbosity distDirLayout projectConfig
656
652
657
- -- Configuring other programs.
658
- --
659
- -- Having configred the compiler, now we configure all the remaining
660
- -- programs. This is to check we can find them, and to monitor them for
661
- -- changes.
662
- --
663
- -- TODO: [required eventually] we don't actually do this yet.
664
- --
665
- -- We rely on the fact that the previous phase added the program config for
666
- -- all local packages, but that all the programs configured so far are the
667
- -- compiler program or related util programs.
668
- --
669
- phaseConfigurePrograms
670
- :: ProjectConfig
671
- -> (Compiler , Platform , ProgramDb )
672
- -> Rebuild ()
673
- phaseConfigurePrograms projectConfig (_, _, compilerprogdb) = do
674
653
-- Users are allowed to specify program locations independently for
675
654
-- each package (e.g. to use a particular version of a pre-processor
676
655
-- for some packages). However they cannot do this for the compiler
677
656
-- itself as that's just not going to work. So we check for this.
678
657
liftIO $
679
658
checkBadPerPackageCompilerPaths
680
- (configuredPrograms compilerprogdb )
659
+ (configuredPrograms progdb )
681
660
(getMapMappend (projectConfigSpecificPackage projectConfig))
682
661
683
- -- TODO: [required eventually] find/configure other programs that the
684
- -- user specifies.
685
-
686
- -- TODO: [required eventually] find/configure all build-tools
687
- -- but note that some of them may be built as part of the plan.
662
+ return (compiler, platform, progdb)
688
663
689
664
-- Run the solver to get the initial install plan.
690
665
-- This is expensive so we cache it independently.
691
666
--
692
667
phaseRunSolver
693
668
:: ProjectConfig
694
669
-> (Compiler , Platform , ProgramDb )
670
+ -> PkgConfigDb
695
671
-> [PackageSpecifier UnresolvedSourcePackage ]
696
672
-> InstalledPackageIndex
697
- -> Rebuild (SolverInstallPlan , PkgConfigDb , IndexUtils. TotalIndexState , IndexUtils. ActiveRepos )
673
+ -> Rebuild (SolverInstallPlan , IndexUtils. TotalIndexState , IndexUtils. ActiveRepos )
698
674
phaseRunSolver
699
675
projectConfig@ ProjectConfig
700
676
{ projectConfigShared
701
677
, projectConfigBuildOnly
702
678
}
703
679
(compiler, platform, progdb)
680
+ pkgConfigDB
704
681
localPackages
705
682
installedPackages =
706
683
rerunIfChanged
@@ -721,13 +698,13 @@ rebuildInstallPlan
721
698
progdb
722
699
platform
723
700
corePackageDbs
701
+
724
702
(sourcePkgDb, tis, ar) <-
725
703
getSourcePackages
726
704
verbosity
727
705
withRepoCtx
728
706
(solverSettingIndexState solverSettings)
729
707
(solverSettingActiveRepos solverSettings)
730
- pkgConfigDB <- getPkgConfigDb verbosity progdb
731
708
732
709
-- TODO: [code cleanup] it'd be better if the Compiler contained the
733
710
-- ConfiguredPrograms that it needs, rather than relying on the progdb
@@ -752,7 +729,7 @@ rebuildInstallPlan
752
729
Left msg -> do
753
730
reportPlanningFailure projectConfig compiler platform localPackages
754
731
dieWithException verbosity $ PhaseRunSolverErr msg
755
- Right plan -> return (plan, pkgConfigDB, tis, ar)
732
+ Right plan -> return (plan, tis, ar)
756
733
where
757
734
corePackageDbs :: [PackageDB ]
758
735
corePackageDbs =
@@ -1038,13 +1015,19 @@ getSourcePackages verbosity withRepoCtx idxState activeRepos = do
1038
1015
$ repos
1039
1016
return sourcePkgDbWithTIS
1040
1017
1041
- getPkgConfigDb :: Verbosity -> ProgramDb -> Rebuild PkgConfigDb
1042
- getPkgConfigDb verbosity progdb = do
1018
+ getPkgConfigDb :: Verbosity -> DistDirLayout -> ProgramDb -> Rebuild PkgConfigDb
1019
+ getPkgConfigDb verbosity distDirLayout progdb = do
1020
+ systemsearchpath <- liftIO $ getSystemSearchPath
1021
+ let progsearchpath = getProgramSearchPath progdb
1043
1022
dirs <- liftIO $ getPkgConfigDbDirs verbosity progdb
1044
- -- Just monitor the dirs so we'll notice new .pc files.
1045
- -- Alternatively we could monitor all the .pc files too.
1046
- traverse_ monitorDirectoryStatus dirs
1047
- liftIO $ readPkgConfigDb verbosity progdb
1023
+ rerunIfChanged verbosity fileMonitorPkgConfigDb (systemsearchpath, progsearchpath, dirs) $ do
1024
+ liftIO $ notice verbosity " Querying pkg-config database..."
1025
+ -- Just monitor the dirs so we'll notice new .pc files.
1026
+ -- Alternatively we could monitor all the .pc files too.
1027
+ traverse_ monitorDirectoryStatus dirs
1028
+ liftIO $ readPkgConfigDb verbosity progdb
1029
+ where
1030
+ fileMonitorPkgConfigDb = newFileMonitor $ distProjectCacheFile distDirLayout " pkg-config-db"
1048
1031
1049
1032
-- | Select the config values to monitor for changes package source hashes.
1050
1033
packageLocationsSignature
0 commit comments