1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495(************************************************************************)(* * 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) *)(************************************************************************)modulePath=structtypet=stringletrelative=Filename.concatletto_stringx=xletexistsx=Sys.file_existsxend(* For now just a pointer to coq/lib (for .vo) and coq-core/lib (for plugins) *)typet={core:Path.t;lib:Path.t}(* fatal error *)letfail_msg="cannot guess a path for Coq libraries; please use -coqlib option \
or ensure you have installed the package containing Coq's stdlib (coq-stdlib in OPAM) \
If you intend to use Coq without a standard library, the -boot -noinit options must be used."letfails=Format.eprintf"%s@\n%!"fail_msg;exit1(* This code needs to be refactored, for now it is just what used to be in envvars *)letguess_coqlib()=Util.getenv_else"COQLIB"(fun()->letprelude="theories/Init/Prelude.vo"inUtil.check_file_else~dir:Coq_config.coqlibsuffix~file:prelude(fun()->ifSys.file_exists(Filename.concatCoq_config.coqlibprelude)thenCoq_config.coqlibelsefail()))(* Build layout uses coqlib = coqcorelib *)letguess_coqcoreliblib=ifSys.file_exists(Path.relativelib"plugins")thenlibelsePath.relativelib"../coq-core"(* Should we fail on double initialization? That seems a way to avoid
mis-use for example when we pass command line arguments *)letinit()=letlib=guess_coqlib()inletcore=Util.getenv_else"COQCORELIB"(fun()->guess_coqcoreliblib)in{core;lib}letinit()=let{core;lib}=init()in(* debug *)iffalsethenFormat.eprintf"core = %s@\n lib = %s@\n%!"corelib;{core;lib}letenv_ref=refNoneletinit()=match!env_refwith|None->letenv=init()inenv_ref:=Someenv;env|Someenv->envletset_coqliblib=letenv={lib;core=guess_coqcoreliblib}inenv_ref:=Someenvletcoqlib{lib;_}=libletcorelib{core;_}=coreletplugins{core;_}=Path.relativecore"plugins"letstdlib{lib;_}=Path.relativelib"theories"letuser_contrib{lib;_}=Path.relativelib"user-contrib"lettool{core;_}tool=Path.(relative(relativecore"tools")tool)letrevision{core;_}=Path.relativecore"revision"letnative_cmi{core;_}lib=letinstall_path=Path.relativecorelibinifSys.file_existsinstall_paththeninstall_pathelse(* Dune build layout, we need to improve this *)letobj_dir=Format.asprintf".%s.objs"libinFilename.(concat(concat(concatcorelib)obj_dir)"byte")