Commit 6067321b authored by Pietro Abate's avatar Pietro Abate

[r2006-03-17 13:25:49 by afrisch] Utiliser les -I pour les includes

Original author: afrisch
Date: 2006-03-17 13:27:38+00:00
parent a01634b4
......@@ -52,9 +52,6 @@ let mk name descr typing compile code ext_info depends =
let magic = "CDUCE:compunit:00007"
let obj_path = ref [ "" ]
let has_obj n =
let base = U.to_string n ^ ".cdo" in
List.exists (fun p -> Sys.file_exists (Filename.concat p base)) !obj_path
......
......@@ -8,8 +8,6 @@ exception NoImplementation of U.t
val name: Compunit.t -> U.t
val run_loaded: bool ref
val obj_path: string list ref
val compile_save: bool -> U.t -> string -> string -> unit
val compile_run: bool -> U.t -> string -> unit
val load_run: U.t -> unit
......
......@@ -29,8 +29,8 @@ let specs =
"(for --compile) show types of exported values";
"--obj-dir", Arg.String (fun s -> out_dir := s :: !out_dir),
"(for --compile) directory for the compiled .cdo file";
"-I", Arg.String (fun s -> Librarian.obj_path := s::!Librarian.obj_path),
" add one directory to the lookup path for .cdo and .cmi files";
"-I", Arg.String (fun s -> Location.obj_path := s::!Location.obj_path),
" add one directory to the lookup path for .cdo/.cmi and include files";
"--stdin", Arg.Unit (fun () -> src := "" :: !src),
" read CDuce script on standard input";
"--arg", Arg.Rest (fun s -> args := s :: !args),
......
......@@ -165,3 +165,16 @@ let protect_op op =
if (!protected) then
raise
(Generic (op ^ ": operation not authorized in the web prototype"))
let obj_path = ref [ "" ]
let resolve_filename s =
if Filename.is_relative s then
try
let p =
List.find
(fun p -> Sys.file_exists (Filename.concat p s))
(current_dir () :: !obj_path) in
Filename.concat p s
with Not_found -> s
else s
......@@ -48,3 +48,7 @@ val loc_of_pos : int * int -> loc
val set_protected : bool -> unit
val is_protected : unit -> bool
val protect_op : string -> unit
val obj_path: string list ref
val resolve_filename: string -> string
......@@ -176,11 +176,8 @@ EXTEND
| "#"; IDENT "help" -> [ mk _loc (Directive `Help) ]
| "#"; IDENT "builtins" -> [ mk _loc (Directive `Builtins) ]
| "include"; s = STRING2 ->
let s =
if Filename.is_relative s
then Filename.concat (Location.current_dir ()) s
else s in
protect_op "File inclusion";
let s = Location.resolve_filename s in
(* avoid looping; should issue an error ? *)
(* it is possible to have looping with x/../x/../x/.. ....
Need to canonicalize filename *)
......
......@@ -80,8 +80,8 @@ Specify where to put the <code>.cdo</code> file (default: same directory as the
source file).</li>
<li> <code>--I %%directory%%</code>
Add a directory to the search path for <code>.cdo</code>
and <code>.cmi</code> files. </li>
Add a directory to the search path for <code>.cdo</code>,
<code>.cmi</code> and include files. </li>
<li> <code>--stdin</code>. Read CDuce script from standard input. </li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment