@@ -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,24 +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 [ WithStage (pkgStage pkg) (newSimpleUnitId (confInstId cid))
600- | cid <- CD. flatDeps (map fst <$> pkgLibDependencies pkg)
601- ]
602- ElabComponent comp ->
603- [ WithStage (elabStage elab) c
604- | c <- compOrderLibDependencies comp
605- ]
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
606611
607612-- | The library dependencies (i.e., the libraries we depend on, NOT
608613-- the dependencies of the library), NOT including setup dependencies.
@@ -611,28 +616,47 @@ elabLibDependencies :: ElaboratedConfiguredPackage -> [(WithStage ConfiguredId,
611616elabLibDependencies elab =
612617 case elabPkgOrComp elab of
613618 ElabPackage pkg ->
614- ordNub [ (WithStage (pkgStage pkg) cid, promised)
615- | (cid, promised) <- CD. nonSetupDeps (pkgLibDependencies pkg)
616- ]
619+ ordNub [ (WithStage (pkgStage pkg) cid, promised)
620+ | (cid, promised) <- CD. nonSetupDeps (pkgLibDependencies pkg)
621+ ]
617622 ElabComponent comp ->
618623 [ (WithStage (elabStage elab) c, promised)
619624 | (c, promised) <- compLibDependencies comp
620625 ]
621-
622- -- | Like 'elabOrderDependencies', but only returns dependencies on
623- -- executables. (This coincides with 'elabExeDependencies'.)
624- elabOrderExeDependencies :: ElaboratedConfiguredPackage -> [WithStage UnitId ]
625- elabOrderExeDependencies =
626- fmap (fmap newSimpleUnitId) . elabExeDependencies
626+
627+ -- | The setup dependencies (the library dependencies of the setup executable;
628+ -- note that it is not legal for setup scripts to have executable
629+ -- dependencies at the moment.)
630+ elabSetupLibDependencies :: ElaboratedConfiguredPackage -> [(WithStage ConfiguredId , Bool )]
631+ elabSetupLibDependencies elab =
632+ case elabPkgOrComp elab of
633+ ElabPackage pkg ->
634+ ordNub [ (WithStage (prevStage (pkgStage pkg)) cid, promised)
635+ | (cid, promised) <- CD. setupDeps (pkgLibDependencies pkg)
636+ ]
637+ -- TODO: Custom setups not supported for components yet. When
638+ -- they are, need to do this differently
639+ ElabComponent _ -> []
640+
641+ -- | This would not be allowed actually. See comment on elabSetupLibDependencies.
642+ elabSetupExeDependencies :: ElaboratedConfiguredPackage -> [WithStage ComponentId ]
643+ elabSetupExeDependencies elab =
644+ map (fmap confInstId) $
645+ case elabPkgOrComp elab of
646+ ElabPackage pkg -> CD. setupDeps (pkgExeDependencies pkg)
647+ -- TODO: Custom setups not supported for components yet. When
648+ -- they are, need to do this differently
649+ ElabComponent _ -> []
627650
628651-- | The executable dependencies (i.e., the executables we depend on);
629652-- these are the executables we must add to the PATH before we invoke
630653-- the setup script.
631654elabExeDependencies :: ElaboratedConfiguredPackage -> [WithStage ComponentId ]
632- elabExeDependencies elab = fmap (fmap confInstId) $
633- case elabPkgOrComp elab of
634- ElabPackage pkg -> CD. nonSetupDeps (pkgExeDependencies pkg)
635- ElabComponent comp -> compExeDependencies comp
655+ elabExeDependencies elab =
656+ map (fmap confInstId) $
657+ case elabPkgOrComp elab of
658+ ElabPackage pkg -> CD. nonSetupDeps (pkgExeDependencies pkg)
659+ ElabComponent comp -> compExeDependencies comp
636660
637661-- | This returns the paths of all the executables we depend on; we
638662-- must add these paths to PATH before invoking the setup script.
@@ -644,23 +668,6 @@ elabExeDependencyPaths elab =
644668 ElabPackage pkg -> map snd $ CD. nonSetupDeps (pkgExeDependencyPaths pkg)
645669 ElabComponent comp -> map snd (compExeDependencyPaths comp)
646670
647- -- | The setup dependencies (the library dependencies of the setup executable;
648- -- note that it is not legal for setup scripts to have executable
649- -- dependencies at the moment.)
650- elabSetupDependencies :: ElaboratedConfiguredPackage -> [(WithStage ConfiguredId , Bool )]
651- elabSetupDependencies elab =
652- case elabPkgOrComp elab of
653- -- FIXME: this should be wrong. Setup and its dependencies can be on a different stage. Where did that information go?
654- ElabPackage pkg ->
655- ordNub
656- [ (WithStage (pkgStage pkg) cid, promised)
657- | (cid, promised) <- CD. setupDeps (pkgLibDependencies pkg)
658- ]
659-
660- -- TODO: Custom setups not supported for components yet. When
661- -- they are, need to do this differently
662- ElabComponent _ -> []
663-
664671elabPkgConfigDependencies :: ElaboratedConfiguredPackage -> [(PkgconfigName , Maybe PkgconfigVersion )]
665672elabPkgConfigDependencies ElaboratedConfiguredPackage {elabPkgOrComp = ElabPackage pkg} =
666673 pkgPkgConfigDependencies pkg
0 commit comments