1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374(************************************************************************)(* * 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=falseletlist_lastl=List.(nthl(lengthl-1))(* Should improve *)letmap_serlibfl_pkg=letsupported=matchfl_pkgwith(* Linked-in statically *)|"coq-core.plugins.ltac."->false(* | "tauto_plugin" -> false *)(* Supported *)|"coq-core.plugins.cc"(* cc *)|"coq-core.plugins.extraction"(* extraction *)|"coq-core.plugins.firstorder"(* firstorder *)|"coq-core.plugins.funind"(* funind *)|"coq-core.plugins.ltac2"(* ltac2 *)|"coq-core.plugins.micromega"(* micromega *)|"coq-core.plugins.ring"(* ring *)|"coq-core.plugins.ssreflect"(* ssreflect *)|"coq-core.plugins.ssrmatching"(* ssrmatching *)|"coq-core.plugins.number_string_notation"(* syntax *)|"coq-core.plugins.tauto"(* tauto *)|"coq-core.plugins.zify"(* zify *)->true|_->ifdebugthenFormat.eprintf"missing serlib: %s@\n%!"fl_pkg;falseinifsupportedthenletplugin_name=String.split_on_char'.'fl_pkg|>list_lastinSome("coq-serapi.serlib."^plugin_name)elseNoneletplugin_handleruser_handler=letloader=Option.default(Fl_dynload.load_packages~debug:false)user_handlerinfunfl_pkg->trylet_,fl_pkg=Mltop.PluginSpec.reprfl_pkgin(* In 8.10 with a Dune-built Coq Fl_dynload will track the dependencies *)matchmap_serlibfl_pkgwith|Someserlib_pkg->ifdebugthenFormat.eprintf"[plugin loader]: plugin %s requested via findlib@\n%!"fl_pkg;loader[serlib_pkg]|None->ifdebugthenFormat.eprintf"[plugin loader]: plugin %s requested via mltop@\n%!"fl_pkg;loader[fl_pkg]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