(************************************************************************) (* * 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) *) (************************************************************************)
let getenv_else s dft = match Boot.Util.getenv_opt s with
| Some v -> v
| None -> dft ()
let getenv_rocq = Boot.Util.getenv_rocq
let safe_getenv warning n =
getenv_else n (fun () ->
warning ("Environment variable "^n^" not found: using '$"^n^"' .");
("$"^n)
)
let ( / ) a b = if Filename.is_relative b then a ^ "/" ^ b else b
let coqify d = d / "coq"
let home ~warn =
getenv_else "HOME" (fun () -> try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found ->
getenv_else "USERPROFILE" (fun () ->
warn ("Cannot determine user home directory, using '.' .");
Filename.current_dir_name))
let path_to_list p = let sep = ifString.equal Sys.os_type "Win32"then';'else':'in String.split_on_char sep p
let expand_path_macros ~warn s = let rec expand_atom s i = let l = String.length s in if i<l && (Util.is_digit s.[i] || Util.is_letter s.[i] || s.[i] == '_') then expand_atom s (i+1) else i in let rec expand_macros s i = let l = String.length s in if Int.equal i l then s else match s.[i] with
| '$' -> let n = expand_atom s (i+1) in let v = safe_getenv warn (String.sub s (i+1) (n-i-1)) in let s = (String.sub s 0 i)^v^(String.sub s n (l-n)) in
expand_macros s (i + String.length v)
| '~' when Int.equal i 0 -> let n = expand_atom s (i+1) in let v = if Int.equal n (i + 1) then home ~warn else (Unix.getpwnam (String.sub s (i+1) (n-i-1))).Unix.pw_dir in let s = v^(String.sub s n (l-n)) in
expand_macros s (String.length v)
| c -> expand_macros s (i+1) in expand_macros s 0
(** {1 Paths} *)
(** {2 Rocq paths} *)
(** Add a local installation suffix (unless the suffix is itself
absolute in which case the prefix does not matter) *) let use_suffix suffix = ifString.length suffix > 0 && suffix.[0] = '/'then suffix else Boot.Env.relocate (Relocatable suffix)
(* XXX do we actually need the local_suffix? *) let relocate local_suffix path = (* This assumes implicitly that the suffix is non-trivial *) let local_path = use_suffix local_suffix in if Sys.file_exists local_path then local_path else Boot.Env.relocate path
let datadir () = relocate Coq_config.datadirsuffix Coq_config.datadir
let configdir () = relocate Coq_config.configdirsuffix Coq_config.configdir
let coqpath () = let make_search_path path = let paths = path_to_list path in let valid_paths = List.filter Sys.file_exists paths in List.rev valid_paths in let rocqpath = getenv_else "ROCQPATH" (fun () -> "") in let coqpath = getenv_else "COQPATH" (fun () -> "") in let coqpath = ifString.equal coqpath rocqpath then""else coqpath in let () = if coqpath <> ""then warn_deprecated_coq_var ~rocq:"ROCQPATH" ~coq:"COQPATH" () in
make_search_path rocqpath @ make_search_path coqpath
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.