Skip to content

Commit

Permalink
Only plan to build a target if some of its components will built #2862
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Aug 7, 2017
1 parent 3ae94a2 commit 7f5a63d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Bug fixes:
* Fixed an issue where Stack wouldn't detect missing Docker images
properly with newer Docker versions.
[#3171](https://github.com/commercialhaskell/stack/pull/3171)
* Previously, cabal files with just test-suite could cause build to fail
([#2862](https://github.com/commercialhaskell/stack/issues/2862))


## 1.5.1
Expand Down
15 changes: 13 additions & 2 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,23 @@ loadLocalPackage boptsCli targets (name, lpv) = do
)
Nothing -> mempty

-- See https://github.com/commercialhaskell/stack/issues/2862
isWanted = case mtarget of
Nothing -> False
-- FIXME: When issue #1406 ("stack 0.1.8 lost ability to
-- build individual executables or library") is resolved,
-- 'packageHasLibrary' is only relevant if the library is
-- part of the target spec.
Just _ -> packageHasLibrary pkg || not (Set.null allComponents)

filterSkippedComponents = Set.filter (not . (`elem` boptsSkipComponents bopts))

(exes, tests, benches) = (filterSkippedComponents exeCandidates,
filterSkippedComponents testCandidates,
filterSkippedComponents benchCandidates)

allComponents = toComponents exes tests benches

toComponents e t b = Set.unions
[ Set.map CExe e
, Set.map CTest t
Expand Down Expand Up @@ -254,8 +265,8 @@ loadLocalPackage boptsCli targets (name, lpv) = do
, lpNewBuildCache = newBuildCache
, lpCabalFile = lpvCabalFP lpv
, lpDir = lpvRoot lpv
, lpWanted = isJust mtarget
, lpComponents = toComponents exes tests benches
, lpWanted = isWanted
, lpComponents = allComponents
-- TODO: refactor this so that it's easier to be sure that these
-- components are indeed unbuildable.
--
Expand Down

0 comments on commit 7f5a63d

Please sign in to comment.