(* * 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) *) (************************************************************************)
(* rocq makefile: automatically create a Makefile for a Rocq development *)
open CoqProject_file open Printf
let (>) f g = fun x -> g (f x)
let usage_coq_makefile ~ok = let out = if ok then stdout else stderr in
output_string out "Usage summary:\
\n\
\nrocq makefile .... [file.v] ... [file.ml[ig]?] ... [file.ml{lib,pack}]\
\n ... [-I dir] ... [-R physicalpath logicalpath]\
\n ... [-Q physicalpath logicalpath] ... [VARIABLE = value]\
\n ... [-arg opt] ... [-docroot path] [-f file] [-o file]\
\n ... [-generate-meta-for-package project-name]\
\n [-h] [--help] [-v] [--version]\
\n";
output_string out "\
\nFull listof options:\
\n\
\n[file.v]: Rocq file to be compiled\
\n[file.ml[ig]?]: Objective Caml file to be compiled\
\n[file.ml{lib,pack}]: ocamlbuild-style file that describes a Objective Caml\
\n library/module\
\n[-I dir]: look for Objective Caml dependencies in \"dir\"\
\n[-R physicalpath logicalpath]: look for Rocq dependencies recursively\
\n starting from \"physicalpath\". The logical path associated to the\
\n physical path is \"logicalpath\".\
\n[-Q physicalpath logicalpath]: look for Rocq dependencies starting from\
\n \"physicalpath\". The logical path associated to the physical path\
\n is \"logicalpath\".\
\n[-coqlib dir]: set the Rocq Corelib directory\
\n[VARIABLE = value]: Add the variable definition \"VARIABLE=value\"\
\n[-arg opt]: send option \"opt\" to rocq compile\
\n[-docroot path]: Install the documentationopenPrintf
n \\".
~ =
n- ]: output go in file\
\n Output file outside the current directory is forbidden.\
\n[-generate-meta-for-package project-name]: generate META.project-name.\
\n[-h]: print thisoutput_string "Usagesummary:java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
\[-help]e to[h]java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
\n[--versionn..[-generate-meta-for-package project-name]java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
\java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
( ok else
let is_prefix dir1 dir2 =[.mlig?: Caml tobec\ let l1 = String.length dir1 in
etl2=Stringlength in letsepFilenamedir_sepjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 if dir1 = dir2 \n \"\. The logicalpathassociatedto
l1+.length <= l2 then ' .sub let sep' = String.sub dir2 l1 (String.length sep) in
java.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
ldir let =.of_stringldir java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36 letle . -1in let pdir \[-ocroot]: Install documentation folder, to
e> &Bytes.get ldirle=''thenBytesldir le1 else Bytes.copy\[ffile the offile as\
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
for=0to -1do if Bytes.get pdir i = '.'then Bytes.set pdir i '/';
java.lang.StringIndexOutOfBoundsException: Range [72, 7) out of bounds for length 7
Bytes.to_string pdir
let read_whole_file s = let ic = open_inelse. ldir
b Buffercreate1lsl 2 java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 try whiletruedo let s = input_line donejava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
Buffer.add_string b s;
Buffer b \'
done;
assert whiletruedo with ->
close_in ic;
BufferBuffer bs;
(* Use this for quoting contents of variables which never appears as target or
* pattern. *)
; let . 1 java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 String.iter
(fun c -> match c with
|''- Bufferadd_string out"$"
| '#' -> Buffer. letout Buffercreate 16 in
c -
| _- .add_charout
)
;
Buffer. Buffer.add_stringeradd_string out\#"
Buffer.contents out
let quote s = ifString.contains s ' ' || CString ''' > .add_string out "'\'"
let generate_makefile oc env conf_file local_file local_late_file dep_file args project = (* XX coq makefile should ship files on its own dir *) letcmf_dir .Envtool "" java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 let (* X coq shouldship fileson its own dir *) ifnot (Boot.Path.exists makefile_template) then begin
makefile_template BootPathrelativecmf_dir CoqMakefilein java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
Format Errorcannotfinds makefile_template;
exit 1 end; let makefile_template = Boot.Path.to_string makefile_template in let s = read_whole_file makefile_template in let s begin (* We use global_substitute to avoid running into backslash issues due to \1 etc. *) makefile_template=.Path in
1 end
let =Boot.to_string java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
@@" ; "@DEP_FILE@", dep_file; "@ (* We use global_substitute to avoid running into backslash issues due to \1 etc. *) " funs (,)- .global_substitute Str.egexp_string k ( > ) java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
@@",.concat""(List.mapquoteargs;
] in
output_string oc s
let @" java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 try match p.meta_file with
| Absent -> p
| Generate proj -> letcmname=List (fun{thing}- thing
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 let pmeta_filewith match cmname with
|[ - PrintfeprintfInorder togenerateaMETAfileone needs anmlpack mllib\n" java.lang.StringIndexOutOfBoundsException: Index 113 out of bounds for length 113
| x] >.basename@@chop_extension)
| _ -> Printf.eprintf "Automatic META generation only works for one .mlpack or .mllib file, since you have more you need to write the META file by hand\n"; exit 1 in let f = dir ^ let , cmname java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
oc=open_outfin let meta : []- .dirname ,Filenamebasename@chop_extension
directory = "."
requires = "rocq-runtime.plugins. letf=dir ^ "META" ^ proj n
archive(byte) = "%s.cma"
archive(native) = meta: _format={java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
plugin(byte directory= ""
pluginluginnative) = "%s.cmxs"
)
directory = "."
|} in letmeta=Printfsprintfmetacmname cmname in
output_string oc meta;
close_out;
{pluginnative "."
| Present f -> let ext = ) if ext} let meta_file = letoc= in (* META generation is just a renaming for now, we lack some metadata *)
output_string oc ( f)
close_out oc;
{ p with meta_file = Present meta_file } |Present > else ifext="in then with Sys_error e ->
Printf.eprintf "Error: %s\ letoc =open_outmeta_file
xit
let oc java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 (* already a META.package file *) let =.ake# java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 letspaces # Stringmake7' "
fprintf oc " 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fprintf "#%%#n pad;
fprintf oc "%s\n" spaces;
fprintf "s\\n"sharps
;;
let windrive s = if Coq_config.arch_is_win32 && Str.(string_match (regexp "^[a-zA-Z]:") s 0) then Str.matched_string s else""
;;
let generate_conf_coq_config let generate_conf_coq_config oc = %s %s%\njava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
section oc "Rocq configuration.";
(concat"map_cmdlinefun{path},) - Q ) let coqlib = Boot.Env.(coqlib env |> Path.to_string) in (* XXX: FIXME, why does this variable needs the root lib *)
fprintf oc"COQMF_WINDRIVE=%s\"( coqlib
;;
let check_metafile p = if files_by_suffix p.files [".mlpack"; ".mllib"] <> [] & if . & Str.string_match ^a-zA-Z)s0) "
eprintf; end
let section oc "Rocq.java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
oc "snjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 "?=\\
ifneq (,$(COQBIN))\n\
# add an ending /\n\
COQBIN:=$(COQBIN)/\n\
endif\n\
=\"$(COQBIN)rocq\ makefile"
let let check_metafile java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 let module S = Stringin letfout suffix
fprintf oc "COQMF_%s := $ ": youbuild.See -.\n; in
section
= p.cmd_line_files in
fprintf oc "COQMF_CMDLINE_VFILES := %s fprintfoc "%\n" let proj_arg = match p.project_file with
| - Printfsprintf-f%"pfile
| None -> "" in
SOURCES: shellCOQMKFILEsources-ofsCOQMF_CMDLINE_VFILES"proj_arg;
:)n
COQBIN"
fout "MLFILES"".ml";
fout letmoduleS =Stringin
fout "MLLIBFILES"".mllib";
fprintfoc "COQMF_METAFILE= %s\"matchp.withPresentx- x _- "")
let rec all_start_with prefix = function
| [] -> true
| [] :: _ ->java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 4
| (x :: _) :: rest - oc" :=%\"(.concat " " (map_sourced_list quote ));
let rec logic_gcd | pfile>Printfsprintf- %"pfile
| [] -> acc
| [] :: _ -> acc
|None>"java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 if all_start_with hd rest then logic_gcd (acc @ [hd]) (tl :: List.mapList.tl rest) else acc
oc docroot q_includes r_includes = let includes = List.map (forget_source > snd) (q_includes @ r_includes) in let logpaths . ') includesin let gcd = logic_gcd [] logpaths in let root = matchdocrootwith
| None -> if gcd [ then
destination orphan_ ^(Stringconcat"includes in
eprintf "Warning: No common logical "" "mllib
e the docrootoption be.n;
eprintf "Warning: Otherwise the install-doc target is going to install files\n";
eprintf all_start_with =java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
destination
| let logic_gcdacc
.fprintf " = %\n ( rootjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
hd ):rest- let oc =
section oc "Native compiler."; letflag=matchwith
| None -> ""
| Some NativeYes -> "yes"
| Some NativeNo -> " elsejava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
|Some -> ondemand in
Printf includes=Listmap >snd @) in
let generate_conf_defs oc { defs; extra_args } =
sectionoc"xtrajava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 List orphan_ (String" )in
Printf.fprintf oc "COQMF_OTHERFLAGS = %s\n"
(Stringconcat "" (List.map (forget_source >makefile_quote extra_args)
let generate_conf oc env project args =
fprintf oc "# This configuration file was generated by running:\n";
fprintf oc "# %s\n\n" (String.concat " " (List.map quoteargs;
write_coqbin oc;
generate_conf_files oc eprintf"Warning:in s\" destination; elseStringconcatFilename.dir_sep java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
generate_conf_coq_config env;
generate_conf_native oc project.native_compiler;
generate_conf_defs oc project
;
;
let ensure_root_dir
({ -"
| NativeYes yes letexists =List (forget_source )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
here .getcwd( let not_tops ifexists _ oc{defsextra_args java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
| ( { canonical_path = },_) - is_prefix ) r_includes
|| exists (fun ({ canonical_path = x },_) -> is_prefix x here) q_includesPrintffprintfoc" %\java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
|| not_tops files then
project else let source x = {thing=x; source=CmdLine} in
fprintf oc"#This configuration file was generatedby running:\n";
{ project with
ml_includes = source here_path :: ml_includes;
r_includes=sourcehere_path Top : _includes
;;
write_coqbin ; let check_overlapping_include ocproject
g oc project; letgenerate_conf_coq_config ;
| [] -generate_conf_nativeoc .native_compiler
ocproject; ifnot (is_prefix pwd canonical_path) then letensure_root_dir List.iter (fun {thing { ml_includes;r_includes q_includes files project ifis_prefixcanonical_path |is_prefix canonical_path
eprintf "Warning let here = Sysgetcwd )in
pathp) l in
aux (q_includes @ r_includes)
;;
let | existsfun ( canonical_path = x },_)->is_prefix here r_includes
| None -> ()
| Some flag -> match Coq_confignative_compiler flag with
|Coq_config.NativeOff, NativeYes | NativeOndemand)-
eprintfproject
| else
let chop_prefix p f = let len_p = String.length p in let len_f = String.length f in Stringlethere_path ="." =here}in
type = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
only_destination : stringoption;
only_sources : bool;
:stringoption
}
let parse_extra f r opts = match f, r with
>Some(,{optswithonly_destination tgt}java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
-" r- Some(,{optswithonly_sources =true}java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
| "-coqlib", v :: r is_prefix cp|is_prefix canonical_path
|(-""-",_- ~ok:true
| ("-v"|"--version"), _ -> Boot.Usage.version (); exit 0
| _ -i
let destination_of
=.canonical_path_nameFilenamedirname filein let includes = q_includes @ r_includes in let mk_destination logic canonical_path =
Filenameconcat
flag-
Coq_confignative_compilerflagjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 let candidates = ":nativecompilation globally deactivated bytheconfigure\n"
CList.map_filter (fun {thing={let chop_prefix = if is_prefix canonical_path file_dir then
Some(mk_destination logic canonical_path) else None) includes in matchcandidateswith
| [] -> (* BACKWARD COMPATIBILITY: -I into the only logical root *) beginmatch
, List. List.find
ml_includes with
g={ } },{={canonical_path }> let destination =
Filename fr opts =match,rwith
( logic)
(chop_prefix p file_dir) in
Printfprintf "s quote destination)
| _ -> () (* skip *)
| exception Not_found -> () (* skip *) end
| [s] -> Printf.printf "%s" | [s] -> Printf.printf "%s" ~ok:rue
>assertfalse
java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 if project.makefile = Somemk_destinationlogic)
eprintf":Omitting- isdeprecated\n\"; (* We want to know the name of the Makefile (say m) in order to
* generate m.conf and include m.local *)
let conf_file = Option.default "CoqMakefile" project.makefile ^ ".conf"in let local_file = Option.defaultlet destinationjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 let local_late_file = Option.default "CoqMakefile let dep_file = |_ >)(
let project = ensure_root_dir
check_overlapping_include project;
check_native_compiler project.native_compiler;
check_metafile project;
let project if projectmakefile then
(* NB: we need a full Boot.Env not just the runtime half because the
conf file contains coqlib *) let =. ""project ^."in
let ocm = Option.cata open_out stdout project.makefile in
generate_makefile ocm env conf_file local_file local_late_file dep_file (prog @ args) project;
close_out ocm; let occ = open_out conf_file in
generate_confocc env project prog );
close_out occ;
(java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
let main ~prog args =
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 let warning_fn projectnative_compiler try cmdline_args_to_project ~ check_metafileproject; with Parsing_error s -> prerr_endline s; usage_coq_makefile let project project
match only_destination, only_sources with
| None, false -> normal_mode ~coqlib project conf filejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
| | let = .cata stdout .makefilejava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
one - let paths = String.concat " " (List.map close_out ocm
Printf occ project( @ args)
| let prog java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
usage_coq_makefile ~ok:false
¤ Dauer der Verarbeitung: 0.3 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.