12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152(************************************************************************)(* * 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) *)(************************************************************************)openNamesopenCErrorsletrecensure_only_one_path_containsfromfileacc=function|[]->beginmatchaccwith|Somex->x|None->user_errPp.(str"File "++strfile++str" not found in "++DirPath.printfrom++str".")end|x::xs->letabspath=x^"/"^fileinifSys.file_existsabspaththenbeginmatchaccwith|None->ensure_only_one_path_containsfromfile(Someabspath)xs|Someother->user_errPp.(str"File "++strfile++str" found twice in "++DirPath.printfrom++str":"++spc()++strother++str","++spc()++strabspath++str".")endelseensure_only_one_path_containsfromfileaccxsletextra_deps=Summary.ref~name:"extra_deps"Id.Map.emptyletbind_extra_dep?locpathid=matchId.Map.find_optid!extra_depswith|Some(other,loc)->user_errPp.(str"Extra dependency "++Id.printid++str" already bound to "++strother++pr_opt(funx->str" at "++Loc.prx)loc++str".")|None->extra_deps:=Id.Map.addid(path,loc)!extra_depsletdeclare_extra_dep?loc~from~fileid=matchLoadpath.find_with_logical_pathfromwith|_::_aspaths->letpaths=List.mapLoadpath.physicalpathsinletfile_path=ensure_only_one_path_containsfromfileNonepathsinOption.iter(bind_extra_dep?locfile_path)id|[]->user_errPp.(str"No LoadPath found for "++DirPath.printfrom++str".")letquery_extra_depid=fst@@Id.Map.findid!extra_deps