Skip to content

Commit

Permalink
More fine grained recompile checking
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Aug 19, 2015
1 parent e20ea86 commit 4cbca17
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ checkDirtiness ps installed package present wanted = do
case moldOpts of
Nothing -> Just "old configure information not found"
Just oldOpts
| oldOpts /= wantConfigCache -> Just $ describeConfigDiff oldOpts wantConfigCache
| Just reason <- describeConfigDiff oldOpts wantConfigCache -> Just reason
| psDirty ps -> Just "local file changes"
| otherwise -> Nothing
case mreason of
Expand All @@ -454,19 +454,20 @@ checkDirtiness ps installed package present wanted = do
tell mempty { wDirty = Map.singleton (packageName package) reason }
return True

describeConfigDiff :: ConfigCache -> ConfigCache -> Text
describeConfigDiff :: ConfigCache -> ConfigCache -> Maybe Text
describeConfigDiff old new
| configCacheDeps old /= configCacheDeps new = "dependencies changed"
| configCacheComponents old /= configCacheComponents new = "components changed"
| configCacheHaddock old && not (configCacheHaddock new) = "no longer building haddocks"
| not (configCacheHaddock old) && configCacheHaddock new = "building haddocks"
| oldOpts /= newOpts = T.pack $ concat
| configCacheDeps old /= configCacheDeps new = Just "dependencies changed"
| not $ Set.null newComponents =
Just $ "components added: " `T.append` T.intercalate ", "
(map (decodeUtf8With lenientDecode) (Set.toList newComponents))
| not (configCacheHaddock old) && configCacheHaddock new = Just "rebuilding with haddocks"
| oldOpts /= newOpts = Just $ T.pack $ concat
[ "flags changed from "
, show oldOpts
, " to "
, show newOpts
]
| otherwise = "unknown config cache difference"
| otherwise = Nothing
where
-- options set by stack
isStackOpt t = any (`T.isPrefixOf` t)
Expand All @@ -487,6 +488,8 @@ describeConfigDiff old new
| x == y = removeMatching xs ys
removeMatching xs ys = (xs, ys)

newComponents = configCacheComponents new `Set.difference` configCacheComponents old

psDirty :: PackageSource -> Bool
psDirty (PSLocal lp) = lpDirtyFiles lp
psDirty (PSUpstream _ _ _) = False -- files never change in an upstream package
Expand Down

0 comments on commit 4cbca17

Please sign in to comment.