diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 0f716d04..7adb32ea 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -1398,48 +1398,19 @@ module Gen(P : Params) = struct let ocamllex_rules (conf : Ocamllex.t) ~dir = List.iter conf.names ~f:(fun name -> let src = Path.relative dir (name ^ ".mll" ) in - let tmp = Path.relative dir (name ^ ".tmp.ml") in let dst = Path.relative dir (name ^ ".ml" ) in add_rule - (Build.run (Dep ctx.ocamllex) [A "-q"; A "-o"; Path tmp; Dep src] - >>> - Build.create_file ~target:dst (fun () -> - let repl = Path.to_string (Path.append ctx.build_dir dst) in - let tmp = Path.to_string tmp in - let dst = Path.to_string dst in - Rewrite_generated_file.rewrite ~src:tmp ~dst ~repl; - Sys.remove tmp))) + (Build.run (Dep ctx.ocamllex) [A "-q"; A "-o"; Target dst; Dep src])) let ocamlyacc_rules (conf : Ocamlyacc.t) ~dir = List.iter conf.names ~f:(fun name -> let src = Path.relative dir (name ^ ".mly" ) in - let tmp = Path.relative dir (name ^ ".tmp.ml" ) in - let tmpi = Path.relative dir (name ^ ".tmp.mli") in let dst = Path.relative dir (name ^ ".ml" ) in let dsti = Path.relative dir (name ^ ".mli" ) in add_rule - (Build.run + (Build.run ~extra_targets:[dst; dsti] (Dep ctx.ocamlyacc) - [ A "-b" - ; Path (Path.relative dir (name ^ ".tmp")) - ; Dep src - ] - >>> - Build.create_files ~targets:[dst; dsti] (fun () -> - let repl = Path.to_string (Path.append ctx.build_dir dst) in - let tmp = Path.to_string tmp in - let dst = Path.to_string dst in - Rewrite_generated_file.rewrite ~src:tmp ~dst ~repl; - Sys.remove tmp; - - let repli = Path.to_string (Path.append ctx.build_dir dsti) in - let tmpi = Path.to_string tmpi in - let dsti = Path.to_string dsti in - with_file_in tmpi ~f:(fun ic -> - with_file_out dsti ~f:(fun oc -> - Printf.fprintf oc "# 1 \"%s\"\n" repli; - copy_channels ic oc)); - Sys.remove tmpi))) + [ Dep src ])) (* +-----------------------------------------------------------------+ | Modules listing | diff --git a/src/jbuild b/src/jbuild index 47c1fa25..77156ac4 100644 --- a/src/jbuild +++ b/src/jbuild @@ -5,4 +5,4 @@ (public_name jbuilder) (libraries (unix jbuilder_re)))) -(ocamllex (sexp_lexer meta_lexer rewrite_generated_file glob_lexer)) +(ocamllex (sexp_lexer meta_lexer glob_lexer)) diff --git a/src/rewrite_generated_file.mli b/src/rewrite_generated_file.mli deleted file mode 100644 index b85e581b..00000000 --- a/src/rewrite_generated_file.mli +++ /dev/null @@ -1 +0,0 @@ -val rewrite : src:string -> dst:string -> repl:string -> unit diff --git a/src/rewrite_generated_file.mll b/src/rewrite_generated_file.mll deleted file mode 100644 index 872ba0a9..00000000 --- a/src/rewrite_generated_file.mll +++ /dev/null @@ -1,20 +0,0 @@ -{ open Import } - -rule iter src repl oc = parse - | ("# " ['0'-'9']+ " \"" as before) ([^'"' '\n']* as name) ('"' '\r'? '\n' as after) - { output_string oc before; - output_string oc (if name = src then repl else name); - output_string oc after; - iter src repl oc lexbuf } - | [^'\n']* '\n' as s - { output_string oc s; - iter src repl oc lexbuf } - | [^'\n']* eof as s - { output_string oc s } - -{ - let rewrite ~src ~dst ~repl = - with_file_in src ~f:(fun ic -> - with_file_out dst ~f:(fun oc -> - iter src repl oc (Lexing.from_channel ic))) -}