1010(* *)
1111(* **********************************************************************)
1212
13- let output_prefix name =
14- match ! Clflags. output_name with
15- | None ->
16- Ext_namespace_encode. make
17- (Filename. remove_extension name)
18- ?ns:! Clflags. dont_record_crc_unit
19- | Some oname ->
20- Filename. remove_extension oname
21-
2213
14+ let set_abs_input_name sourcefile =
15+ let sourcefile =
16+ if ! Location. absname && Filename. is_relative sourcefile then
17+ Ext_path. absolute_cwd_path sourcefile
18+ else sourcefile in
19+ Location. set_input_name sourcefile;
20+ sourcefile
2321
2422
2523let setup_error_printer (syntax_kind : [ `ml | `reason | `rescript ] )=
@@ -36,9 +34,10 @@ let setup_error_printer (syntax_kind : [ `ml | `reason | `rescript ])=
3634
3735
3836
39- let handle_reason (type a ) (kind : a Ml_binary.kind ) sourcefile ppf opref =
37+ let handle_reason (type a ) (kind : a Ml_binary.kind ) sourcefile ppf =
4038 setup_error_printer `reason ;
4139 let tmpfile = Ast_reason_pp. pp sourcefile in
40+ let outputprefix = Config_util. output_prefix sourcefile in
4241 (match kind with
4342 | Ml_binary. Ml ->
4443 Js_implementation. implementation
@@ -47,7 +46,7 @@ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
4746 let ast = Ml_binary. read_ast Ml in_chan in
4847 close_in in_chan; ast
4948 )
50- ppf tmpfile opref
49+ ppf tmpfile ~outputprefix
5150
5251 | Ml_binary. Mli ->
5352 Js_implementation. interface
@@ -56,55 +55,61 @@ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
5655 let ast = Ml_binary. read_ast Mli in_chan in
5756 close_in in_chan; ast
5857 )
59- ppf tmpfile opref ; );
58+ ppf tmpfile ~outputprefix );
6059 Ast_reason_pp. clean tmpfile
6160
62-
6361
6462let process_file sourcefile
6563 ?(kind ) ppf =
6664 (* This is a better default then "", it will be changed later
6765 The {!Location.input_name} relies on that we write the binary ast
6866 properly
6967 *)
70- Location. set_input_name sourcefile;
71- let opref = output_prefix sourcefile in
7268 let kind =
7369 match kind with
7470 | None -> Ext_file_extensions. classify_input (Ext_filename. get_extension_maybe sourcefile)
7571 | Some kind -> kind in
7672 match kind with
77- | Re -> handle_reason Ml sourcefile ppf opref
73+ | Re ->
74+ let sourcefile = set_abs_input_name sourcefile in
75+ handle_reason Ml sourcefile ppf
7876 | Rei ->
79- handle_reason Mli sourcefile ppf opref
77+ let sourcefile = set_abs_input_name sourcefile in
78+ handle_reason Mli sourcefile ppf
8079 | Ml ->
80+ let sourcefile = set_abs_input_name sourcefile in
8181 Js_implementation. implementation
8282 ~parser: Pparse_driver. parse_implementation
83- ppf sourcefile opref
83+ ppf sourcefile
8484 | Mli ->
85+ let sourcefile = set_abs_input_name sourcefile in
8586 Js_implementation. interface
8687 ~parser: Pparse_driver. parse_interface
87- ppf sourcefile opref
88+ ppf sourcefile
8889 | Res ->
90+ let sourcefile = set_abs_input_name sourcefile in
8991 setup_error_printer `rescript ;
9092 Js_implementation. implementation
9193 ~parser: Res_driver. parse_implementation
92- ppf sourcefile opref
94+ ppf sourcefile
9395 | Resi ->
96+ let sourcefile = set_abs_input_name sourcefile in
9497 setup_error_printer `rescript ;
9598 Js_implementation. interface
9699 ~parser: Res_driver. parse_interface
97- ppf sourcefile opref
100+ ppf sourcefile
98101 | Intf_ast
99102 ->
100- Js_implementation. interface_mliast ppf sourcefile opref
103+ Js_implementation. interface_mliast ppf sourcefile
101104 setup_error_printer ;
102105 | Impl_ast
103106 ->
104- Js_implementation. implementation_mlast ppf sourcefile opref
107+ Js_implementation. implementation_mlast ppf sourcefile
105108 setup_error_printer;
106109 | Mlmap
107- -> Js_implementation. implementation_map ppf sourcefile opref
110+ ->
111+ Location. set_input_name sourcefile;
112+ Js_implementation. implementation_map ppf sourcefile
108113 | Cmi
109114 ->
110115 let cmi_sign = (Cmi_format. read_cmi sourcefile).cmi_sign in
0 commit comments