Skip to content

Commit

Permalink
Always write build-info, even before building
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Sep 7, 2021
1 parent d42a431 commit 5bf69e7
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions Cabal/src/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,9 @@ build pkg_descr lbi flags suffixes = do

internalPackageDB <- createInternalPackageDB verbosity lbi distPref

(\f -> foldM_ f (installedPkgs lbi) componentsToBuild) $ \index target -> do
let comp = targetComponent target
clbi = targetCLBI target
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity
let bi = componentBuildInfo comp
progs' = addInternalBuildTools pkg_descr lbi bi (withPrograms lbi)
lbi' = lbi {
withPrograms = progs',
withPackageDB = withPackageDB lbi ++ [internalPackageDB],
installedPkgs = index
}
mb_ipi <- buildComponent verbosity (buildNumJobs flags) pkg_descr
lbi' suffixes comp clbi distPref
return (maybe index (Index.insert `flip` index) mb_ipi)

-- Before the actual building, dump out build-information.
-- This way, if the actual compilation failed, the options have still been
-- dumped.
when shouldDumpBuildInfo $ do
-- Changing this line might break consumers of the dumped build info.
-- Announce changes on mailing lists!
Expand All @@ -150,6 +138,22 @@ build pkg_descr lbi flags suffixes = do
exists <- doesFileExist (buildInfoPref distPref)
when exists $ removeFile (buildInfoPref distPref)

-- Now do the actual building
(\f -> foldM_ f (installedPkgs lbi) componentsToBuild) $ \index target -> do
let comp = targetComponent target
clbi = targetCLBI target
componentInitialBuildSteps distPref pkg_descr lbi clbi verbosity
let bi = componentBuildInfo comp
progs' = addInternalBuildTools pkg_descr lbi bi (withPrograms lbi)
lbi' = lbi {
withPrograms = progs',
withPackageDB = withPackageDB lbi ++ [internalPackageDB],
installedPkgs = index
}
mb_ipi <- buildComponent verbosity (buildNumJobs flags) pkg_descr
lbi' suffixes comp clbi distPref
return (maybe index (Index.insert `flip` index) mb_ipi)

return ()
where
distPref = fromFlag (buildDistPref flags)
Expand Down

0 comments on commit 5bf69e7

Please sign in to comment.