Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 如何在堆栈构建我的项目(使用nix)之前生成FFI依赖项?_C_Haskell_Ffi_Haskell Stack_Nix - Fatal编程技术网

C 如何在堆栈构建我的项目(使用nix)之前生成FFI依赖项?

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

我有一个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_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
都是最新的