这一计划将所需的文件复制到指定目录(仅在Windows上运行):
import Data.List (isSuffixOf)
import System.Environment (getArgs)
import GHC.Paths (libdir)
import System.Directory
import System.FilePath
import System.Cmd
main = do
[to] <- getArgs
let libdir' = to </> "lib"
createDirectoryIfMissing True libdir'
copy libdir libdir'
rawSystem "xcopy"
[ "/e", "/q"
, dropFileName libdir </> "mingw"
, to </> "mingw\\"]
-- | skip some files while copying
uselessFile f
= or $ map (`isSuffixOf` f)
[ "."
, "_debug.a"
, "_p.a", ".p_hi" -- libraries built with profiling
, ".dyn_hi", ".dll"] -- dynamic libraries
copy from to
= getDirectoryContents from
>>= mapM_ copy' . filter (not . uselessFile)
where
copy' f = do
let (from', to') = (from </> f, to </> f)
isDir <- doesDirectoryExist from'
if isDir
then createDirectory to' >> copy from' to'
else copyFile from' to'
与目标目录中运行它作为参数后,您将有lib
和mingw
(约300本地副本总共Mb)。
您可以从lib
中删除未使用的库以节省更多空间。
您可以手动指定'package.conf.d'的路径而不是调用'libdir'。即''runGhc(只是“路径\到\ ghc \ lib”)' – 2011-03-30 13:18:31
谢谢,但我的问题是关于如何完成ghc在我的应用程序在Windows上的最小嵌入,然后提到的具体错误。 – mentics 2011-03-30 13:37:35
在这种情况下,我不明白实际存在什么问题。看起来你只需要将'lib'和'mingw'复制到你的zip文件中,并提供'runGhc'与这个'lib'的相对路径(并且不要忘记从'lib'中删除未使用的包和库, )。 – 2011-03-30 14:17:17