diff options
| author | Xavier Leroy <xavier.leroy@inria.fr> | 2001-07-02 14:25:28 +0000 |
|---|---|---|
| committer | Xavier Leroy <xavier.leroy@inria.fr> | 2001-07-02 14:25:28 +0000 |
| commit | 390e63f8884eb2e3491241db1b1b0164cbc95d03 (patch) | |
| tree | e7e59b374a0f40ea01d66d036bd634ea993debd3 /driver/compile.ml | |
| parent | 141b93165d047c369d001b3ac88c7da2d2b3cf85 (diff) | |
| download | ocaml-390e63f8884eb2e3491241db1b1b0164cbc95d03.tar.gz | |
Pour le preprocessing, utiliser des fichiers temporaires uniques dans /tmp (PR#314)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3564 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'driver/compile.ml')
| -rw-r--r-- | driver/compile.ml | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/driver/compile.ml b/driver/compile.ml index 008331e727..641ef5b199 100644 --- a/driver/compile.ml +++ b/driver/compile.ml @@ -46,14 +46,15 @@ let initial_env () = (* Optionally preprocess a source file *) -let preprocess sourcefile tmpfile = +let preprocess sourcefile = match !Clflags.preprocessor with None -> sourcefile | Some pp -> - let comm = pp ^ " " ^ sourcefile ^ " > " ^ tmpfile in + let tmpfile = Filename.temp_file "camlpp" "" in + let comm = Printf.sprintf "%s %s > %s" pp sourcefile tmpfile in if Ccomp.command comm <> 0 then begin + remove_file tmpfile; Printf.eprintf "Preprocessing error\n"; - flush stderr; exit 2 end; tmpfile @@ -103,7 +104,7 @@ let interface ppf sourcefile = init_path(); let prefixname = Filename.chop_extension sourcefile in let modulename = String.capitalize(Filename.basename prefixname) in - let inputfile = preprocess sourcefile (prefixname ^ ".ppi") in + let inputfile = preprocess sourcefile in let ast = parse_file inputfile Parse.interface ast_intf_magic_number in if !Clflags.dump_parsetree then fprintf ppf "%a@." Printast.interface ast; let sg = Typemod.transl_signature (initial_env()) ast in @@ -125,7 +126,7 @@ let implementation ppf sourcefile = init_path(); let prefixname = Filename.chop_extension sourcefile in let modulename = String.capitalize(Filename.basename prefixname) in - let inputfile = preprocess sourcefile (prefixname ^ ".ppo") in + let inputfile = preprocess sourcefile in let objfile = prefixname ^ ".cmo" in let oc = open_out_bin objfile in let env = initial_env() in |
