123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113(************************************************************************)(* * 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 *)(************************************************************************)(* Init options for coq *)typeasync_flags={enable_async:stringoption;deep_edits:bool;async_workers:int;}typecoq_opts={(* callback to handle async feedback *)fb_handler:Feedback.feedback->unit;(* callback to load cma/cmo files *)ml_load:(string->unit)option;(* Enable Coq Debug mode *)debug:bool;}(**************************************************************************)(* Low-level, internal Coq initialization *)(**************************************************************************)letcoq_initopts=ifopts.debugthenbeginBacktrace.record_backtracetrue;Flags.debug:=true;end;letload_obj=Sertop_loader.plugin_handleropts.ml_loadin(* XXX: We may not have to set path once the issue in Coq upstream is fixed. *)letadd_dir=Sertop_loader.add_ml_pathin(* Custom toplevel is used for bytecode-to-js dynlink *)letser_mltop:Mltop.toplevel=letopenMltopin{load_obj(* We ignore all the other operations for now. *);use_file=(fun_->());add_dir;ml_loop=(fun_->())}inMltop.set_topser_mltop;(* Core Coq initialization *)Lib.init();(* This should be configurable somehow. *)Global.set_engagementDeclarations.PredicativeSet;Global.set_indices_matterfalse;(**************************************************************************)(* Feedback setup *)(**************************************************************************)(* Initialize logging. *)ignore(Feedback.add_feederopts.fb_handler);(**************************************************************************)(* Start the STM!! *)(**************************************************************************)Stm.init_core();(* End of initialization *)()(******************************************************************************)(* Async setup *)(******************************************************************************)(* Set async flags; IMPORTANT, this has to happen before STM.init () ! *)letprocess_stm_flagsopts=Option.cata(funcoqtop->(* Whether to forward Glob output to the IDE. *)letdump_opt="-no-glob"inletopenStm.AsyncOptsinletopts={default_optswithasync_proofs_mode=APon;(* Imitate CoqIDE *)async_proofs_never_reopen_branch=notopts.deep_edits;async_proofs_n_workers=opts.async_workers;async_proofs_n_tacworkers=opts.async_workers;}in(* async_proofs_worker_priority); *)AsyncTaskQueue.async_proofs_flags_for_workers:=[dump_opt];CoqworkmgrApi.(initHigh);(* Uh! XXXX *)fori=0toArray.lengthSys.argv-1doArray.setSys.argvi"-m"done;Array.setSys.argv0coqtop;opts)Stm.AsyncOpts.default_optsopts.enable_async