为了使我们的代码与多个ocamlgraph版本一起工作,我们在one of our files中使用以下代码片段
#if OCAMLGRAPH_VERSION >= (2,0,0)
let module Dom = Dominator.Make_graph(struct
include G
let empty () = create ()
let add_edge g v1 v2 = add_edge g v1 v2; g
end) in
#elif OCAMLGRAPH_VERSION >= (1,8,6)
let module Dom = Dominator.Make_graph(G) in
#else
let module Dom = Dominator.Make(G) in
#endif在我们的dune文件中,我们使用cppo对其进行预处理,如下所示:
(library
[...]
(preprocess (action (run %{bin:cppo} -V OCAMLGRAPH:%{read:ocamlgraph.version} %{input-file})))
(rule
(target ocamlgraph.version)
(action (with-stdout-to %{target} (run ocamlfind query -format %v ocamlgraph))))现在我们想使用dune build @fmt。问题是,ocamlformat不能识别尚未预处理的文件。一种解决方法是将受影响的文件添加到.ocamlformat-ignore中,但该文件相当大,因此没有自动格式化它将是一种遗憾。
这个问题有没有简单的解决方案?也许有一个共同的模式可以用沙丘来解决这个问题?
发布于 2021-01-23 18:11:06
从技术上讲,不是一个答案,但有几个线索:
,
dom.ml中,并放弃格式化这个文件,因为这个文件可能会很小。我知道这并不理想。https://stackoverflow.com/questions/65854619
复制相似问题