123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* 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) *)(************************************************************************)(************************************************************************)(* SerAPI: Coq interaction protocol with bidirectional serialization *)(************************************************************************)(* Copyright 2016-2019 MINES ParisTech -- License LGPL 2.1+ *)(* Copyright 2019-2023 Inria -- License LGPL 2.1+ *)(* Written by: Emilio J. Gallego Arias and others *)(************************************************************************)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