Skip to content

Commit 257a206

Browse files
committed
factor output [interpret_json]
1 parent 180df62 commit 257a206

File tree

2 files changed

+52
-27
lines changed

2 files changed

+52
-27
lines changed

jscomp/bin/bsb.ml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8417,15 +8417,21 @@ let revise_merlin new_content =
84178417
output_string ochan merlin_trailer ;
84188418
output_string ochan "\n";
84198419
close_out ochan
8420+
8421+
8422+
8423+
8424+
84208425
(*TODO: it is a little mess that [cwd] and [project dir] are shared*)
8421-
(** *)
8422-
let write_ninja_file bsc_dir cwd =
8423-
let builddir = Bsb_config.lib_bs in
8426+
8427+
8428+
let bsppx_exe = "bsppx.exe"
8429+
let bsc_exe = "bsc.exe"
8430+
let bsb_helper_exe = "bsb_helper.exe"
8431+
8432+
let interpret_json bsc_dir cwd =
8433+
let builddir = Bsb_config.lib_bs in
84248434
let () = Bsb_build_util.mkp builddir in
8425-
let bsc, bsdep, bsppx =
8426-
bsc_dir // "bsc.exe",
8427-
bsc_dir // "bsb_helper.exe",
8428-
bsc_dir // "bsppx.exe" in
84298435

84308436
let update_queue = ref [] in
84318437
let globbed_dirs = ref [] in
@@ -8447,7 +8453,11 @@ let write_ninja_file bsc_dir cwd =
84478453
S %s\n\
84488454
B %s\n\
84498455
FLG -ppx %s\n\
8450-
" lib_ocaml_dir lib_ocaml_dir bsppx
8456+
"
8457+
lib_ocaml_dir
8458+
lib_ocaml_dir
8459+
(bsc_dir // bsppx_exe)
8460+
(* bsppx *)
84518461
) in
84528462
let () =
84538463
match Bsb_default.get_bsc_flags () with
@@ -8538,14 +8548,17 @@ let write_ninja_file bsc_dir cwd =
85388548
Unix.unlink Literals.bsconfig_json;
85398549
Unix.rename config_file_bak Literals.bsconfig_json
85408550
end;
8541-
8551+
!globbed_dirs
8552+
(** *)
8553+
let write_ninja_file bsc_dir cwd =
8554+
let globbed_dirs = interpret_json bsc_dir cwd in
85428555
Bsb_gen.output_ninja
8543-
~builddir
8556+
~builddir:Bsb_config.lib_bs
85448557
~cwd
85458558
~js_post_build_cmd: Bsb_default.(get_js_post_build_cmd ())
85468559
~package_specs:(Bsb_default.get_package_specs())
8547-
bsc
8548-
bsdep
8560+
(bsc_dir // bsc_exe)
8561+
(bsc_dir // bsb_helper_exe)
85498562
(Bsb_default.get_package_name ())
85508563
(Bsb_default.get_ocamllex ())
85518564
(Bsb_default.get_bs_external_includes ())
@@ -8557,7 +8570,7 @@ let write_ninja_file bsc_dir cwd =
85578570
Bsb_default.(get_refmt_flags ())
85588571

85598572
;
8560-
!globbed_dirs
8573+
globbed_dirs
85618574

85628575

85638576
end

jscomp/bsb/bsb_config_parse.ml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,21 @@ let revise_merlin new_content =
9090
output_string ochan merlin_trailer ;
9191
output_string ochan "\n";
9292
close_out ochan
93+
94+
95+
96+
97+
9398
(*TODO: it is a little mess that [cwd] and [project dir] are shared*)
94-
(** *)
95-
let write_ninja_file bsc_dir cwd =
96-
let builddir = Bsb_config.lib_bs in
97-
let () = Bsb_build_util.mkp builddir in
98-
let bsc, bsdep, bsppx =
99-
bsc_dir // "bsc.exe",
100-
bsc_dir // "bsb_helper.exe",
101-
bsc_dir // "bsppx.exe" in
10299

100+
101+
let bsppx_exe = "bsppx.exe"
102+
let bsc_exe = "bsc.exe"
103+
let bsb_helper_exe = "bsb_helper.exe"
104+
105+
let interpret_json bsc_dir cwd =
106+
let builddir = Bsb_config.lib_bs in
107+
let () = Bsb_build_util.mkp builddir in
103108
let update_queue = ref [] in
104109
let globbed_dirs = ref [] in
105110
(* ATTENTION: order matters here, need resolve global properties before
@@ -120,7 +125,11 @@ let write_ninja_file bsc_dir cwd =
120125
S %s\n\
121126
B %s\n\
122127
FLG -ppx %s\n\
123-
" lib_ocaml_dir lib_ocaml_dir bsppx
128+
"
129+
lib_ocaml_dir
130+
lib_ocaml_dir
131+
(bsc_dir // bsppx_exe)
132+
(* bsppx *)
124133
) in
125134
let () =
126135
match Bsb_default.get_bsc_flags () with
@@ -211,14 +220,17 @@ let write_ninja_file bsc_dir cwd =
211220
Unix.unlink Literals.bsconfig_json;
212221
Unix.rename config_file_bak Literals.bsconfig_json
213222
end;
214-
223+
!globbed_dirs
224+
(** *)
225+
let write_ninja_file bsc_dir cwd =
226+
let globbed_dirs = interpret_json bsc_dir cwd in
215227
Bsb_gen.output_ninja
216-
~builddir
228+
~builddir:Bsb_config.lib_bs
217229
~cwd
218230
~js_post_build_cmd: Bsb_default.(get_js_post_build_cmd ())
219231
~package_specs:(Bsb_default.get_package_specs())
220-
bsc
221-
bsdep
232+
(bsc_dir // bsc_exe)
233+
(bsc_dir // bsb_helper_exe)
222234
(Bsb_default.get_package_name ())
223235
(Bsb_default.get_ocamllex ())
224236
(Bsb_default.get_bs_external_includes ())
@@ -230,5 +242,5 @@ let write_ninja_file bsc_dir cwd =
230242
Bsb_default.(get_refmt_flags ())
231243

232244
;
233-
!globbed_dirs
245+
globbed_dirs
234246

0 commit comments

Comments
 (0)