@@ -235,6 +235,7 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
235235 pPackages <- for (smProject sourceMap) $ \ pp -> do
236236 lp <- loadLocalPackage sourceMap pp
237237 return $ SourceLocal lp Local
238+ bopts <- view $ configL. to configBuild
238239 deps <- for (smDeps sourceMap) $ \ dp ->
239240 case dpLocation dp of
240241 PLImmutable loc -> do
@@ -244,7 +245,7 @@ constructPlan baseConfigOpts0 localDumpPkgs loadPackage0 sourceMap installedMap
244245 PLMutable dir -> do
245246 -- FIXME this is not correct, we don't want to treat all Mutable as local
246247 -- FIXME ^ is from Stack.Build.Source
247- pp <- mkProjectPackage YesPrintWarnings dir
248+ pp <- mkProjectPackage YesPrintWarnings dir (shouldHaddockDeps bopts)
248249 lp <- loadLocalPackage sourceMap pp
249250 return $ SourceLocal lp Snap
250251 return $ pPackages <> deps
@@ -343,8 +344,8 @@ mkUnregisterLocal tasks dirtyReason localDumpPkgs sourceMap initialBuildSteps =
343344-- benchmarks. If @isAllInOne@ is 'True' (the common case), then all of
344345-- these should have already been taken care of as part of the build
345346-- step.
346- addFinal :: LocalPackage -> Package -> Bool -> M ()
347- addFinal lp package isAllInOne = do
347+ addFinal :: LocalPackage -> Package -> Bool -> Bool -> M ()
348+ addFinal lp package isAllInOne buildHaddocks = do
348349 depsRes <- addPackageDeps False package
349350 res <- case depsRes of
350351 Left e -> return $ Left e
@@ -363,6 +364,7 @@ addFinal lp package isAllInOne = do
363364 True -- local
364365 Local
365366 package
367+ , taskBuildHaddock = buildHaddocks
366368 , taskPresent = present
367369 , taskType = TTFilePath lp Local -- FIXME we can rely on this being Local, right?
368370 , taskAllInOne = isAllInOne
@@ -474,12 +476,12 @@ installPackage treatAsDep name ps minstalled = do
474476 SourceRemote pkgLoc _version cp -> do
475477 planDebug $ " installPackage: Doing all-in-one build for upstream package " ++ show name
476478 package <- loadPackage ctx pkgLoc (cpFlags cp) (cpGhcOptions cp)
477- resolveDepsAndInstall True treatAsDep ps package minstalled
479+ resolveDepsAndInstall True treatAsDep (cpHaddocks cp) ps package minstalled
478480 SourceLocal lp _ ->
479481 case lpTestBench lp of
480482 Nothing -> do
481483 planDebug $ " installPackage: No test / bench component for " ++ show name ++ " so doing an all-in-one build."
482- resolveDepsAndInstall True treatAsDep ps (lpPackage lp) minstalled
484+ resolveDepsAndInstall True treatAsDep (lpBuildHaddocks lp) ps (lpPackage lp) minstalled
483485 Just tb -> do
484486 -- Attempt to find a plan which performs an all-in-one
485487 -- build. Ignore the writer action + reset the state if
@@ -494,10 +496,10 @@ installPackage treatAsDep name ps minstalled = do
494496 case res of
495497 Right deps -> do
496498 planDebug $ " installPackage: For " ++ show name ++ " , successfully added package deps"
497- adr <- installPackageGivenDeps True ps tb minstalled deps
499+ adr <- installPackageGivenDeps True False ps tb minstalled deps
498500 -- FIXME: this redundantly adds the deps (but
499501 -- they'll all just get looked up in the map)
500- addFinal lp tb True
502+ addFinal lp tb True False
501503 return $ Right adr
502504 Left _ -> do
503505 -- Reset the state to how it was before
@@ -507,43 +509,45 @@ installPackage treatAsDep name ps minstalled = do
507509 put s
508510 -- Otherwise, fall back on building the
509511 -- tests / benchmarks in a separate step.
510- res' <- resolveDepsAndInstall False treatAsDep ps (lpPackage lp) minstalled
512+ res' <- resolveDepsAndInstall False treatAsDep (lpBuildHaddocks lp) ps (lpPackage lp) minstalled
511513 when (isRight res') $ do
512514 -- Insert it into the map so that it's
513515 -- available for addFinal.
514516 updateLibMap name res'
515- addFinal lp tb False
517+ addFinal lp tb False False
516518 return res'
517519
518520resolveDepsAndInstall :: Bool
521+ -> Bool
519522 -> Bool
520523 -> Source
521524 -> Package
522525 -> Maybe Installed
523526 -> M (Either ConstructPlanException AddDepRes )
524- resolveDepsAndInstall isAllInOne treatAsDep ps package minstalled = do
527+ resolveDepsAndInstall isAllInOne treatAsDep buildHaddocks ps package minstalled = do
525528 res <- addPackageDeps treatAsDep package
526529 case res of
527530 Left err -> return $ Left err
528- Right deps -> liftM Right $ installPackageGivenDeps isAllInOne ps package minstalled deps
531+ Right deps -> liftM Right $ installPackageGivenDeps isAllInOne buildHaddocks ps package minstalled deps
529532
530533-- | Checks if we need to install the given 'Package', given the results
531534-- of 'addPackageDeps'. If dependencies are missing, the package is
532535-- dirty, or it's not installed, then it needs to be installed.
533536installPackageGivenDeps :: Bool
537+ -> Bool
534538 -> Source
535539 -> Package
536540 -> Maybe Installed
537541 -> ( Set PackageIdentifier
538542 , Map PackageIdentifier GhcPkgId
539543 , InstallLocation )
540544 -> M AddDepRes
541- installPackageGivenDeps isAllInOne ps package minstalled (missing, present, minLoc) = do
545+ installPackageGivenDeps isAllInOne buildHaddocks ps package minstalled (missing, present, minLoc) = do
542546 let name = packageName package
543547 ctx <- ask
544548 mRightVersionInstalled <- case (minstalled, Set. null missing) of
545549 (Just installed, True ) -> do
546- shouldInstall <- checkDirtiness ps installed package present (wanted ctx)
550+ shouldInstall <- checkDirtiness ps installed package present
547551 return $ if shouldInstall then Nothing else Just installed
548552 (Just _, False ) -> do
549553 let t = T. intercalate " , " $ map (T. pack . packageNameString . pkgName) (Set. toList missing)
@@ -569,6 +573,7 @@ installPackageGivenDeps isAllInOne ps package minstalled (missing, present, minL
569573 -- https://github.com/commercialhaskell/stack/issues/345
570574 (assert (destLoc == loc) destLoc)
571575 package
576+ , taskBuildHaddock = buildHaddocks
572577 , taskPresent = present
573578 , taskType =
574579 case ps of
@@ -721,9 +726,8 @@ checkDirtiness :: Source
721726 -> Installed
722727 -> Package
723728 -> Map PackageIdentifier GhcPkgId
724- -> Set PackageName
725729 -> M Bool
726- checkDirtiness ps installed package present wanted' = do
730+ checkDirtiness ps installed package present = do
727731 ctx <- ask
728732 moldOpts <- runRIO ctx $ tryGetFlagCache installed
729733 let configOpts = configureOpts
@@ -733,18 +737,13 @@ checkDirtiness ps installed package present wanted' = do
733737 (psLocal ps)
734738 (sourceLocation ps) -- should be Local always
735739 package
736- buildOpts = bcoBuildOpts (baseConfigOpts ctx)
737740 wantConfigCache = ConfigCache
738741 { configCacheOpts = configOpts
739742 , configCacheDeps = Set. fromList $ Map. elems present
740743 , configCacheComponents =
741744 case ps of
742745 SourceLocal lp _ -> Set. map (encodeUtf8 . renderComponent) $ lpComponents lp
743746 SourceRemote {} -> Set. empty
744- , configCacheHaddock =
745- shouldHaddockPackage buildOpts wanted' (packageName package) ||
746- -- Disabling haddocks when old config had haddocks doesn't make dirty.
747- maybe False configCacheHaddock moldOpts
748747 , configCachePkgSrc = toCachePkgSrc ps
749748 }
750749 config = view configL ctx
@@ -776,7 +775,6 @@ describeConfigDiff config old new
776775 | not $ Set. null newComponents =
777776 Just $ " components added: " `T.append` T. intercalate " , "
778777 (map (decodeUtf8With lenientDecode) (Set. toList newComponents))
779- | not (configCacheHaddock old) && configCacheHaddock new = Just " rebuilding with haddocks"
780778 | oldOpts /= newOpts = Just $ T. pack $ concat
781779 [ " flags changed from "
782780 , show oldOpts
0 commit comments