stack-1.6.5: The Haskell Tool Stack

Safe HaskellNone




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 ResolveResultss 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.



data Target Source #

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.

Convenience helpers

Test suite exports

parseRawTarget :: Text -> Maybe RawTarget Source #

If this function returns Nothing, the input should be treated as a directory.

data RawTarget Source #

Raw command line input, without checking against any databases or list of locals. Does not deal with directories