Cabal Team After Build (Haskell Build System)

Can you tell Cabal to run some command after creating the application?

For example, I want to create some .hs files with a script and after creating, copy the other files to the dist/build/app directory.

+4
source share
1 answer

Yes. Take a look at postInst and its associated types / operations.

Distribution.Simple.UserHooks

Here is a quick example, you can hoogle related operations to find out more. It executes various .sh scripts, copy files, etc. AFTER assembly cabal. absoluteInstallDirs tells you where cabal puts other files, should you need it.

Hope this helps!

 import Distribution.Simple import Distribution.Simple.LocalBuildInfo import System.Process import System.Exit main = defaultMainWithHooks fixpointHooks fixpointHooks = simpleUserHooks { postInst = buildAndCopyFixpoint } buildAndCopyFixpoint _ _ pkg lbi = do putStrLn $ "Post Install: " ++ show binDir -- , libDir) executeShellCommand "./configure" executeShellCommand "./build.sh" executeShellCommand $ "chmod a+x external/fixpoint/fixpoint.native " executeShellCommand $ "cp external/fixpoint/fixpoint.native " ++ binDir executeShellCommand $ "cp external/z3/lib/libz3.* " ++ binDir where allDirs = absoluteInstallDirs pkg lbi NoCopyDest binDir = bindir allDirs ++ "/" executeShellCommand cmd = putStrLn ("EXEC: " ++ cmd) >> system cmd >>= check where check (ExitSuccess) = return () check (ExitFailure n) = error $ "cmd: " ++ cmd ++ " failure code " ++ show n fixpointHooks = simpleUserHooks { postInst = buildAndCopyFixpoint } 
+3
source

Source: https://habr.com/ru/post/1491180/


All Articles