C 如何在堆栈构建我的项目(使用nix)之前生成FFI依赖项?
我有一个Haskell+stack+nix项目,它大量使用FFI代码。问题是,我所依赖的两个C文件必须在编译Haskell项目之前生成。这两个文件是(i)C 如何在堆栈构建我的项目(使用nix)之前生成FFI依赖项?,c,haskell,ffi,haskell-stack,nix,C,Haskell,Ffi,Haskell Stack,Nix,我有一个Haskell+stack+nix项目,它大量使用FFI代码。问题是,我所依赖的两个C文件必须在编译Haskell项目之前生成。这两个文件是(i)/cbits/xdgshellprotocol.c和(ii)/include/xdgshellprotocol.h 首先,这里是可以生成这些文件的Makefile: WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) WAYLAND_SCAN
/cbits/xdgshellprotocol.c
和(ii)/include/xdgshellprotocol.h
首先,这里是可以生成这些文件的Makefile:
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c: xdg-shell-protocol.h
$(WAYLAND_SCANNER) private-code \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
请注意,我依赖于系统程序wayland协议
和wayland扫描仪
,这两个程序都在我的项目的shell.nix
中指定:
buildInputs = with pkgs; [
# ...
# These are bleeding edge so I crafted my own nix expressions:
(callPackage ./nix/wayland.nix { } )
(callPackage ./nix/wayland-protocols.nix { } )
# ...
];
最后请注意,我告诉Haskell我的包.yaml中的这些文件:
c-sources:
- cbits/xdg-shell-protocol.c
include-dirs:
- include
问题:我如何使每次有人运行堆栈[--nix]build
(带或不带nix),这两个文件(I)/cbits/xdg shell protocol.c
和(ii)/include/xdg shell protocol.h
都是最新的