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 0ff465b
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,54 @@ 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))

@@ -680,20 +680,29 @@

Check failure on line 697 in cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs

View workflow job for this annotation

GitHub Actions / hlint

Error: Parse error: on input `@@' ▫︎ Found: " ] `catchIO` (\\_ -> return (ExitFailure 10))\n \n> @@ -680,20 +680,29 @@\n noticeProgress ProgressBuilding\n -- run preBuildHook. If it returns with 0, we assume the build was\n"
noticeProgress ProgressBuilding
-- 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


PBHaddockPhase{runHaddock} -> do
noticeProgress ProgressHaddock
runHaddock
Expand Down

0 comments on commit 0ff465b

Please sign in to comment.