Debian Codegraph @

tools/configure/cmdArgs.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Util
12
13 (** * Command-line parsing *)
14
15 type prefix = RelocatableInstall | Prefix of string
16
17 type nativecompiler = NativeYes | NativeNo | NativeOndemand
18
19 module Prefs = struct
20
21 type t = {
22 prefix : prefix option;
23 quiet : bool;
24 interactive : bool;
25 libdir : string option;
26 configdir : string option;
27 datadir : string option;
28 docdir : string option;
29 arch : string option;
30 natdynlink : bool;
31 browser : string option;
32 bytecodecompiler : bool;
33 nativecompiler : nativecompiler;
34 coqwebsite : string;
35 debug : bool;
36 }
37
38 end
39
40 open Prefs
41
42 let default_prefs = {
43 prefix = None;
44 quiet = false;
45 interactive = true;
46 libdir = None;
47 configdir = None;
48 datadir = None;
49 docdir = None;
50 arch = None;
51 natdynlink = true;
52 browser = None;
53 bytecodecompiler = true;
54 nativecompiler = NativeNo;
55 coqwebsite = "http://rocq-prover.org/";
56 debug = false;
57 }
58
59 let get_bool = function
60 | "true" | "yes" | "y" | "all" -> true
61 | "false" | "no" | "n" -> false
62 | s -> raise (Arg.Bad ("boolean argument expected instead of "^s))
63
64 let get_native = function
65 | "yes" -> NativeYes
66 | "no" -> NativeNo
67 | "ondemand" -> NativeOndemand
68 | s -> raise (Arg.Bad ("(yes|no|ondemand) argument expected instead of "^s))
69
70 let prefs = ref default_prefs
71
72 let arg_bool f = Arg.String (fun s -> prefs := f !prefs (get_bool s))
73
74 let arg_string f = Arg.String (fun s -> prefs := f !prefs s)
75 let arg_string_option f = Arg.String (fun s -> prefs := f !prefs (Some s))
76
77 let arg_set f = Arg.Unit (fun () -> prefs := f !prefs)
78
79 let arg_native f = Arg.String (fun s -> prefs := f !prefs (get_native s))
80
81 (* TODO : earlier any option -foo was also available as --foo *)
82
83 let warn_warn_error () =
84 Format.eprintf "****** the -warn-error option is deprecated, \
85 warnings are not set in the config section of the \
86 corresponding build tool [coq_makefile, dune]@\n%!"
87
88 let make_prefix path =
89 if Filename.is_relative path then
90 Prefix (Sys.getcwd() ^ "/" ^ path)
91 else Prefix path
92
93 let args_options = Arg.align [
94 "-prefix", arg_string (fun p prefix -> { p with prefix = Some (make_prefix prefix) }),
95 "<dir> Set installation directory to <dir>";
96 "-relocatable", arg_set (fun p -> { p with prefix = Some RelocatableInstall } ),
97 " Make a relocatable installation";
98 "-quiet", arg_set (fun p -> { p with quiet = true }),
99 " Don't print variables during configure";
100 "-no-ask", arg_set (fun p -> { p with interactive = false }),
101 " Don't ask questions during configure [questions will be filled with defaults]";
102 "-libdir", arg_string_option (fun p libdir -> { p with libdir }),
103 "<dir> Where to install lib files";
104 "-configdir", arg_string_option (fun p configdir -> { p with configdir }),
105 "<dir> Where to install config files";
106 "-datadir", arg_string_option (fun p datadir -> { p with datadir }),
107 "<dir> Where to install data files";
108 "-docdir", arg_string_option (fun p docdir -> { p with docdir }),
109 "<dir> Where to install doc files";
110 "-arch", arg_string_option (fun p arch -> { p with arch }),
111 "<arch> Specifies the architecture";
112 "-natdynlink", arg_bool (fun p natdynlink -> { p with natdynlink }),
113 "(yes|no) Use dynamic loading of native code or not";
114 "-browser", arg_string_option (fun p browser -> { p with browser }),
115 "<command> Use <command> to open URL %s";
116 "-bytecode-compiler", arg_bool (fun p bytecodecompiler -> { p with bytecodecompiler }),
117 "(yes|no) Enable Rocq's bytecode reduction machine (VM)";
118 "-native-compiler", arg_native (fun p nativecompiler -> { p with nativecompiler }),
119 "(yes|no|ondemand) Compilation to native code for conversion and normalization
120 yes: -native-compiler option of coqc will default to 'yes', stdlib will be precompiled
121 no (default): no native compilation available at all
122 ondemand: -native-compiler option of coqc will default to 'ondemand', stdlib will not be precompiled";
123 "-warn-error", arg_bool (fun p _warn_error -> warn_warn_error (); p),
124 " Deprecated option: warnings are now adjusted in the corresponding build tool.";
125 "-coqwebsite", arg_string (fun p coqwebsite -> { p with coqwebsite }),
126 " URL of the rocq website";
127 "-debug", arg_set (fun p -> { p with debug = true }), " Enable debug information for package detection"
128 ]
129
130 let parse_args () =
131 Arg.parse
132 args_options
133 (fun s -> raise (Arg.Bad ("Unknown option: "^s)))
134 "Available options for configure are:";
135 !prefs
136
137 (* Support don't ask *)
138 let cprintf prefs x =
139 if not prefs.quiet
140 then cprintf x
141 else Printf.ifprintf stdout x