aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpboutill2011-09-01 09:51:37 +0000
committerpboutill2011-09-01 09:51:37 +0000
commitb405a4ef9efa01eeb2c0709233cb21223a910f65 (patch)
tree457825a00102f0ac3131a1293bb851f4d2e60fc7
parent02c63cbf0c7ee8feacea68b39ceaebdce69c4af8 (diff)
Automatic search of project file
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14444 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r--ide/coqide.ml6
-rw-r--r--ide/project_file.ml441
2 files changed, 32 insertions, 15 deletions
diff --git a/ide/coqide.ml b/ide/coqide.ml
index 900bd26bf4..0f53214868 100644
--- a/ide/coqide.ml
+++ b/ide/coqide.ml
@@ -1479,8 +1479,9 @@ let create_session file =
|None -> !sup_args
|Some the_file -> match !current.read_project with
|Ignore_args -> !sup_args
- |Append_args -> (Project_file.args_from_project the_file !custom_project_files)@(!sup_args)
- |Subst_args -> Project_file.args_from_project the_file !custom_project_files
+ |Append_args -> (Project_file.args_from_project the_file !custom_project_files !current.project_file_name)
+ @(!sup_args)
+ |Subst_args -> Project_file.args_from_project the_file !custom_project_files !current.project_file_name
in
let ct = ref (Coq.spawn_coqtop coqtop_args) in
let command = new Command_windows.command_window !ct current in
@@ -1687,7 +1688,6 @@ let load_file handler f =
try
prerr_endline "Loading file starts";
let is_f = Minilib.same_file f in
- Minilib.safe_prerr_endline f;
if not (Minilib.list_fold_left_i
(fun i found x -> if found then found else
let {analyzed_view=av} = x in
diff --git a/ide/project_file.ml4 b/ide/project_file.ml4
index 77d002c285..d543961503 100644
--- a/ide/project_file.ml4
+++ b/ide/project_file.ml4
@@ -132,17 +132,34 @@ let split_arguments =
| [] -> ([],([],[],[],[]),[],[]),([],[]),([],[])
in aux
-let read_project_file f = split_arguments (snd (process_cmd_line (Filename.dirname f) (Some f, None, false, true) [] (parse f)))
+let read_project_file f =
+ split_arguments
+ (snd (process_cmd_line (Filename.dirname f) (Some f, None, false, true) [] (parse f)))
-let args_from_project file project_files =
- let contains_file f dir =
- let is_f = Minilib.same_file f in
- List.exists (fun x -> let tmp = (if Filename.is_relative x then Filename.concat dir x else x)
- in Minilib.safe_prerr_endline tmp; is_f tmp)
+let args_from_project file project_files default_name =
+ let is_f = Minilib.same_file file in
+ let contains_file dir =
+ List.exists (fun x -> is_f (Minilib.correct_path x dir))
+ in
+ let build_cmd_line i_inc r_inc args =
+ List.fold_right (fun (_,i) o -> "-I" :: i :: o) i_inc
+ (List.fold_right (fun (_,l,p) o -> "-R" :: p :: l :: o) r_inc
+ (List.fold_right (fun a o -> parse_args (Stream.of_string a) @ o) args []))
in try
- let (_,(_,(i_inc,r_inc),(args,_))) = List.find (fun (dir,((v_files,_,_,_),_,_)) ->
- contains_file file dir v_files) project_files in
- List.fold_right (fun (_,i) o -> "-I" :: i :: o) i_inc
- (List.fold_right (fun (_,l,p) o -> "-R" :: p :: l :: o) r_inc
- (List.fold_right (fun a o -> parse_args (Stream.of_string a) @ o) args []))
- with Not_found -> []
+ let (_,(_,(i_inc,r_inc),(args,_))) =
+ List.find (fun (dir,((v_files,_,_,_),_,_)) ->
+ contains_file dir v_files) project_files in
+ build_cmd_line i_inc r_inc args
+ with Not_found ->
+ let rec find_project_file dir = try
+ let ((v_files,_,_,_),(i_inc,r_inc),(args,_)) =
+ read_project_file (Filename.concat dir default_name) in
+ if contains_file dir v_files
+ then build_cmd_line i_inc r_inc args
+ else let newdir = Filename.dirname dir in
+ Minilib.safe_prerr_endline newdir;
+ if dir = newdir then [] else find_project_file newdir
+ with Sys_error s ->
+ let newdir = Filename.dirname dir in
+ if dir = newdir then [] else find_project_file newdir
+ in find_project_file (Filename.dirname file)