Skip to content

Commit dea9f6d

Browse files
committed
relative paths reloaded
1 parent b708dfe commit dea9f6d

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

jscomp/bsb/bsb_config.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ let rev_lib_bs_prefix p = rev_lib_bs // p
6262

6363
let ocaml_bin_install_prefix p = lib_ocaml // p
6464

65-
let proj_rel path = Bsb_ninja_global_vars.lazy_src_root_dir // path
65+
let proj_rel path = rev_lib_bs // path
6666

6767
(** it may not be a bad idea to hard code the binary path
6868
of bsb in configuration time

jscomp/bsb/bsb_ninja_gen.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ let output_ninja_and_namespace_map
236236

237237
let oc = open_out_bin (cwd_lib_bs // Literals.build_ninja) in
238238
mark_rescript oc;
239-
Bsb_ninja_targets.output_kv
239+
(* Bsb_ninja_targets.output_kv
240240
Bsb_ninja_global_vars.src_root_dir per_proj_dir
241-
oc ;
241+
oc ; *)
242242
output_static_resources static_resources rules.copy_resources oc ;
243243
(** Generate build statement for each file *)
244244
Ext_list.iter bs_file_groups

jscomp/bsb/bsb_ninja_global_vars.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
to be "a" and "$a"
3131
*)
3232

33-
let src_root_dir = "g_root"
33+
(* let src_root_dir = "g_root"
3434
35-
let lazy_src_root_dir = "$g_root"
35+
let lazy_src_root_dir = "$g_root" *)
3636

3737

3838

jscomp/bsb/bsb_ninja_rule.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ let make_custom_rules
218218
);
219219

220220
Ext_buffer.add_char_string buf ' ' bsc_flags;
221-
Ext_buffer.add_string buf " -bs-ast -o $out $i";
221+
Ext_buffer.add_string buf " -absname -bs-ast -o $out $i";
222222
Ext_buffer.contents buf
223223
in
224224
let build_ast =

jscomp/main/js_main.ml

+28-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ let output_prefix name =
1919
| Some oname ->
2020
Filename.remove_extension oname
2121

22-
22+
let set_abs_input_name sourcefile =
23+
let sourcefile =
24+
if !Location.absname && Filename.is_relative sourcefile then
25+
Ext_path.absolute_cwd_path sourcefile
26+
else sourcefile in
27+
Location.set_input_name sourcefile;
28+
sourcefile
2329

2430

2531
let setup_error_printer (syntax_kind : [ `ml | `reason | `rescript ])=
@@ -59,52 +65,68 @@ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
5965
ppf tmpfile opref ; );
6066
Ast_reason_pp.clean tmpfile
6167

62-
68+
6369

6470
let process_file sourcefile
6571
?(kind ) ppf =
6672
(* This is a better default then "", it will be changed later
6773
The {!Location.input_name} relies on that we write the binary ast
6874
properly
6975
*)
70-
Location.set_input_name sourcefile;
71-
let opref = output_prefix sourcefile in
7276
let kind =
7377
match kind with
7478
| None -> Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe sourcefile)
7579
| Some kind -> kind in
7680
match kind with
77-
| Re -> handle_reason Ml sourcefile ppf opref
81+
| Re ->
82+
let sourcefile = set_abs_input_name sourcefile in
83+
let opref = output_prefix sourcefile in
84+
handle_reason Ml sourcefile ppf opref
7885
| Rei ->
86+
let sourcefile = set_abs_input_name sourcefile in
87+
let opref = output_prefix sourcefile in
7988
handle_reason Mli sourcefile ppf opref
8089
| Ml ->
90+
let sourcefile = set_abs_input_name sourcefile in
91+
let opref = output_prefix sourcefile in
8192
Js_implementation.implementation
8293
~parser:Pparse_driver.parse_implementation
8394
ppf sourcefile opref
8495
| Mli ->
96+
let sourcefile = set_abs_input_name sourcefile in
97+
let opref = output_prefix sourcefile in
8598
Js_implementation.interface
8699
~parser:Pparse_driver.parse_interface
87100
ppf sourcefile opref
88101
| Res ->
102+
let sourcefile = set_abs_input_name sourcefile in
103+
let opref = output_prefix sourcefile in
89104
setup_error_printer `rescript;
90105
Js_implementation.implementation
91106
~parser:Res_driver.parse_implementation
92107
ppf sourcefile opref
93108
| Resi ->
109+
let sourcefile = set_abs_input_name sourcefile in
110+
let opref = output_prefix sourcefile in
94111
setup_error_printer `rescript;
95112
Js_implementation.interface
96113
~parser:Res_driver.parse_interface
97114
ppf sourcefile opref
98115
| Intf_ast
99116
->
117+
let opref = output_prefix sourcefile in
100118
Js_implementation.interface_mliast ppf sourcefile opref
101119
setup_error_printer ;
102120
| Impl_ast
103121
->
122+
let opref = output_prefix sourcefile in
104123
Js_implementation.implementation_mlast ppf sourcefile opref
105124
setup_error_printer;
106125
| Mlmap
107-
-> Js_implementation.implementation_map ppf sourcefile opref
126+
->
127+
Location.set_input_name sourcefile;
128+
let opref = output_prefix sourcefile in
129+
Js_implementation.implementation_map ppf sourcefile opref
108130
| Cmi
109131
->
110132
let cmi_sign = (Cmi_format.read_cmi sourcefile).cmi_sign in

0 commit comments

Comments
 (0)