Skip to content

Commit 4bafd20

Browse files
committed
fix bugs of bsb
1 parent 7fa8959 commit 4bafd20

File tree

5 files changed

+53
-31
lines changed

5 files changed

+53
-31
lines changed

bsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@
467467
"a.ml"
468468
]
469469
}
470-
, "bsc-flags" : ["-w -40-30", "-w +a"]
470+
// , "bsc-flags" : ["-w -40-30", "-w +a"]
471471
, "generate-merlin" : true
472472
// "ppx-flags": ["reason/bin/reactjs_jsx_ppx"]
473473
// ,

jscomp/bin/bsb.ml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6368,11 +6368,11 @@ let handle_list_files dir (s : Ext_json.t array) loc_start loc_end : Ext_file_p
63686368
let dyn_file_array = String_vec.make (Array.length files_array) in
63696369
let files =
63706370
Array.fold_left (fun acc name ->
6371-
let new_acc = Binary_cache.map_update ~dir acc name in
6372-
if new_acc != acc then (* reference in-equality *)
6373-
String_vec.push name dyn_file_array ;
6374-
new_acc
6375-
6371+
if Ext_string.is_valid_source_name name then begin
6372+
let new_acc = Binary_cache.map_update ~dir acc name in
6373+
String_vec.push name dyn_file_array ;
6374+
new_acc
6375+
end else acc
63766376
) String_map.empty files_array in
63776377
[{Ext_file_pp.loc_start ;
63786378
loc_end; action = (`print (print_arrays dyn_file_array))}],
@@ -6499,7 +6499,7 @@ let rec parsing_source (dir_index : int) cwd (x : Ext_json.t String_map.t )
64996499
let res =
65006500
Array.fold_left (fun origin json ->
65016501
match json with
6502-
| `Obj m ->
6502+
| `Obj m -> (* could also be a string *)
65036503
parsing_source current_dir_index !dir m ++ origin
65046504
| _ -> origin ) empty s in
65056505
children := res.files ;
@@ -7579,7 +7579,8 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
75797579
~output:output_mlastd
75807580
~input:output_mlast
75817581
~rule:Rules.build_bin_deps
7582-
?shadows:(if group.dir_index = 0 then None else Some ["group", `Overwrite (string_of_int group.dir_index)])
7582+
?shadows:(if group.dir_index = 0 then None
7583+
else Some [Bsb_build_schemas.bsb_dir_group, `Overwrite (string_of_int group.dir_index)])
75837584
;
75847585
let rule_name , cm_outputs, deps =
75857586
if module_info.mli = Mli_empty then
@@ -8510,27 +8511,37 @@ let () =
85108511
end
85118512
else
85128513
begin
8513-
match Ext_array.find_and_split Sys.argv Ext_string.equal "--" with
8514+
match Ext_array.find_and_split Sys.argv Ext_string.equal separator with
85148515
| `No_split
85158516
->
85168517
begin
85178518
Arg.parse bsb_main_flags annoymous usage;
85188519
(* [-make-world] should never be combined with [-package-specs] *)
8519-
if !make_world then begin
8520-
(* don't regenerate files when we only run [bsb -clean-world] *)
8521-
let deps = regenerate_ninja cwd bsc_dir !force_regenerate in
8522-
make_world_deps deps
8520+
begin match !make_world, !force_regenerate with
8521+
| false, false -> ()
8522+
| make_world, force_regenerate ->
8523+
(* don't regenerate files when we only run [bsb -clean-world] *)
8524+
let deps = regenerate_ninja cwd bsc_dir force_regenerate in
8525+
if make_world then begin
8526+
make_world_deps deps
8527+
end;
85238528
end;
85248529
if !watch_mode then begin
85258530
watch ()
8526-
(* ninja is not triggered in this case *)
8531+
(* ninja is not triggered in this case
8532+
There are several cases we wish ninja will not be triggered.
8533+
[bsb -clean-world]
8534+
[bsb -regen ]
8535+
*)
8536+
end else if !make_world then begin
8537+
ninja_command ninja [||]
85278538
end
85288539
end
85298540
| `Split (bsb_args,ninja_args)
8530-
->
8541+
-> (* -make-world all dependencies fall into this category *)
85318542
begin
85328543
Arg.parse_argv bsb_args bsb_main_flags annoymous usage ;
8533-
let deps = (regenerate_ninja cwd bsc_dir !force_regenerate) in
8544+
let deps = regenerate_ninja cwd bsc_dir !force_regenerate in
85348545
(* [-make-world] should never be combined with [-package-specs] *)
85358546
if !make_world then
85368547
make_world_deps deps ;

jscomp/bsb/bsb_build_ui.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ let handle_list_files dir (s : Ext_json.t array) loc_start loc_end : Ext_file_p
104104
let dyn_file_array = String_vec.make (Array.length files_array) in
105105
let files =
106106
Array.fold_left (fun acc name ->
107-
let new_acc = Binary_cache.map_update ~dir acc name in
108-
if new_acc != acc then (* reference in-equality *)
109-
String_vec.push name dyn_file_array ;
110-
new_acc
111-
107+
if Ext_string.is_valid_source_name name then begin
108+
let new_acc = Binary_cache.map_update ~dir acc name in
109+
String_vec.push name dyn_file_array ;
110+
new_acc
111+
end else acc
112112
) String_map.empty files_array in
113113
[{Ext_file_pp.loc_start ;
114114
loc_end; action = (`print (print_arrays dyn_file_array))}],
@@ -235,7 +235,7 @@ let rec parsing_source (dir_index : int) cwd (x : Ext_json.t String_map.t )
235235
let res =
236236
Array.fold_left (fun origin json ->
237237
match json with
238-
| `Obj m ->
238+
| `Obj m -> (* could also be a string *)
239239
parsing_source current_dir_index !dir m ++ origin
240240
| _ -> origin ) empty s in
241241
children := res.files ;

jscomp/bsb/bsb_main.ml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,27 +448,37 @@ let () =
448448
end
449449
else
450450
begin
451-
match Ext_array.find_and_split Sys.argv Ext_string.equal "--" with
451+
match Ext_array.find_and_split Sys.argv Ext_string.equal separator with
452452
| `No_split
453453
->
454454
begin
455455
Arg.parse bsb_main_flags annoymous usage;
456456
(* [-make-world] should never be combined with [-package-specs] *)
457-
if !make_world then begin
458-
(* don't regenerate files when we only run [bsb -clean-world] *)
459-
let deps = regenerate_ninja cwd bsc_dir !force_regenerate in
460-
make_world_deps deps
457+
begin match !make_world, !force_regenerate with
458+
| false, false -> ()
459+
| make_world, force_regenerate ->
460+
(* don't regenerate files when we only run [bsb -clean-world] *)
461+
let deps = regenerate_ninja cwd bsc_dir force_regenerate in
462+
if make_world then begin
463+
make_world_deps deps
464+
end;
461465
end;
462466
if !watch_mode then begin
463467
watch ()
464-
(* ninja is not triggered in this case *)
468+
(* ninja is not triggered in this case
469+
There are several cases we wish ninja will not be triggered.
470+
[bsb -clean-world]
471+
[bsb -regen ]
472+
*)
473+
end else if !make_world then begin
474+
ninja_command ninja [||]
465475
end
466476
end
467477
| `Split (bsb_args,ninja_args)
468-
->
478+
-> (* -make-world all dependencies fall into this category *)
469479
begin
470480
Arg.parse_argv bsb_args bsb_main_flags annoymous usage ;
471-
let deps = (regenerate_ninja cwd bsc_dir !force_regenerate) in
481+
let deps = regenerate_ninja cwd bsc_dir !force_regenerate in
472482
(* [-make-world] should never be combined with [-package-specs] *)
473483
if !make_world then
474484
make_world_deps deps ;

jscomp/bsb/bsb_ninja.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
398398
~output:output_mlastd
399399
~input:output_mlast
400400
~rule:Rules.build_bin_deps
401-
?shadows:(if group.dir_index = 0 then None else Some ["group", `Overwrite (string_of_int group.dir_index)])
401+
?shadows:(if group.dir_index = 0 then None
402+
else Some [Bsb_build_schemas.bsb_dir_group, `Overwrite (string_of_int group.dir_index)])
402403
;
403404
let rule_name , cm_outputs, deps =
404405
if module_info.mli = Mli_empty then

0 commit comments

Comments
 (0)