首页 > 解决方案 > 将 hsc2hs 与 HPack 和 Stack 一起使用

问题描述

我想通过 Stack 和 HPack 使用 hsc2hs。问题是,由于 HPack 不允许我将.hsc文件列为源文件,.hs因此对文件的更改.hsc不会触发stack build.

我的package.yaml文件如下:

name: bounce-bench
version: 0.1.0
category: acme

dependencies:
  - base

source-dirs:
  - src

executables:
  sim-ffi:
    source-dirs: sim
    main: sim-ffi.hs

    build-tools: hsc2hs
    c-sources:
        - csim/Bounce.h
        - csim/Bounce.c
    include-dirs: csim

使用上述文件,初始成功(包括从stack build构建),但是,如果更改,后续调用不会执行任何操作。sim-ffi.hssim-ffi.hscstack buildsim-ffi.hsc

如果我尝试将main键的值从sim-ffi.hsto更改sim-ffi.hsc,我会被明确告知:

Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5: The 'main-is' field must specify a
'.hs' or '.lhs' file (even if it is generated by a preprocessor), or it may
specify a C/C++/obj-C source file.

标签: haskellpreprocessorhaskell-stackhsc2hshpack

解决方案


推荐阅读