⬑
在ArchLinux中创建Cabal项目
要点
需要首先修改calbal配置~/.cabal/config
,加入三行:
library-vanilla: False
shared: True
executable-dynamic: True
否则pacman
安装的依赖包将无法编译。
如果有多个executable可以把相同的部分写进common里面
示例
cabal-version: 2.4
name: projectName
version: 0.1.0.0
author: Mistivia
maintainer: i@mistivia.com
extra-source-files: CHANGELOG.md
common deps
other-modules: MyMod
build-depends: base ^>=4.16.4.0,
bytestring ==0.11.4.0,
containers ==0.6.5.1,
network ==3.2.7.0,
utf8-string ==1.0.2,
base16-bytestring ==1.0.2.0,
hs-source-dirs: app
, libs
default-language: GHC2021
ghc-options: -Wall
executable exec1
import: deps
main-is: Exec1.hs
executable exec2
import: deps
main-is: Exec2.hs
test-suite tests
type: exitcode-stdio-1.0
import: deps
build-depends: HUnit
main-is: TestMain.hs
hs-source-dirs: tests
项目文件:
- app
- Exec1.hs
- Exec2.hd
- libs
- MyMod.hs
- tests
- TestMain.hs
- projectName.cabal