在COQ项目中安装外部依赖项的最佳实践是什么?

发布于 2025-02-07 00:04:42 字数 4385 浏览 2 评论 0原文

我了解我认为是官方利用的本质doc https://coq.inria.fr/refman/refman/practical-tools/utilities.html#building-a-coq-project

  • 一个人创建a _coqproject,并用参数为COQC和要编译的文件名(希望以依赖关系的顺序),
  • 然​​后使用coq_makefile -f _coqproject -o coqmakefile进行自动coqmakefile
  • 然后使用他们的建议makefile运行自动生成的make文件。

但是,如果我们需要其他依赖项,它就不会说如何安装它们(或卸载)。这样做的标准方法是什么?

我的猜测是,一个人可能会在makefile结束时添加目标,并执行某种opam install

例如,

# KNOWNTARGETS will not be passed along to CoqMakefile
KNOWNTARGETS := CoqMakefile
# KNOWNFILES will not get implicit targets from the final rule, and so
# depending on them won't invoke the submake. TODO: Not sure what this means
# Warning: These files get declared as PHONY, so any targets depending
# on them always get rebuilt -- or better said, any rules which those names will have their cmds be re-ran (which is
# usually rebuilding functions since that is what make files are for)
KNOWNFILES := Makefile _CoqProject

# Runs invoke-coqmakefile rule if you do run make by itself. Sets the default goal to be used if no targets were specified on the command line.
.DEFAULT_GOAL := invoke-coqmakefile

# Depends on two files to run this, itself and our _CoqProject
CoqMakefile: Makefile _CoqProject
    $(COQBIN)coq_makefile -f _CoqProject -o CoqMakefile

# Note make knows what is the make file in this case thanks to -f CoqMakefile
invoke-coqmakefile: CoqMakefile install_external_dependencies
    $(MAKE) --no-print-directory -f CoqMakefile $(filter-out $(KNOWNTARGETS),$(MAKECMDGOALS))

#
.PHONY: invoke-coqmakefile $(KNOWNFILES)

####################################################################
##                      Your targets here                         ##
####################################################################

# This should be the last rule, to handle any targets not declared above
%: invoke-coqmakefile
    @true

# I know this is not a good coq dependency example but just to make it concrete wrote some opam command
install_external_dependencies:
    opam install coq-serapi

我认为我在正确的位置编写了install_external_depentencies,但我不确定。那是对的吗?有人有一个真实的例子吗?

For all the code see: https://github. com/brando90/ultimate-utils/tree/master/tutorials_for_myself/my_makefile_playground/beginner_coq_project_project_with_makefiles/debug_proj

相关:有关:建立Coq Project of Coq Project of Coq Project of Coq Project的官方培训问题官方的位置到学习者 - 直接coq-coq-make-files-for-beginner/1682“ rel =” nofollow noreferrer“> https://coq.discourse.group/t/official-place-place-place-place-to-to - 浏览 - 固定 - coq-coq-make-for-for-beginner/1682


btw, 我还不了解Makefile中的最后一个。

# This should be the last rule, to handle any targets not declared above
%: invoke-coqmakefile
    @true

IE

  • %true在Make File模板COQ中给了我们。
  • %以规则的名义。
  • 那条线做什么?

更新

我正在寻求一个端到端的小型演示,以了解如何使用_COQPROJECTcoq_makefile使用_coqproject coq_makefile ,如UTISITION doc doc doc a href =“ https://coq.inria.fr/refman/practical-tools/utilities.html” rel =“ nofollow noreferrer”> https://coq.inria.fr/refman/practical-tractical-toolsials/practical-toolsions.htmls.html 。理想的答案将包含一个单个脚本,以一次安装和编译所有内容 - 例如install_project_name.sh中。包括OPAM开关等。


相关:

I understand what I believe is the essence of the official utilties doc https://coq.inria.fr/refman/practical-tools/utilities.html#building-a-coq-project:

  • one creates a _CoqProject with arguments to coqc and the file names to compile (hopefully in an order that takes into account dependencies)
  • then one make an automatic CoqMakefile with coq_makefile -f _CoqProject -o CoqMakefile
  • Then you use their recommended Makefile to run the automatically generated make file.

But then if we need other dependencies, it doesn't say how to install them (or uninstall) them. What is the standard way to do that?

My guess is that one likely adds a target to your Makefile at the end of it and do some sort of opam install?

e.g.

# KNOWNTARGETS will not be passed along to CoqMakefile
KNOWNTARGETS := CoqMakefile
# KNOWNFILES will not get implicit targets from the final rule, and so
# depending on them won't invoke the submake. TODO: Not sure what this means
# Warning: These files get declared as PHONY, so any targets depending
# on them always get rebuilt -- or better said, any rules which those names will have their cmds be re-ran (which is
# usually rebuilding functions since that is what make files are for)
KNOWNFILES := Makefile _CoqProject

# Runs invoke-coqmakefile rule if you do run make by itself. Sets the default goal to be used if no targets were specified on the command line.
.DEFAULT_GOAL := invoke-coqmakefile

# Depends on two files to run this, itself and our _CoqProject
CoqMakefile: Makefile _CoqProject
    $(COQBIN)coq_makefile -f _CoqProject -o CoqMakefile

# Note make knows what is the make file in this case thanks to -f CoqMakefile
invoke-coqmakefile: CoqMakefile install_external_dependencies
    $(MAKE) --no-print-directory -f CoqMakefile $(filter-out $(KNOWNTARGETS),$(MAKECMDGOALS))

#
.PHONY: invoke-coqmakefile $(KNOWNFILES)

####################################################################
##                      Your targets here                         ##
####################################################################

# This should be the last rule, to handle any targets not declared above
%: invoke-coqmakefile
    @true

# I know this is not a good coq dependency example but just to make it concrete wrote some opam command
install_external_dependencies:
    opam install coq-serapi

I think I wrote the install_external_dependencies in the right place but I'm not sure. Is that correct? Anyone has a real example?

For all the code see: https://github.com/brando90/ultimate-utils/tree/master/tutorials_for_myself/my_makefile_playground/beginner_coq_project_with_makefiles/debug_proj

related: question on official tutorial for building coq projects https://coq.discourse.group/t/official-place-to-learn-how-to-setup-coq-make-files-for-beginner/1682


Btw,
I don't understand the last like in the makefile yet.

# This should be the last rule, to handle any targets not declared above
%: invoke-coqmakefile
    @true

i.e.

  • %true in the make file template coq gave us.
  • % in the name of the rule.
  • What does that line do?

Update

I'm seeking an end-to-end small demo of how to install all dependencies with whatever the recommended approach when using _CoqProject and coq_makefile as shown in the utilities doc https://coq.inria.fr/refman/practical-tools/utilities.html. The ideal answer would contain a single script to install and compile everything in one go -- say in a install_project_name.sh. Including opam switches etc.


Related:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨与橙与城 2025-02-14 00:04:42

最简单的设置是用OPAM手动安装外部依赖关系。

opam install packages-needed-by-my-project

然后,他们将立即可以建立您自己的项目。

组织的下一个级别是打包您的项目。请参阅以下COQ社区资源:

与您的问题立即相关的主要内容是拥有*。在项目根部的文件列出了其依赖项(可能具有版本要求)。然后,您可以使用OPAM安装安装它们。 - 只能Deps-


您问题的MakeFile部分是关于无缝传递选项的过度工程,以coqmakefile。我不确定它是如何工作的,但无论如何都不重要,尤其是因为Dune已成为COQ项目推荐的构建系统。

The simplest setup is to install external dependencies manually with opam.

opam install packages-needed-by-my-project

Then they will be immediately available to build your own project.

The next level of organization is to package up your project. Refer to the following Coq community resources:

The main thing immediately relevant to your question is to have a *.opam file at the root of your project which lists its dependencies (possibly with version requirements). Then you can install them using opam install . --deps-only.


The Makefile part of your question is about a bit of overengineering for passing options seamlessly to CoqMakefile. I'm not sure how it works off-hand, but it's not important anyway, especially because Dune is superseding make as the recommended build system for Coq project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文