![](/img/trans.png)
[英]What is the easiest command for issuing a cabal build, when coding Haskell in Emacs?
[英]Cabal after build command (Haskell build system)
是否有可能在構建應用程序后告訴Cabal運行某些命令?
我希望例如使用腳本生成一些.hs
文件,並在構建之后將其他一些文件復制到dist/build/app
目錄。
是。 看一下postInst
和相關的類型/操作。
這是一個快速示例,您可以通過相關操作來了解更多信息。 這將執行各種.sh腳本,復制文件等。在cabal構建之后。 如果需要, absoluteInstallDirs
告訴您cabal放置其他文件的位置。
希望這可以幫助!
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 }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.