123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126(************************************************************************)(* * 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) *)(************************************************************************)typet={boot:bool;coqlib:stringoption;sort:bool;vos:bool;noglob:bool;ml_path:stringlist;vo_path:(bool*string*string)list;dyndep:string;worker:stringoption;files:stringlist}letmake()={boot=false;coqlib=None;sort=false;vos=false;noglob=false;ml_path=[];vo_path=[];dyndep="both";worker=None;files=[]}letwarn_unknown_option=CWarnings.create~name:"unknown-option"Pp.(funopt->str"Unknown option \""++stropt++str"\".")letusage()=letopenPrintfineprintf" usage: rocq dep [options] <filename>+\n";eprintf" options:\n";eprintf" -boot : For rocq developers, prints dependencies over rocq library files (omitted by default).\n";eprintf" -sort : output the given file name ordered by dependencies\n";eprintf" -noglob | -no-glob : \n";eprintf" -noinit : currently no effect\n";eprintf" -f file : read -I, -Q, -R and filenames from _CoqProject-formatted file.\n";eprintf" -I dir : add (non recursively) dir to ocaml path\n";eprintf" -R dir logname : add and import dir recursively to rocq load path under logical name logname\n";eprintf" -Q dir logname : add (recursively) and open (non recursively) dir to rocq load path under logical name logname\n";eprintf" -vos : also output dependencies about .vos files\n";eprintf" -exclude-dir dir : skip subdirectories named 'dir' during -R/-Q search\n";eprintf" -coqlib dir : set the rocq core library directory\n";eprintf" -dyndep (opt|byte|both|no|var) : set how dependencies over ML modules are printed\n";eprintf" -worker WORKER : output WORKER instead of the rocqworker path\n";eprintf" -w (w1,..,wn) : configure display of warnings\n";eprintf"%!";(* flush *)exit1letwarn_project_file=letcategory=CWarnings.CoreCategories.filesysteminCWarnings.create~name:"project-file"~categoryPp.strletadd_ml_pathstf={stwithml_path=f::st.ml_path}letadd_vo_pathst(isr,path,logic)=letlogic=ifString.equallogic"Coq"then"Corelib"elselogicin{stwithvo_path=(isr,path,logic)::st.vo_path}letadd_filestf={stwithfiles=f::st.files}letadd_from_coqprojectstf=letopenCoqProject_fileinletfold_sourcedfaccl=List.fold_left(funacc{thing}->faccthing)acclinletproject=tryread_project_file~warning_fn:warn_project_filefwith|Parsing_errormsg->Error.cannot_parse_project_filefmsg|UnableToOpenProjectFilemsg->Error.cannot_open_project_filemsginletst=fold_sourced(funst{path}->add_ml_pathstpath)stproject.ml_includesinletst=fold_sourced(funst({path},l)->add_vo_pathst(false,path,l))stproject.q_includesinletst=fold_sourced(funst({path},l)->add_vo_pathst(true,path,l))stproject.r_includesinletst=fold_sourcedadd_filest(all_filesproject)instletparsestargs=letrecparsest=function|"-boot"::ll->parse{stwithboot=true}ll|"-sort"::ll->parse{stwithsort=true}ll|"-vos"::ll->parse{stwithvos=true}ll|("-noglob"|"-no-glob")::ll->parse{stwithnoglob=true}ll|"-noinit"::ll->(* do nothing *)parsestll|"-f"::f::ll->parse(add_from_coqprojectstf)ll|"-I"::r::ll->parse(add_ml_pathstr)ll|"-I"::[]->usage()|"-R"::r::ln::ll->parse(add_vo_pathst(true,r,ln))ll|"-Q"::r::ln::ll->parse(add_vo_pathst(false,r,ln))ll|("-Q"|"-R")::([]|[_])->usage()|"-exclude-dir"::r::ll->System.exclude_directoryr;parsestll|"-exclude-dir"::[]->usage()|"-coqlib"::r::ll->parse{stwithcoqlib=Somer}ll|"-coqlib"::[]->usage()|"-dyndep"::dyndep::ll->parse{stwithdyndep}ll|"-worker"::w::ll->parse{stwithworker=Somew}ll|"-w"::w::ll->letw=ifw="none"thenwelseCWarnings.get_flags()^","^winCWarnings.set_flagsw;parsestll|("-h"|"--help"|"-help")::_->usage()|opt::llwhenString.lengthopt>0&&opt.[0]='-'->warn_unknown_optionopt;parsestll|f::ll->parse(add_filestf)ll|[]->stinletst=parsestargsin{stwithml_path=List.revst.ml_path;vo_path=List.revst.vo_path;files=List.revst.files}