Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Parsing command line targets
There are two relevant data sources for performing this parsing: the project configuration, and command line arguments. Project configurations includes the resolver (defining a LoadedSnapshot of global and snapshot packages), local dependencies, and project packages. It also defines local flag overrides.
The command line arguments specify both additional local flag overrides and targets in their raw form.
Flags are simple: we just combine CLI flags with config flags and make one big map of flags, preferring CLI flags when present.
Raw targets can be a package name, a package name with component, just a component, or a package name and version number. We first must resolve these raw targets into both simple targets and additional dependencies. This works as follows:
- If a component is specified, find a unique project package which defines that component, and convert it into a name+component target.
- Ensure that all name+component values refer to valid components in the given project package.
- For names, check if the name is present in the snapshot, local deps, or project packages. If it is not, then look up the most recent version in the package index and convert to a name+version.
- For name+version, first ensure that the name is not used by a project package. Next, if that name+version is present in the snapshot or local deps _and_ its location is PLIndex, we have the package. Otherwise, add to local deps with the appropriate PLIndex.
If in either of the last two bullets we added a package to local deps, print a warning to the user recommending modifying the extra-deps.
Combine the various ResolveResults
s together into Target
values, by
combining various components for a single package and ensuring that no
conflicting statements were made about targets.
At this point, we now have a Map from package name to SimpleTarget, and an updated Map of local dependencies. We still have the aggregated flags, and the snapshot and project packages.
Finally, we upgrade the snapshot by using calculatePackagePromotion.
Synopsis
- data Target
- data NeedTargets
- data PackageType
- parseTargets :: HasBuildConfig env => NeedTargets -> Bool -> BuildOptsCLI -> SMActual GlobalPackage -> RIO env SMTargets
- gpdVersion :: GenericPackageDescription -> Version
- parseRawTarget :: Text -> Maybe RawTarget
- data RawTarget
- = RTPackageComponent !PackageName !UnresolvedComponent
- | RTComponent !ComponentName
- | RTPackage !PackageName
- | RTPackageIdentifier !PackageIdentifier
- data UnresolvedComponent
- = ResolvedComponent !NamedComponent
- | UnresolvedComponent !ComponentName
Types
How a package is intended to be built
TargetAll !PackageType | Build all of the default components. |
TargetComps !(Set NamedComponent) | Only build specific components |
data NeedTargets Source #
Do we need any targets? For example, `stack build` will fail if no targets are provided.
data PackageType Source #
Instances
Show PackageType Source # | |
Defined in Stack.Types.SourceMap showsPrec :: Int -> PackageType -> ShowS # show :: PackageType -> String # showList :: [PackageType] -> ShowS # | |
Eq PackageType Source # | |
Defined in Stack.Types.SourceMap (==) :: PackageType -> PackageType -> Bool # (/=) :: PackageType -> PackageType -> Bool # |
parseTargets :: HasBuildConfig env => NeedTargets -> Bool -> BuildOptsCLI -> SMActual GlobalPackage -> RIO env SMTargets Source #
Convenience helpers
gpdVersion :: GenericPackageDescription -> Version #
Get the Version
from a GenericPackageDescription
.
Since: pantry-0.1.0.0
Test suite exports
parseRawTarget :: Text -> Maybe RawTarget Source #
If this function returns Nothing
, the input should be treated as a
directory.
Raw command line input, without checking against any databases or list of locals. Does not deal with directories
RTPackageComponent !PackageName !UnresolvedComponent | |
RTComponent !ComponentName | |
RTPackage !PackageName | |
RTPackageIdentifier !PackageIdentifier |
Instances
data UnresolvedComponent Source #
Either a fully resolved component, or a component name that could be either an executable, test, or benchmark
ResolvedComponent !NamedComponent | |
UnresolvedComponent !ComponentName |
Instances
Show UnresolvedComponent Source # | |
Defined in Stack.Build.Target showsPrec :: Int -> UnresolvedComponent -> ShowS # show :: UnresolvedComponent -> String # showList :: [UnresolvedComponent] -> ShowS # | |
Eq UnresolvedComponent Source # | |
Defined in Stack.Build.Target (==) :: UnresolvedComponent -> UnresolvedComponent -> Bool # (/=) :: UnresolvedComponent -> UnresolvedComponent -> Bool # | |
Ord UnresolvedComponent Source # | |
Defined in Stack.Build.Target compare :: UnresolvedComponent -> UnresolvedComponent -> Ordering # (<) :: UnresolvedComponent -> UnresolvedComponent -> Bool # (<=) :: UnresolvedComponent -> UnresolvedComponent -> Bool # (>) :: UnresolvedComponent -> UnresolvedComponent -> Bool # (>=) :: UnresolvedComponent -> UnresolvedComponent -> Bool # max :: UnresolvedComponent -> UnresolvedComponent -> UnresolvedComponent # min :: UnresolvedComponent -> UnresolvedComponent -> UnresolvedComponent # |