使用ocp-build是否可以执行以下操作:
到目前为止,我试过这个:
(generator.ocp)
begin library "error_gen"
sort = true
files = [ "error_gen.ml" ]
requires = [str]
end
(generated.ocp)
begin library "error_code"
sort = true
files = [
"error_code.ml" (
pp = [ "./_obuild/error_gen/error_gen.byte" ]
pp_requires = [ "error_gen:byte" ]
)
]
requires = ["error_gen"]
end
(和main.ocp)
begin program "main"
sort = true
files = []
requires = ["error_code" "parser"]
end
它抱怨这条消息:
错误:在项目“error_code”中,源文件名 “src / generated / error_code.ml”不存在
我看到版本文件生成存在一些支持,例如在项目ocp-indent
中第46行。
"indentVersion.ml" (ocp2ml) (* auto-generated by ocp-build *)
非常感谢,谢谢。
答案 0 :(得分:1)
在github.com/OCamlPro/ocp-build的分支“next”中,你会发现一个可能解决你的问题的ocp-build版本:
begin library "error_code"
sort = true
files = [ "error_code.ml" ]
build_rules = [
"error_code.ml" (
(* the files that are needed to call the command *)
sources = [ "%{error_gen_FULL_DST_DIR}%/error_gen.byte" ]
(* the commands to be executed, in the sub-directory of the library
each command has the syntax: { "COMMAND" "ARG1" "ARG2" ... }
*)
commands = [
{ "%{error_gen_FULL_DST_DIR}%/error_gen.byte" }
]
)
]
requires = ["error_gen"]
end
例如,这在wxOCaml:
中使用https://github.com/OCamlPro/ocplib-wxOCaml/blob/next-ocpbuild/configure.ocp
命令可以使用选项进行后期修复:
{ "configure" } (chdir = "subdirectory") (* to execute in a sub-directory *)
{ "cat" "toto" } (stdout = "new_toto") (* to copy the stdout in "new_toto" *)