From 6735186e6458fedd57efd663c900166af0d6fce3 Mon Sep 17 00:00:00 2001 From: herbelin Date: Sun, 29 Jun 2008 16:24:36 +0000 Subject: Lissage de la gestion des chemins de chargement de fichiers : - Option -R fait maintenant des Import à tous les niveaux de la hiérarchie de répertoires. Par exemple, Require "Init.Wf" marche. - Option -I rend maintenant possible l'accès aux sous-répertoires via les noms qualifiés. Ainsi -R est exactement comme -I sauf qu'il rend récursivement visibles les noms non qualifiés. - Ajout option -I dir -as coqdir, et par symétrie, -R dir -as coqdir. - Ajout option -exclude-dir pour exclure certains sous-répertoires de la descente récursive de -R. - Amélioration message de localisation pour fichiers venant d'un "state". - Adaptation du checker (et ajout du test check_coq_overwriting qui semblait involontairement oublié dans l'option -R). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@11188 85f007b7-540e-0410-9357-904b9bb8a0f7 --- checker/check.ml | 4 ++-- checker/checker.ml | 35 +++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'checker') diff --git a/checker/check.ml b/checker/check.ml index f8844975ac..bc36f2732c 100644 --- a/checker/check.ml +++ b/checker/check.ml @@ -209,7 +209,7 @@ let locate_absolute_library dir = if loadpath = [] then raise LibUnmappedDir; try let name = string_of_id base^".vo" in - let _, file = System.where_in_path loadpath name in + let _, file = System.where_in_path false loadpath name in (dir, file) with Not_found -> (* Last chance, removed from the file system but still in memory *) @@ -229,7 +229,7 @@ let locate_qualified_library qid = in if loadpath = [] then raise LibUnmappedDir; let name = qid.basename^".vo" in - let path, file = System.where_in_path loadpath name in + let path, file = System.where_in_path true loadpath name in let dir = extend_dirpath (find_logical_path path) (id_of_string qid.basename) in (* Look if loaded *) diff --git a/checker/checker.ml b/checker/checker.ml index 1c7ace12f0..7de2583523 100644 --- a/checker/checker.ml +++ b/checker/checker.ml @@ -73,16 +73,14 @@ let convert_string d = failwith "caught" let add_rec_path ~unix_path:dir ~coq_root:coq_dirpath = - let dirs = all_subdirs dir in - let prefix = repr_dirpath coq_dirpath in - if dirs <> [] then + if exists_dir dir then + let dirs = all_subdirs dir in + let prefix = repr_dirpath coq_dirpath in let convert_dirs (lp,cp) = - (lp,Names.make_dirpath - ((List.map convert_string (List.rev cp))@prefix)) in + (lp,make_dirpath (List.map convert_string (List.rev cp)@prefix)) in let dirs = map_succeed convert_dirs dirs in - begin - List.iter Check.add_load_path dirs - end + List.iter Check.add_load_path dirs; + Check.add_load_path (dir,coq_dirpath) else msg_warning (str ("Cannot open " ^ dir)) @@ -101,6 +99,14 @@ let set_default_rec_include d = let p = Check.default_root_prefix in check_coq_overwriting p; push_rec_include (d, p) +let set_include d p = + let p = dirpath_of_string p in + check_coq_overwriting p; + push_include (d,p) +let set_rec_include d p = + let p = dirpath_of_string p in + check_coq_overwriting p; + push_rec_include(d,p) (* Initializes the LoadPath according to COQLIB and Coq_config *) let init_load_path () = @@ -174,9 +180,11 @@ let print_usage_channel co command = output_string co command; output_string co "Coq options are:\n"; output_string co -" -I dir add directory dir in the include path +" -I dir -as coqdir map physical dir to logical coqdir + -I dir map directory dir to the empty logical path -include dir (idem) - -R dir coqdir recursively map physical dir to logical coqdir + -R dir -as coqdir recursively map physical dir to logical coqdir + -R dir coqdir (idem) -admit module load module and dependencies without checking -norec module check module but admit dependencies without checking @@ -297,11 +305,14 @@ let parse_args() = | "-impredicative-set" :: rem -> set_engagement Declarations.ImpredicativeSet; parse rem + | ("-I"|"-include") :: d :: "-as" :: p :: rem -> set_include d p; parse rem + | ("-I"|"-include") :: d :: "-as" :: [] -> usage () | ("-I"|"-include") :: d :: rem -> set_default_include d; parse rem | ("-I"|"-include") :: [] -> usage () - | "-R" :: d :: p :: rem -> - push_rec_include (d, dirpath_of_string p);parse rem + | "-R" :: d :: "-as" :: p :: rem -> set_rec_include d p;parse rem + | "-R" :: d :: "-as" :: [] -> usage () + | "-R" :: d :: p :: rem -> set_rec_include d p;parse rem | "-R" :: ([] | [_]) -> usage () | "-debug" :: rem -> set_debug (); parse rem -- cgit v1.2.3