-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[coq] [draft] Support for coqffi
#4007
Conversation
Co-authored-by: Thomas Letan <thomas.letan@ssi.gouv.fr> Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Co-authored-by: Thomas Letan <thomas.letan@ssi.gouv.fr> Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Co-authored-by: Thomas Letan <thomas.letan@ssi.gouv.fr> Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
We are missing how to access the right cmi file name. Co-authored-by: Thomas Letan <thomas.letan@ssi.gouv.fr> Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
src/dune_rules/coq_rules.ml
Outdated
(* Get the path to the cmi file *) | ||
(* We need help here! The below fails with wrong dune *) | ||
let expand_expr = String_with_vars.make_var Loc.none ~payload:ml_lib_name "cmi" in | ||
let cmi_path = Expander.expand_path expander expand_expr in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work, we also tried:
let cmi_path =
let open Result.O in
let* ml_lib = Lib.DB.resolve lib_db (Loc.none, Lib_name.of_string ml_lib_name) in
let info = Lib.info ml_lib in
let obj_dir = Obj_dir.public_cmi_dir (Lib_info.obj_dir info) in
Result.Ok (Path.relative obj_dir (coq_module_name ^ ".cmi"))
which works but it doesn't compute the right cmi path for wrapped libs.
This is broken for external libs, but maybe it is not too far from the right path. Co-authored-by: Thomas Letan <thomas.letan@ssi.gouv.fr> Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
Updated with a fresh attempt to locate a cmi path, but unfortunately it only works for local libs. |
This is already a pretty great improvement, congrats! |
Adding @rgrinberg 's comments on how to move forward with this:
|
Thanks @ejgallego (and @rgrinberg ) for the heads-up. I have tagged a first beta release for |
Hi @lthms , I'm closing this PR due to inactivity, but I'd love to reopen and finish it if you still find it useful. |
Yeah, sorry about that. I’ve been focused on other things. Yet, Thanks again a lot for taking the time to guide me the other time. |
Great to hear, looking forward to completing this, and to using coqffi |
This is a draft PR to support @lthms
coqffi
rules that allows for Coq to call OCaml libraries https://github.com/coq-community/coqffi . This has been written in collaboration with @lthms .As of today, we add a
(ffi_modules ...)
field to(coq.theory ...)
and the corresponding rules for.cmi
to.v
generation. This is a pretty small patch and highlights how to add a simple rule to Coq's mode.There are some open issues and todos before we can consider this ready:
(coq.theory ...)