Skip to content

Commit

Permalink
Pass in PackageDescription explicitly to readTargetInfos, see haskell…
Browse files Browse the repository at this point in the history
…#3606

Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Jul 23, 2016
1 parent 6c9d014 commit b1b8597
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cabal/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ build pkg_descr lbi flags suffixes
-- TODO: if checkBuildTargets ignores a target we may accept
-- a --assume-deps-up-to-date with multiple arguments. Arguably, we should
-- error early in this case.
target <- readTargetInfos verbosity lbi (buildArgs flags) >>= \r -> case r of
target <- readTargetInfos verbosity pkg_descr lbi (buildArgs flags) >>= \r -> case r of
[] -> die "In --assume-deps-up-to-date mode you must specify a target"
[target] -> return target
_ -> die "In --assume-deps-up-to-date mode you can only build a single target"
Expand All @@ -109,7 +109,7 @@ build pkg_descr lbi flags suffixes
buildComponent verbosity (buildNumJobs flags) pkg_descr
lbi' suffixes comp clbi distPref
| otherwise = do
targets <- readTargetInfos verbosity lbi (buildArgs flags)
targets <- readTargetInfos verbosity pkg_descr lbi (buildArgs flags)
let componentsToBuild = neededTargetsInBuildOrder lbi (map nodeKey targets)
info verbosity $ "Component build order: "
++ intercalate ", "
Expand Down Expand Up @@ -149,7 +149,7 @@ repl pkg_descr lbi flags suffixes args = do
let distPref = fromFlag (replDistPref flags)
verbosity = fromFlag (replVerbosity flags)

target <- readTargetInfos verbosity lbi args >>= \r -> case r of
target <- readTargetInfos verbosity pkg_descr lbi args >>= \r -> case r of
-- This seems DEEPLY questionable.
[] -> return (head (allTargetsInBuildOrder lbi))
[target] -> return target
Expand Down
13 changes: 10 additions & 3 deletions Cabal/Distribution/Simple/BuildTarget.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ import System.Directory

-- | Take a list of 'String' build targets, and parse and validate them
-- into actual 'TargetInfo's to be built/registered/whatever.
readTargetInfos :: Verbosity -> LocalBuildInfo -> [String] -> IO [TargetInfo]
readTargetInfos verbosity lbi args = do
build_targets <- readBuildTargets (localPkgDescr lbi) args
readTargetInfos :: Verbosity
-> PackageDescription
-> LocalBuildInfo
-> [String]
-> IO [TargetInfo]
readTargetInfos verbosity pkg_descr lbi args = do
-- NB: NOT pkg_descr not localPkgDescr lbi which is
-- not guaranteed to be up-to-date depending on buggy
-- client code.
build_targets <- readBuildTargets pkg_descr args
checkBuildTargets verbosity lbi build_targets

-- ------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Cabal/Distribution/Simple/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ install :: PackageDescription -- ^information from the .cabal file
install pkg_descr lbi flags
| fromFlag (copyAssumeDepsUpToDate flags) = do
checkHasLibsOrExes
targets <- readTargetInfos verbosity lbi (copyArgs flags)
targets <- readTargetInfos verbosity pkg_descr lbi (copyArgs flags)
case targets of
_ | null (copyArgs flags)
-> copyPackage verbosity pkg_descr lbi distPref copydest
Expand All @@ -76,7 +76,7 @@ install pkg_descr lbi flags

| otherwise = do
checkHasLibsOrExes
targets <- readTargetInfos verbosity lbi (copyArgs flags)
targets <- readTargetInfos verbosity pkg_descr lbi (copyArgs flags)

copyPackage verbosity pkg_descr lbi distPref copydest

Expand Down
2 changes: 1 addition & 1 deletion Cabal/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ register pkg_descr lbi flags = when (hasPublicLib pkg_descr) doRegister
-- usefully (they're not public.) If we start supporting scoped
-- packages, we'll have to relax this.
doRegister = do
targets <- readTargetInfos verbosity lbi (regArgs flags)
targets <- readTargetInfos verbosity pkg_descr lbi (regArgs flags)

-- It's important to register in build order, because ghc-pkg
-- will complain if a dependency is not registered.
Expand Down

0 comments on commit b1b8597

Please sign in to comment.