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

Don't watch files for non-library components that are not being built #3565

Merged
merged 5 commits into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ Other enhancements:
[#3520](https://github.com/commercialhaskell/stack/issues/3520).
* Log when each individual test suite finishes. See:
[#3552](https://github.com/commercialhaskell/stack/issues/3552).
* Avoid spurious rebuilds when using `--file-watch` by not watching files for
executable, test and benchmark components that aren't a target. See:
[#3483](https://github.com/commercialhaskell/stack/issues/3483).
* Stack will now try to detect the width of the running terminal
(only on POSIX for the moment) and use that to better display
output messages. Work is ongoing, so some messages will not
Expand Down
15 changes: 11 additions & 4 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ loadLocalPackage boptsCli targets (name, lpv) = do
case packageLibraries pkg of
NoLibraries -> False
HasLibraries _ -> True
in hasLibrary || not (Set.null allComponents)
in hasLibrary || not (Set.null nonLibComponents)

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

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

allComponents = toComponents exes tests benches
nonLibComponents = toComponents exes tests benches

toComponents e t b = Set.unions
[ Set.map CExe e
Expand Down Expand Up @@ -278,7 +278,14 @@ loadLocalPackage boptsCli targets (name, lpv) = do
benchpkg = resolvePackage benchconfig gpkg

mbuildCache <- tryGetBuildCache $ lpvRoot lpv
(files,_) <- getPackageFilesSimple pkg (lpvCabalFP lpv)

(_,compFiles,otherFiles,_) <-
getPackageFiles (packageFiles pkg) (lpvCabalFP lpv)
let filesForComponent cn = Set.map dotCabalGetPath
$ M.findWithDefault mempty cn compFiles
files = Set.unions
$ otherFiles
: map filesForComponent (CLib : Set.toList nonLibComponents)

(dirtyFiles, newBuildCache) <- checkBuildCache
(fromMaybe Map.empty mbuildCache)
Expand All @@ -301,7 +308,7 @@ loadLocalPackage boptsCli targets (name, lpv) = do
, lpCabalFile = lpvCabalFP lpv
, lpDir = lpvRoot lpv
, lpWanted = isWanted
, lpComponents = allComponents
, lpComponents = nonLibComponents
-- TODO: refactor this so that it's easier to be sure that these
-- components are indeed unbuildable.
--
Expand Down