123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)(* <O___,, * (see CREDITS file for the list of authors) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)(************************************************************************)(* Coq serialization API/Plugin *)(* Copyright 2016-2019 MINES ParisTech *)(************************************************************************)(* Status: Very Experimental *)(************************************************************************)letdebug=falseletml_path=ref[]letadd_ml_pathpath=ml_path:=path::!ml_path(* Should improve *)letmap_serlibml_mod=letplugin_name=Filename.(remove_extension(basenameml_mod))inletsupported=matchplugin_namewith(* Linked-in statically *)|"ltac_plugin"->false(* | "tauto_plugin" -> false *)(* Supported *)|"ground_plugin"(* firstorder *)|"recdef_plugin"(* funind *)|"ring_plugin"(* setoid_ring *)|"extraction_plugin"(* setoid_ring *)|"ssrmatching_plugin"(* ssrmatching *)|"ssreflect_plugin"(* ssr *)->true|_->ifdebugthenFormat.eprintf"missing serlib: %s@\n%!"ml_mod;falseinifsupportedthenSome("coq-serapi.serlib."^plugin_name)elseNoneletplugin_handleruser_handler=letloader=Option.defaultDynlink.loadfileuser_handlerinfunml_mod->try(* In 8.10 with a Dune-built Coq Fl_dynload will track the dependencies *)matchmap_serlibml_modwith|Someserlib_pkg->ifdebugthenFormat.eprintf"[plugin loader]: module %s requested via findlib@\n%!"ml_mod;Fl_dynload.load_packages[serlib_pkg]|None->ifdebugthenFormat.eprintf"[plugin loader]: module %s requested via mltop@\n%!"ml_mod;let_,ml_file=System.find_file_in_path~warn:true!ml_pathml_modinlet()=loaderml_filein()withDynlink.Errorerr->letmsg=Dynlink.error_messageerrinFormat.eprintf"[sertop] Critical Dynlink error %s@\n%!"msg