Skip to content

Commit

Permalink
Add pre and post build hooks
Browse files Browse the repository at this point in the history
Run a program (named "preBuildHook") before doing a package build and
another program (named "postBuildHook") after the package is built.

These two programs simply need to be on the users $PATH variable and
are completely generic.

Co-authored: Moritz Angermann <[email protected]>
  • Loading branch information
erikd committed Apr 17, 2024
1 parent 50a5cb6 commit 56349de
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,31 @@ buildAndInstallUnpackedPackage
runConfigure
PBBuildPhase{runBuild} -> do
noticeProgress ProgressBuilding
runBuild
-- run preBuildHook. If it returns with 0, we assume the build was
-- successful. If not, run the build.
code <-
rawSystemExitCode
verbosity
(Just srcdir)
"preBuildHook"
[ (unUnitId $ installedUnitId rpkg)
, (getSymbolicPath srcdir)
, (getSymbolicPath builddir)
]
`catchIO` (\_ -> return (ExitFailure 10))
when (code /= ExitSuccess) $ do
runBuild
-- not sure, if we want to care about a failed postBuildHook?
void $
rawSystemExitCode
verbosity
(Just srcdir)
"postBuildHook"
[ (unUnitId $ installedUnitId rpkg)
, (getSymbolicPath srcdir)
, (getSymbolicPath builddir)
]
`catchIO` (\_ -> return (ExitFailure 10))
PBHaddockPhase{runHaddock} -> do
noticeProgress ProgressHaddock
runHaddock
Expand Down

0 comments on commit 56349de

Please sign in to comment.