【问题标题】:Copying a newly builded file as a Dune's stanza将新建的文件复制为沙丘的节
【发布时间】:2021-06-23 23:09:38
【问题描述】:

我在 OCaml 中编写了一个库,其所有源代码都位于 lib 文件夹中。 我还在bin 文件夹中准备了“外观”可执行文件。 现在我想准备一些如何使用上述可执行文件的示例。 为此,我需要事先复制一个可执行文件,或者(最好)告诉 Dune 在构建后使用新创建的一个。

这是我的问题。 Dune 的copy_files 节不允许1我从_build 文件夹复制。 是否有任何其他方法可以在每次构建后使用新的可执行文件,或者我是否需要在某个时候复制它们并保持最新?

以下是项目的结构(以防口头描述有任何误导)。

root
   lib <- source
   bin <- frontend for source
   examples <- how to use the above frontend

1 不允许我指的是本节的以下用法: ( copy_files %{project_root}/_build/default/bin/program.exe )

【问题讨论】:

标签: ocaml copying ocaml-dune


【解决方案1】:

@Lhooq 建议的解决方案可能是使用带有--root 参数的dune exec 命令。

关于提供的场景,如果我们制作一个脚本:

   dune exec --root=../.. ./bin/some_program.exe 
(* 
   Where 'some_program' is the name of an .ml file located in bin folder.
   I assumed here that the program is compiled to native code, not to bytecode (hence the .exe).
*)

并将其放在examples 目录中,然后通过调用它,我们将实际运行位于bin 文件夹中的some_program.ml 中定义的程序的最新版本。

为了清楚起见:bin 文件夹不包含任何已编译的文件(.exe 和 .bc)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多