What is the best way to do a coq_makefile-style validate with dune? Obviously, it is not currently supported but is there a way to write a rule or something?
ping @Emilio Jesús Gallego Arias
something like
(rule (alias validate)
(deps $all_vo_files$)
(action (run coqchk -some-Q %{deps}))
I guess
(for the right values of $all_vo_files$
and -some-Q
)
ah, but doesn't this cause the (in)famous coqchk
re-checking of everything in each call?
You mean because by default dune builds everything?
Karl Palmskog said:
ah, but doesn't this cause the (in)famous
coqchk
re-checking of everything in each call?
is that different from coq_makefile?
but coq_makefile
builds artifacts that are not built twice
since there are no corresponding files generated by coqchk
, it does work from ground up for every file, right?
coqchk doesn't build artifacts
Validate runs on the whole project both above and in coq_makefile
But only when you call the appropriate target
for example, say that you have a dependency chain:
lib.v
-> A.v
-> Top.v
.
Then calling coqchk
on lib.vo
and A.vo
would be redundant if you do coqchk Top.vo
. I believe Emilio has suggested one should generate lib.ok
and A.ok
or something to avoid this.
the pseudo rule I posted and coq_makefile just do 1 call coqchk lib.vo A.vo Top.vo
so no redundancy
you can't trust a .ok file anyway
there’s an option to change this, but by default coqchk
rechecks proof terms for your project _and its dependencies_ (including the stdlib), so you run it once on everything, and you rerun it if anything changes.
well, you can trust it if you generate it yourself
(so the rerunning is not so frequent)
you’re probably thinking more of the -non-rec
option (or whatever it’s called) which trusts proof terms from dependencies?
OK that seemed to work
I'm depending on my vo files like this: (deps (glob_files *.vo))
Is there a better way to do this?
Can I just tell dune to look for vo files that come from src?
vo files that come from src
glob_files src/*.vo
?
if you have subdirectories take care as glob_files doesn't recurse
I have quite a few subdirectories
then you need quite a few globs
glob_files recurse but not sure if only in 3.0
is called glob_files_rec, note that what Gaëtan wrote is incremental still, the alias will be considered up to date [if the exit code was fine] until the deps change
Can't find anything in the refman about glob_files_rec I'm guessing that is new
I'm confused tho, I would have thought (deps (glob_files src/**/*.vo))
would work but it doesn't seem to
Also glob_files src/*.vo
doesn't seem to do anything either
Ali Caglayan said:
I'm confused tho, I would have thought
(deps (glob_files src/**/*.vo))
would work but it doesn't seem to
anything before the last / is taken as a literal path
probably you don't have a src/**
directory
Seems to be 3.0 only ? https://dune.readthedocs.io/en/latest/concepts.html#glob
There is a very unfortunate issue with the Dune manual https://github.com/ocaml/dune/issues/4982
Yes, (glob_files ...)
is a bit strange, in the sense it only understands a single directory
OK let me start over then
I have a src directory
with multiple .v files deeply populated in there
Dune had at first a few limitations like rules can only output over one directory, etc... that was due the way the incremental domain were setup, devs are slowly lifting these limitations
I have a dune file in src which I want to add a rule for coqchk to
(rule (alias validate)
(deps (glob_files *.vo))
(action (run coqchk -R . LogiCoq %{deps} -o))
)
works but checks a lot of stdlib too
See _build/log
but indeed I guess that's specific to coqchk?
also a single rule per .vo may be better
if you don't update all the .vo's at once
I am busy this week, but if someone would like to add (validate)
to (coq.theory) I'd happy to help
in fact, we don't even need to add validate, just generate the rules
so people can do dune build @dir/coqchk
or whatever we want to call that, I don't think setting up the rules is so expensive
yeah just update the core rule for .vo
in coq_rules.ml , and add a rule to call coqchk, with an alias as a way to trigger it
aliases play the role of virtual targets, so they are used for the cases that a rule produces no targets, like tests indeed
if you produce a target then no need to use an alias, you can always trigger the rule by the target
without -norec
(fixed), calls to coqchk
are IIRC virtually constant-time, so per-file rules don’t seem so convenient in that mode…
but just to be clear, if you don't pass -norec
, then every time dependencies change, you have to recheck all of Stdlib that you use, even with Gaëtan's Dune rule, right?
indeed. And -norec
is harder to use than I thought: it takes a module name and does not seem to accept wildcards, so “no stdlib” or “only this project” seems hard to express?
Last updated: Oct 13 2024 at 01:02 UTC