1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283(************************************************************************)(* * 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) *)(************************************************************************)openUtilopenPplet(/)s1s2=Filename.concats1s2(* Recursively puts `.v` files in the LoadPath *)letbuild_stdlib_vo_path~unix_path~coq_path=letopenLoadpathin{unix_path;coq_path;has_ml=false;implicit=true;recursive=true}(* Note we don't use has_ml=true due to #12771 , we need to see if we
should just remove that option *)letbuild_userlib_path~unix_path=letopenLoadpathinifSys.file_existsunix_paththenletml_path=System.all_subdirs~unix_path|>List.mapfstinletvo_path={unix_path;coq_path=Libnames.default_root_prefix;has_ml=false;implicit=false;recursive=true}inml_path,[vo_path]else[],[](* LoadPath for Coq user libraries *)letinit_load_path~coqlib=letopenLoadpathinletuser_contrib=coqlib/"user-contrib"inletxdg_dirs=Envars.xdg_dirs~warn:(funx->Feedback.msg_warning(strx))inletcoqpath=Envars.coqpathinletcoq_path=Names.DirPath.make[Libnames.coq_root]in(* ML includes *)letunix_path=(* Usually lib/coq-stdlib/../plugins ; this kind of hacks with the
ML path should go away once we use ocamlfind to load plugins *)CPath.choose_existing[CPath.make[coqlib;"plugins"];CPath.make[coqlib;"..";"coq-core";"plugins"]]|>function|None->CErrors.user_err(Pp.str"Cannot find plugins directory")|Somef->(f:>string)inletplugins_dirs=System.all_subdirs~unix_path|>List.mapfstinletcontrib_ml,contrib_vo=build_userlib_path~unix_path:user_contribinletmisc_ml,misc_vo=List.map(funs->build_userlib_path~unix_path:s)(xdg_dirs@coqpath)|>List.splitinletml_loadpath=plugins_dirs@contrib_ml@List.concatmisc_mlinletvo_loadpath=(* current directory (not recursively!) *)[{unix_path=".";coq_path=Libnames.default_root_prefix;implicit=false;has_ml=true;recursive=false}]@(* then standard library *)[build_stdlib_vo_path~unix_path:(coqlib/"theories")~coq_path]@(* then user-contrib *)contrib_vo@(* then directories in XDG_DATA_DIRS and XDG_DATA_HOME and COQPATH *)List.concatmisc_voinml_loadpath,vo_loadpath