在Windows上部署应用程序的GHC API的简单方法

我想在Windows上部署需要访问GHC API的应用程序。使用Wiki中的第一个简单示例: http://www.haskell.org/haskellwiki/GHC/As_a_library 导致以下错误(在具有haskell平台的一台机器上编译并在另一个干净的Windows安装上执行): test.exe:在C: haskell lib package.conf.d中找不到包数据库 我想将我的应用程序部署为一个简单的zip文件,而不是要求用户安装任何东西。是否有一种简单的方法在该zip文件中包含所需的GHC内容,以便它可以工作?     
已邀请:
该程序将必要的文件复制到指定的目录(仅适用于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
中删除未使用的库以节省更多空间。     

要回复问题请先登录注册