123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183(************************************************************************)(* * The Rocq Prover / The Rocq 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) *)(************************************************************************)letfatal_errorexn=Topfmt.(in_phase~phase:ParsingCommandLineprint_err_exnexn);letexit_code=if(CErrors.is_anomalyexn)then129else1inexitexit_codeletset_worker_idopts=assert(s<>"master");Flags.async_proofs_worker_id:=sletget_host_portopts=matchString.split_on_char':'swith|[host;portr;portw]->Some(Spawned.Socket(host,int_of_stringportr,int_of_stringportw))|["stdfds"]->SomeSpawned.AnonPipe|_->Coqargs.error_wrong_arg("Error: host:portr:portw or stdfds expected after option "^opt)letget_error_resilienceopt=function|"on"|"all"|"yes"->Stm.AsyncOpts.FAll|"off"|"no"->Stm.AsyncOpts.FNone|s->Stm.AsyncOpts.FOnly(String.split_on_char','s)letget_priorityopts=tryCoqworkmgrApi.priority_of_stringswithInvalid_argument_->Coqargs.error_wrong_arg("Error: low/high expected after "^opt)letget_async_proofs_modeopt=letopenStm.AsyncOptsinfunction|"no"|"off"->APoff|"yes"|"on"->APon|"lazy"->APonLazy|_->Coqargs.error_wrong_arg("Error: on/off/lazy expected after "^opt)letget_cacheopt=function|"force"->SomeStm.AsyncOpts.Force|_->Coqargs.error_wrong_arg("Error: force expected after "^opt)letspawn_args(opts:Coqargs.t)=(* Coqargs whose effect is not in the summary and matters for workers:
Flags.output_directory
Flags.test_mode
native output dir, native includes
Coqargs whose effect is used before the summary is installed and matter for workers:
-I, -boot
and we force -q -noinit otherwise the worker will try to require the
rcfile and prelude before receiving the summary
AFAICT that's all *)letoutput_dir=matchopts.config.output_directorywith|None->[]|Somedir->["-output-directory";dir]inlettest_mode=ifopts.config.test_modethen["-test-mode"]else[]inletnative_output=["-native-output-dir";opts.config.native_output_dir]inletnative_includeni=["-nI";ni]inletnative_includes=CList.concat_mapnative_includeopts.config.native_include_dirsinletml_includei=["-I";i]inletml_includes=CList.concat_mapml_includeopts.pre.ml_includesinletboot=ifopts.pre.bootthen["-boot"]else[]inList.concat[output_dir;test_mode;native_output;native_includes;ml_includes;boot;["-q";"-noinit"]]letparse_argsoptsarglist:Stm.AsyncOpts.stm_opt*stringlist=letinit=Stm.AsyncOpts.default_opts~spawn_args:(spawn_argsopts)inletargs=refarglistinletextras=ref[]inletrecparseoval=match!argswith|[]->(oval,List.rev!extras)|opt::rem->args:=rem;letnext()=match!argswith|x::rem->args:=rem;x|[]->Coqargs.error_missing_argoptinletnoval=beginmatchoptwith|"-async-proofs"->{ovalwithStm.AsyncOpts.async_proofs_mode=get_async_proofs_modeopt(next())}|"-async-proofs-j"->{ovalwithStm.AsyncOpts.async_proofs_n_workers=(Coqargs.get_int~opt(next()))}|"-async-proofs-cache"->{ovalwithStm.AsyncOpts.async_proofs_cache=get_cacheopt(next())}|"-async-proofs-tac-j"->letj=Coqargs.get_int~opt(next())inifj<0thenbeginCoqargs.error_wrong_arg("Error: -async-proofs-tac-j only accepts values greater than or equal to 0")end;{ovalwithStm.AsyncOpts.async_proofs_n_tacworkers=j}|"-async-proofs-worker-priority"->{ovalwithStm.AsyncOpts.async_proofs_worker_priority=get_priorityopt(next())}|"-async-proofs-private-flags"->{ovalwithStm.AsyncOpts.async_proofs_private_flags=Some(next());}|"-async-proofs-tactic-error-resilience"->{ovalwithStm.AsyncOpts.async_proofs_tac_error_resilience=get_error_resilienceopt(next())}|"-async-proofs-command-error-resilience"->{ovalwithStm.AsyncOpts.async_proofs_cmd_error_resilience=Coqargs.get_bool~opt(next())}|"-async-proofs-delegation-threshold"->{ovalwithStm.AsyncOpts.async_proofs_delegation_threshold=Coqargs.get_float~opt(next())}|"-worker-id"->set_worker_idopt(next());oval|"-main-channel"->letch=next()inSpawned.main_channel:=get_host_portoptch;{ovalwithspawn_args=opt::ch::oval.spawn_args}|"-control-channel"->letch=next()inSpawned.control_channel:=get_host_portoptch;{ovalwithspawn_args=opt::ch::oval.spawn_args}(* Options with zero arg *)|"-async-queries-always-delegate"|"-async-proofs-always-delegate"|"-async-proofs-never-reopen-branch"->{ovalwithStm.AsyncOpts.async_proofs_never_reopen_branch=true;spawn_args=opt::oval.spawn_args;}|"-stm-debug"->Stm.stm_debug:=true;{ovalwithspawn_args=opt::oval.spawn_args}(* Unknown option *)|s->extras:=s::!extras;ovalendinparsenovalintryparseinitwithany->fatal_erroranyletusage="\
\n -stm-debug STM debug mode (will trace every transaction)\
"