@@ -24,7 +24,8 @@ module Distribution.Client.ProjectPlanning.Types
2424 , elabOrderLibDependencies
2525 , elabExeDependencies
2626 , elabOrderExeDependencies
27- , elabSetupDependencies
27+ , elabSetupLibDependencies
28+ , elabSetupExeDependencies
2829 , elabPkgConfigDependencies
2930 , elabInplaceDependencyBuildCacheFiles
3031 , elabRequiresRegistration
@@ -585,25 +586,28 @@ elabDistDirParams shared elab =
585586-- use 'elabLibDependencies'. This method is the same as
586587-- 'nodeNeighbors'.
587588--
588- -- NB : this method DOES include setup deps.
589+ -- Note : this method DOES include setup deps.
589590elabOrderDependencies :: ElaboratedConfiguredPackage -> [WithStage UnitId ]
590591elabOrderDependencies elab =
591592 elabOrderLibDependencies elab ++ elabOrderExeDependencies elab
592593
593- -- | Like 'elabOrderDependencies', but only returns dependencies on
594- -- libraries.
594+ -- | The result includes setup dependencies
595595elabOrderLibDependencies :: ElaboratedConfiguredPackage -> [WithStage UnitId ]
596596elabOrderLibDependencies elab =
597- case elabPkgOrComp elab of
598- ElabPackage pkg ->
599- ordNub
600- [ WithStage (pkgStage pkg) (newSimpleUnitId (confInstId cid))
601- | cid <- CD. flatDeps (map fst <$> pkgLibDependencies pkg)
602- ]
603- ElabComponent comp ->
604- [ WithStage (elabStage elab) c
605- | c <- compOrderLibDependencies comp
606- ]
597+ ordNub $
598+ [ fmap (newSimpleUnitId . confInstId) dep
599+ | (dep, _promised) <- elabLibDependencies elab ++ elabSetupLibDependencies elab
600+ ]
601+
602+ -- | The result includes setup dependencies
603+ elabOrderExeDependencies :: ElaboratedConfiguredPackage -> [WithStage UnitId ]
604+ elabOrderExeDependencies elab =
605+ -- Compare with elabOrderLibDependencies. The setup dependencies here do not need
606+ -- any special attention because the stage is already included in pkgExeDependencies.
607+ map (fmap (newSimpleUnitId . confInstId)) $
608+ case elabPkgOrComp elab of
609+ ElabPackage pkg -> CD. flatDeps (pkgExeDependencies pkg)
610+ ElabComponent comp -> compExeDependencies comp
607611
608612-- | The library dependencies (i.e., the libraries we depend on, NOT
609613-- the dependencies of the library), NOT including setup dependencies.
@@ -621,20 +625,40 @@ elabLibDependencies elab =
621625 | (c, promised) <- compLibDependencies comp
622626 ]
623627
624- -- | Like 'elabOrderDependencies', but only returns dependencies on
625- -- executables. (This coincides with 'elabExeDependencies'.)
626- elabOrderExeDependencies :: ElaboratedConfiguredPackage -> [WithStage UnitId ]
627- elabOrderExeDependencies =
628- fmap (fmap newSimpleUnitId) . elabExeDependencies
628+ -- | The setup dependencies (the library dependencies of the setup executable;
629+ -- note that it is not legal for setup scripts to have executable
630+ -- dependencies at the moment.)
631+ elabSetupLibDependencies :: ElaboratedConfiguredPackage -> [(WithStage ConfiguredId , Bool )]
632+ elabSetupLibDependencies elab =
633+ case elabPkgOrComp elab of
634+ ElabPackage pkg ->
635+ ordNub
636+ [ (WithStage (prevStage (pkgStage pkg)) cid, promised)
637+ | (cid, promised) <- CD. setupDeps (pkgLibDependencies pkg)
638+ ]
639+ -- TODO: Custom setups not supported for components yet. When
640+ -- they are, need to do this differently
641+ ElabComponent _ -> []
642+
643+ -- | This would not be allowed actually. See comment on elabSetupLibDependencies.
644+ elabSetupExeDependencies :: ElaboratedConfiguredPackage -> [WithStage ComponentId ]
645+ elabSetupExeDependencies elab =
646+ map (fmap confInstId) $
647+ case elabPkgOrComp elab of
648+ ElabPackage pkg -> CD. setupDeps (pkgExeDependencies pkg)
649+ -- TODO: Custom setups not supported for components yet. When
650+ -- they are, need to do this differently
651+ ElabComponent _ -> []
629652
630653-- | The executable dependencies (i.e., the executables we depend on);
631654-- these are the executables we must add to the PATH before we invoke
632655-- the setup script.
633656elabExeDependencies :: ElaboratedConfiguredPackage -> [WithStage ComponentId ]
634- elabExeDependencies elab = fmap (fmap confInstId) $
635- case elabPkgOrComp elab of
636- ElabPackage pkg -> CD. nonSetupDeps (pkgExeDependencies pkg)
637- ElabComponent comp -> compExeDependencies comp
657+ elabExeDependencies elab =
658+ map (fmap confInstId) $
659+ case elabPkgOrComp elab of
660+ ElabPackage pkg -> CD. nonSetupDeps (pkgExeDependencies pkg)
661+ ElabComponent comp -> compExeDependencies comp
638662
639663-- | This returns the paths of all the executables we depend on; we
640664-- must add these paths to PATH before invoking the setup script.
@@ -646,22 +670,6 @@ elabExeDependencyPaths elab =
646670 ElabPackage pkg -> map snd $ CD. nonSetupDeps (pkgExeDependencyPaths pkg)
647671 ElabComponent comp -> map snd (compExeDependencyPaths comp)
648672
649- -- | The setup dependencies (the library dependencies of the setup executable;
650- -- note that it is not legal for setup scripts to have executable
651- -- dependencies at the moment.)
652- elabSetupDependencies :: ElaboratedConfiguredPackage -> [(WithStage ConfiguredId , Bool )]
653- elabSetupDependencies elab =
654- case elabPkgOrComp elab of
655- -- FIXME: this should be wrong. Setup and its dependencies can be on a different stage. Where did that information go?
656- ElabPackage pkg ->
657- ordNub
658- [ (WithStage (pkgStage pkg) cid, promised)
659- | (cid, promised) <- CD. setupDeps (pkgLibDependencies pkg)
660- ]
661- -- TODO: Custom setups not supported for components yet. When
662- -- they are, need to do this differently
663- ElabComponent _ -> []
664-
665673elabPkgConfigDependencies :: ElaboratedConfiguredPackage -> [(PkgconfigName , Maybe PkgconfigVersion )]
666674elabPkgConfigDependencies ElaboratedConfiguredPackage {elabPkgOrComp = ElabPackage pkg} =
667675 pkgPkgConfigDependencies pkg
0 commit comments