12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970(************************************************************************)(* * 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 *)|"firstorder_plugin"(* firstorder *)|"funind_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()with|Dynlink.Errorerrasexn->letmsg=Dynlink.error_messageerrinFormat.eprintf"[sertop] Critical Dynlink error %s@\n%!"msg;raiseexn|Fl_package_base.No_such_package(pkg,_)asexn->Format.eprintf"[sertop] Couldn't find the SerAPI plugin %s@; please check `ocamlfind list` does include SerAPI's plugin libraries.\n%!"pkg;raiseexn