Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target package names #4889

Merged
merged 18 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cabal-install/Distribution/Client/CmdBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ benchAction (applyFlagDefaults -> (configFlags, configExFlags, installFlags, had
-- For the @bench@ command we select all buildable benchmarks,
-- or fail if there are no benchmarks or no buildable benchmarks.
--
selectPackageTargets :: TargetSelector PackageId
selectPackageTargets :: TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets targetSelector targets

Expand Down Expand Up @@ -181,13 +181,13 @@ data TargetProblem =
TargetProblemCommon TargetProblemCommon

-- | The 'TargetSelector' matches benchmarks but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector

-- | The 'TargetSelector' matches targets but no benchmarks
| TargetProblemNoBenchmarks (TargetSelector PackageId)
| TargetProblemNoBenchmarks TargetSelector

-- | The 'TargetSelector' refers to a component that is not a benchmark
| TargetProblemComponentNotBenchmark PackageId ComponentName
Expand Down
6 changes: 3 additions & 3 deletions cabal-install/Distribution/Client/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ buildAction (applyFlagDefaults -> (configFlags, configExFlags, installFlags, had
-- For the @build@ command select all components except non-buildable and disabled
-- tests\/benchmarks, fail if there are no such components
--
selectPackageTargets :: TargetSelector PackageId
selectPackageTargets :: TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets targetSelector targets

Expand Down Expand Up @@ -173,10 +173,10 @@ data TargetProblem =
TargetProblemCommon TargetProblemCommon

-- | The 'TargetSelector' matches targets but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector
deriving (Eq, Show)

reportTargetProblems :: Verbosity -> [TargetProblem] -> IO a
Expand Down
12 changes: 6 additions & 6 deletions cabal-install/Distribution/Client/CmdErrorMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ sortGroupOn key = map (\xs@(x:_) -> (key x, xs))
-- Renderering for a few project and package types
--

renderTargetSelector :: TargetSelector PackageId -> String
renderTargetSelector :: TargetSelector -> String
renderTargetSelector (TargetPackage _ pkgid Nothing) =
"the package " ++ display pkgid

Expand Down Expand Up @@ -129,20 +129,20 @@ optionalStanza _ = Nothing

-- | Does the 'TargetSelector' potentially refer to one package or many?
--
targetSelectorPluralPkgs :: TargetSelector a -> Plural
targetSelectorPluralPkgs :: TargetSelector -> Plural
targetSelectorPluralPkgs (TargetAllPackages _) = Plural
targetSelectorPluralPkgs (TargetPackage _ _ _) = Singular
targetSelectorPluralPkgs (TargetComponent _ _ _) = Singular
targetSelectorPluralPkgs (TargetPackageName _) = Singular

-- | Does the 'TargetSelector' refer to
targetSelectorRefersToPkgs :: TargetSelector a -> Bool
targetSelectorRefersToPkgs :: TargetSelector -> Bool
targetSelectorRefersToPkgs (TargetAllPackages mkfilter) = isNothing mkfilter
targetSelectorRefersToPkgs (TargetPackage _ _ mkfilter) = isNothing mkfilter
targetSelectorRefersToPkgs (TargetComponent _ _ _) = False
targetSelectorRefersToPkgs (TargetPackageName _) = True

targetSelectorFilter :: TargetSelector a -> Maybe ComponentKindFilter
targetSelectorFilter :: TargetSelector -> Maybe ComponentKindFilter
targetSelectorFilter (TargetPackage _ _ mkfilter) = mkfilter
targetSelectorFilter (TargetAllPackages mkfilter) = mkfilter
targetSelectorFilter (TargetComponent _ _ _) = Nothing
Expand Down Expand Up @@ -238,7 +238,7 @@ renderTargetProblemCommon verb (TargetProblemNoSuchComponent pkgid cname) =
-- This renders an error message for those cases.
--
renderTargetProblemNoneEnabled :: String
-> TargetSelector PackageId
-> TargetSelector
-> [AvailableTarget ()]
-> String
renderTargetProblemNoneEnabled verb targetSelector targets =
Expand Down Expand Up @@ -300,7 +300,7 @@ renderTargetProblemNoneEnabled verb targetSelector targets =
-- | Several commands have a @TargetProblemNoTargets@ problem constructor.
-- This renders an error message for those cases.
--
renderTargetProblemNoTargets :: String -> TargetSelector PackageId -> String
renderTargetProblemNoTargets :: String -> TargetSelector -> String
renderTargetProblemNoTargets verb targetSelector =
"Cannot " ++ verb ++ " " ++ renderTargetSelector targetSelector
++ " because " ++ reason targetSelector ++ ". "
Expand Down
6 changes: 3 additions & 3 deletions cabal-install/Distribution/Client/CmdHaddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ haddockAction (applyFlagDefaults -> (configFlags, configExFlags, installFlags, h
-- depending on the @--executables@ flag we also select all the buildable exes.
-- We do similarly for test-suites, benchmarks and foreign libs.
--
selectPackageTargets :: HaddockFlags -> TargetSelector PackageId
selectPackageTargets :: HaddockFlags -> TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets haddockFlags targetSelector targets

Expand Down Expand Up @@ -179,10 +179,10 @@ data TargetProblem =
TargetProblemCommon TargetProblemCommon

-- | The 'TargetSelector' matches targets but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector
deriving (Eq, Show)

reportTargetProblems :: Verbosity -> [TargetProblem] -> IO a
Expand Down
8 changes: 4 additions & 4 deletions cabal-install/Distribution/Client/CmdInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ symlinkBuiltPackage :: (UnitId -> FilePath) -- ^ A function to get an UnitId's
-- store directory
-> FilePath -- ^ Where to put the symlink
-> ( UnitId
, [(ComponentTarget, [TargetSelector PackageId])] )
, [(ComponentTarget, [TargetSelector])] )
-> IO ()
symlinkBuiltPackage mkSourceBinDir destDir (pkg, components) =
traverse_ (symlinkBuiltExe (mkSourceBinDir pkg) destDir) exes
Expand Down Expand Up @@ -265,7 +265,7 @@ establishDummyProjectBaseContext verbosity cliConfig tmpDir localPackages = do
-- For the @build@ command select all components except non-buildable and disabled
-- tests\/benchmarks, fail if there are no such components
--
selectPackageTargets :: TargetSelector PackageId
selectPackageTargets :: TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets targetSelector targets

Expand Down Expand Up @@ -312,10 +312,10 @@ data TargetProblem =
TargetProblemCommon TargetProblemCommon

-- | The 'TargetSelector' matches targets but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector
deriving (Eq, Show)

reportTargetProblems :: Verbosity -> [TargetProblem] -> IO a
Expand Down
8 changes: 4 additions & 4 deletions cabal-install/Distribution/Client/CmdRepl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ replAction (applyFlagDefaults -> (configFlags, configExFlags, installFlags, hadd
-- Fail if there are no buildable lib\/exe components, or if there are
-- multiple libs or exes.
--
selectPackageTargets :: TargetSelector PackageId
selectPackageTargets :: TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets targetSelector targets

Expand Down Expand Up @@ -229,13 +229,13 @@ data TargetProblem =
TargetProblemCommon TargetProblemCommon

-- | The 'TargetSelector' matches targets but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector

-- | A single 'TargetSelector' matches multiple targets
| TargetProblemMatchesMultiple (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemMatchesMultiple TargetSelector [AvailableTarget ()]

-- | Multiple 'TargetSelector's match multiple targets
| TargetProblemMultipleTargets TargetsMap
Expand Down
10 changes: 5 additions & 5 deletions cabal-install/Distribution/Client/CmdRun.hs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ matchingPackagesByUnitId uid =
-- For the @run@ command we select the exe if there is only one and it's
-- buildable. Fail if there are no or multiple buildable exe components.
--
selectPackageTargets :: TargetSelector PackageId
selectPackageTargets :: TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets targetSelector targets

Expand Down Expand Up @@ -341,16 +341,16 @@ selectComponentTarget pkgid cname subtarget _
data TargetProblem =
TargetProblemCommon TargetProblemCommon
-- | The 'TargetSelector' matches targets but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector

-- | The 'TargetSelector' matches targets but no executables
| TargetProblemNoExes (TargetSelector PackageId)
| TargetProblemNoExes TargetSelector

-- | A single 'TargetSelector' matches multiple targets
| TargetProblemMatchesMultiple (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemMatchesMultiple TargetSelector [AvailableTarget ()]

-- | Multiple 'TargetSelector's match multiple targets
| TargetProblemMultipleTargets TargetsMap
Expand Down
8 changes: 4 additions & 4 deletions cabal-install/Distribution/Client/CmdTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ testAction (applyFlagDefaults -> (configFlags, configExFlags, installFlags, hadd
-- For the @test@ command we select all buildable test-suites,
-- or fail if there are no test-suites or no buildable test-suites.
--
selectPackageTargets :: TargetSelector PackageId
selectPackageTargets :: TargetSelector
-> [AvailableTarget k] -> Either TargetProblem [k]
selectPackageTargets targetSelector targets

Expand Down Expand Up @@ -184,13 +184,13 @@ data TargetProblem =
TargetProblemCommon TargetProblemCommon

-- | The 'TargetSelector' matches targets but none are buildable
| TargetProblemNoneEnabled (TargetSelector PackageId) [AvailableTarget ()]
| TargetProblemNoneEnabled TargetSelector [AvailableTarget ()]

-- | There are no targets at all
| TargetProblemNoTargets (TargetSelector PackageId)
| TargetProblemNoTargets TargetSelector

-- | The 'TargetSelector' matches targets but no test-suites
| TargetProblemNoTests (TargetSelector PackageId)
| TargetProblemNoTests TargetSelector

-- | The 'TargetSelector' refers to a component that is not a test-suite
| TargetProblemComponentNotTest PackageId ComponentName
Expand Down
9 changes: 4 additions & 5 deletions cabal-install/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ runProjectPostBuildPhase verbosity
-- possible to for different selectors to match the same target. This extra
-- information is primarily to help make helpful error messages.
--
type TargetsMap = Map UnitId [(ComponentTarget, [TargetSelector PackageId])]
type TargetsMap = Map UnitId [(ComponentTarget, [TargetSelector])]

-- | Given a set of 'TargetSelector's, resolve which 'UnitId's and
-- 'ComponentTarget's they ought to refer to.
Expand Down Expand Up @@ -428,15 +428,15 @@ type TargetsMap = Map UnitId [(ComponentTarget, [TargetSelector PackageId])]
-- a basis for their own @selectComponentTarget@ implementation.
--
resolveTargets :: forall err.
(forall k. TargetSelector PackageId
(forall k. TargetSelector
-> [AvailableTarget k]
-> Either err [k])
-> (forall k. PackageId -> ComponentName -> SubComponentTarget
-> AvailableTarget k
-> Either err k )
-> (TargetProblemCommon -> err)
-> ElaboratedInstallPlan
-> [TargetSelector PackageId]
-> [TargetSelector]
-> Either [err] TargetsMap
resolveTargets selectPackageTargets selectComponentTarget liftProblem
installPlan targetSelectors =
Expand All @@ -462,8 +462,7 @@ resolveTargets selectPackageTargets selectComponentTarget liftProblem
-- TODO [required eventually] currently all build targets refer to packages
-- inside the project. Ultimately this has to be generalised to allow
-- referring to other packages and targets.
checkTarget :: TargetSelector PackageId
-> Either err [(UnitId, ComponentTarget)]
checkTarget :: TargetSelector -> Either err [(UnitId, ComponentTarget)]

-- We can ask to build any whole package, project-local or a dependency
checkTarget bt@(TargetPackage _ pkgid mkfilter)
Expand Down
Loading