Skip to content

Commit 25451f2

Browse files
committed
tweak
1 parent 19b3c87 commit 25451f2

File tree

9 files changed

+86
-198
lines changed

9 files changed

+86
-198
lines changed

jscomp/main/bsb_main.ml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,37 +177,18 @@ let install_target config_opt =
177177
let () =
178178
try begin
179179
match Sys.argv with
180-
#if BS_NATIVE then
181-
| [| _; "-backend"; _ |]
182-
#end
183180
| [| _ |] -> (* specialize this path [bsb.exe] which is used in watcher *)
184-
#if BS_NATIVE then
185-
if Array.length Sys.argv = 3 then begin match Array.get Sys.argv 2 with
186-
| "js" -> Bsb_global_backend.set_backend Bsb_config_types.Js
187-
| "native" -> Bsb_global_backend.set_backend Bsb_config_types.Native
188-
| "bytecode" -> Bsb_global_backend.set_backend Bsb_config_types.Bytecode
189-
| _ -> failwith "-backend should be one of: 'js', 'bytecode' or 'native'."
190-
end;
191-
#end
192181
Bsb_ninja_regen.regenerate_ninja
193182
~toplevel_package_specs:None
194183
~forced:false
195184
~per_proj_dir:Bsb_global_paths.cwd |> ignore;
196185
ninja_command_exit [||]
197-
198186
| argv ->
199187
begin
200-
let i = Ext_array.rfind_with_index
201-
argv Ext_string.equal separator in
188+
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in
202189
if i < 0 then
203190
begin
204-
Bsb_arg.parse_exn
205-
~usage
206-
~argv
207-
208-
bsb_main_flags
209-
handle_anonymous_arg
210-
;
191+
Bsb_arg.parse_exn ~usage ~argv bsb_main_flags handle_anonymous_arg;
211192
(* first, check whether we're in boilerplate generation mode, aka -init foo -theme bar *)
212193
match !generate_theme_with_path with
213194
| Some path -> Bsb_theme_init.init_sample_project ~cwd:Bsb_global_paths.cwd ~theme:!current_theme path

lib/4.06.1/bsb.ml

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,8 @@ val to_list_f :
20072007
('a -> 'b) ->
20082008
'b list
20092009

2010-
val to_list_map : ('a -> 'b option) -> 'a array -> 'b list
2010+
val to_list_map :
2011+
'a array -> ('a -> 'b option) -> 'b list
20112012

20122013
val to_list_map_acc :
20132014
'a array ->
@@ -2023,12 +2024,9 @@ val of_list_map :
20232024
val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int
20242025

20252026

2026-
type 'a split = [ `No_split | `Split of 'a array * 'a array ]
20272027

2028-
val rfind_and_split :
2029-
'a array ->
2030-
('a -> 'b -> bool) ->
2031-
'b -> 'a split
2028+
type 'a split = No_split | Split of 'a array * 'a array
2029+
20322030

20332031
val find_and_split :
20342032
'a array ->
@@ -2187,7 +2185,7 @@ let rec tolist_aux a f i res =
21872185
| Some v -> v :: res
21882186
| None -> res)
21892187

2190-
let to_list_map f a =
2188+
let to_list_map a f =
21912189
tolist_aux a f (Array.length a - 1) []
21922190

21932191
let to_list_map_acc a acc f =
@@ -2262,13 +2260,7 @@ let rfind_with_index arr cmp v =
22622260
else aux (i - 1) in
22632261
aux (len - 1)
22642262

2265-
type 'a split = [ `No_split | `Split of 'a array * 'a array ]
2266-
let rfind_and_split arr cmp v : _ split =
2267-
let i = rfind_with_index arr cmp v in
2268-
if i < 0 then
2269-
`No_split
2270-
else
2271-
`Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 ))
2263+
type 'a split = No_split | Split of 'a array * 'a array
22722264

22732265

22742266
let find_with_index arr cmp v =
@@ -2282,9 +2274,9 @@ let find_with_index arr cmp v =
22822274
let find_and_split arr cmp v : _ split =
22832275
let i = find_with_index arr cmp v in
22842276
if i < 0 then
2285-
`No_split
2277+
No_split
22862278
else
2287-
`Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1))
2279+
Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1))
22882280

22892281
(** TODO: available since 4.03, use {!Array.exists} *)
22902282

@@ -10770,23 +10762,23 @@ let extract_input_output (edge : Ext_json_types.t) : string list * string list =
1077010762
(match Ext_array.find_and_split content
1077110763
(fun x () -> match x with Str { str =":"} -> true | _ -> false )
1077210764
() with
10773-
| `No_split -> error ()
10774-
| `Split ( output, input) ->
10775-
(Ext_array.to_list_map (fun (x : Ext_json_types.t) ->
10765+
| No_split -> error ()
10766+
| Split ( output, input) ->
10767+
(Ext_array.to_list_map output (fun x ->
1077610768
match x with
1077710769
| Str {str = ":"} ->
1077810770
error ()
1077910771
| Str {str } ->
1078010772
Some str
10781-
| _ -> None) output
10773+
| _ -> None)
1078210774
,
10783-
Ext_array.to_list_map (fun (x : Ext_json_types.t) ->
10775+
Ext_array.to_list_map input (fun x ->
1078410776
match x with
1078510777
| Str {str = ":"} ->
1078610778
error ()
1078710779
| Str {str} ->
1078810780
Some str (* More rigirous error checking: It would trigger a ninja syntax error *)
10789-
| _ -> None) input))
10781+
| _ -> None) ))
1079010782
| _ -> error ()
1079110783
type json_map = Ext_json_types.t Map_string.t
1079210784

@@ -16968,28 +16960,18 @@ let install_target config_opt =
1696816960
let () =
1696916961
try begin
1697016962
match Sys.argv with
16971-
1697216963
| [| _ |] -> (* specialize this path [bsb.exe] which is used in watcher *)
16973-
1697416964
Bsb_ninja_regen.regenerate_ninja
1697516965
~toplevel_package_specs:None
1697616966
~forced:false
1697716967
~per_proj_dir:Bsb_global_paths.cwd |> ignore;
1697816968
ninja_command_exit [||]
16979-
1698016969
| argv ->
1698116970
begin
16982-
let i = Ext_array.rfind_with_index
16983-
argv Ext_string.equal separator in
16971+
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in
1698416972
if i < 0 then
1698516973
begin
16986-
Bsb_arg.parse_exn
16987-
~usage
16988-
~argv
16989-
16990-
bsb_main_flags
16991-
handle_anonymous_arg
16992-
;
16974+
Bsb_arg.parse_exn ~usage ~argv bsb_main_flags handle_anonymous_arg;
1699316975
(* first, check whether we're in boilerplate generation mode, aka -init foo -theme bar *)
1699416976
match !generate_theme_with_path with
1699516977
| Some path -> Bsb_theme_init.init_sample_project ~cwd:Bsb_global_paths.cwd ~theme:!current_theme path

lib/4.06.1/unstable/all_ounit_tests.ml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,8 @@ val to_list_f :
13001300
('a -> 'b) ->
13011301
'b list
13021302

1303-
val to_list_map : ('a -> 'b option) -> 'a array -> 'b list
1303+
val to_list_map :
1304+
'a array -> ('a -> 'b option) -> 'b list
13041305

13051306
val to_list_map_acc :
13061307
'a array ->
@@ -1316,12 +1317,9 @@ val of_list_map :
13161317
val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int
13171318

13181319

1319-
type 'a split = [ `No_split | `Split of 'a array * 'a array ]
13201320

1321-
val rfind_and_split :
1322-
'a array ->
1323-
('a -> 'b -> bool) ->
1324-
'b -> 'a split
1321+
type 'a split = No_split | Split of 'a array * 'a array
1322+
13251323

13261324
val find_and_split :
13271325
'a array ->
@@ -1480,7 +1478,7 @@ let rec tolist_aux a f i res =
14801478
| Some v -> v :: res
14811479
| None -> res)
14821480

1483-
let to_list_map f a =
1481+
let to_list_map a f =
14841482
tolist_aux a f (Array.length a - 1) []
14851483

14861484
let to_list_map_acc a acc f =
@@ -1555,13 +1553,7 @@ let rfind_with_index arr cmp v =
15551553
else aux (i - 1) in
15561554
aux (len - 1)
15571555

1558-
type 'a split = [ `No_split | `Split of 'a array * 'a array ]
1559-
let rfind_and_split arr cmp v : _ split =
1560-
let i = rfind_with_index arr cmp v in
1561-
if i < 0 then
1562-
`No_split
1563-
else
1564-
`Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 ))
1556+
type 'a split = No_split | Split of 'a array * 'a array
15651557

15661558

15671559
let find_with_index arr cmp v =
@@ -1575,9 +1567,9 @@ let find_with_index arr cmp v =
15751567
let find_and_split arr cmp v : _ split =
15761568
let i = find_with_index arr cmp v in
15771569
if i < 0 then
1578-
`No_split
1570+
No_split
15791571
else
1580-
`Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1))
1572+
Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1))
15811573

15821574
(** TODO: available since 4.03, use {!Array.exists} *)
15831575

@@ -2462,22 +2454,22 @@ let suites =
24622454
__LOC__ >:: begin fun _ ->
24632455
Ext_array.find_and_split
24642456
[|"a"; "b";"c"|]
2465-
Ext_string.equal "--" =~ `No_split
2457+
Ext_string.equal "--" =~ No_split
24662458
end;
24672459
__LOC__ >:: begin fun _ ->
24682460
Ext_array.find_and_split
24692461
[|"a"; "b";"c";"--"|]
2470-
Ext_string.equal "--" =~ `Split ([|"a";"b";"c"|],[||])
2462+
Ext_string.equal "--" =~ Split( [|"a";"b";"c"|], [||])
24712463
end;
24722464
__LOC__ >:: begin fun _ ->
24732465
Ext_array.find_and_split
24742466
[|"--"; "a"; "b";"c";"--"|]
2475-
Ext_string.equal "--" =~ `Split ([||], [|"a";"b";"c";"--"|])
2467+
Ext_string.equal "--" =~ Split ([||], [|"a";"b";"c";"--"|])
24762468
end;
24772469
__LOC__ >:: begin fun _ ->
24782470
Ext_array.find_and_split
24792471
[| "u"; "g"; "--"; "a"; "b";"c";"--"|]
2480-
Ext_string.equal "--" =~ `Split ([|"u";"g"|], [|"a";"b";"c";"--"|])
2472+
Ext_string.equal "--" =~ Split ([|"u";"g"|], [|"a";"b";"c";"--"|])
24812473
end;
24822474
__LOC__ >:: begin fun _ ->
24832475
Ext_array.reverse [|1;2|] =~ [|2;1|];

lib/4.06.1/unstable/bsb_native.ml

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,8 @@ val to_list_f :
20072007
('a -> 'b) ->
20082008
'b list
20092009

2010-
val to_list_map : ('a -> 'b option) -> 'a array -> 'b list
2010+
val to_list_map :
2011+
'a array -> ('a -> 'b option) -> 'b list
20112012

20122013
val to_list_map_acc :
20132014
'a array ->
@@ -2023,12 +2024,9 @@ val of_list_map :
20232024
val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int
20242025

20252026

2026-
type 'a split = [ `No_split | `Split of 'a array * 'a array ]
20272027

2028-
val rfind_and_split :
2029-
'a array ->
2030-
('a -> 'b -> bool) ->
2031-
'b -> 'a split
2028+
type 'a split = No_split | Split of 'a array * 'a array
2029+
20322030

20332031
val find_and_split :
20342032
'a array ->
@@ -2187,7 +2185,7 @@ let rec tolist_aux a f i res =
21872185
| Some v -> v :: res
21882186
| None -> res)
21892187

2190-
let to_list_map f a =
2188+
let to_list_map a f =
21912189
tolist_aux a f (Array.length a - 1) []
21922190

21932191
let to_list_map_acc a acc f =
@@ -2262,13 +2260,7 @@ let rfind_with_index arr cmp v =
22622260
else aux (i - 1) in
22632261
aux (len - 1)
22642262

2265-
type 'a split = [ `No_split | `Split of 'a array * 'a array ]
2266-
let rfind_and_split arr cmp v : _ split =
2267-
let i = rfind_with_index arr cmp v in
2268-
if i < 0 then
2269-
`No_split
2270-
else
2271-
`Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 ))
2263+
type 'a split = No_split | Split of 'a array * 'a array
22722264

22732265

22742266
let find_with_index arr cmp v =
@@ -2282,9 +2274,9 @@ let find_with_index arr cmp v =
22822274
let find_and_split arr cmp v : _ split =
22832275
let i = find_with_index arr cmp v in
22842276
if i < 0 then
2285-
`No_split
2277+
No_split
22862278
else
2287-
`Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1))
2279+
Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1))
22882280

22892281
(** TODO: available since 4.03, use {!Array.exists} *)
22902282

@@ -10802,23 +10794,23 @@ let extract_input_output (edge : Ext_json_types.t) : string list * string list =
1080210794
(match Ext_array.find_and_split content
1080310795
(fun x () -> match x with Str { str =":"} -> true | _ -> false )
1080410796
() with
10805-
| `No_split -> error ()
10806-
| `Split ( output, input) ->
10807-
(Ext_array.to_list_map (fun (x : Ext_json_types.t) ->
10797+
| No_split -> error ()
10798+
| Split ( output, input) ->
10799+
(Ext_array.to_list_map output (fun x ->
1080810800
match x with
1080910801
| Str {str = ":"} ->
1081010802
error ()
1081110803
| Str {str } ->
1081210804
Some str
10813-
| _ -> None) output
10805+
| _ -> None)
1081410806
,
10815-
Ext_array.to_list_map (fun (x : Ext_json_types.t) ->
10807+
Ext_array.to_list_map input (fun x ->
1081610808
match x with
1081710809
| Str {str = ":"} ->
1081810810
error ()
1081910811
| Str {str} ->
1082010812
Some str (* More rigirous error checking: It would trigger a ninja syntax error *)
10821-
| _ -> None) input))
10813+
| _ -> None) ))
1082210814
| _ -> error ()
1082310815
type json_map = Ext_json_types.t Map_string.t
1082410816

@@ -17134,37 +17126,18 @@ let install_target config_opt =
1713417126
let () =
1713517127
try begin
1713617128
match Sys.argv with
17137-
17138-
| [| _; "-backend"; _ |]
17139-
1714017129
| [| _ |] -> (* specialize this path [bsb.exe] which is used in watcher *)
17141-
17142-
if Array.length Sys.argv = 3 then begin match Array.get Sys.argv 2 with
17143-
| "js" -> Bsb_global_backend.set_backend Bsb_config_types.Js
17144-
| "native" -> Bsb_global_backend.set_backend Bsb_config_types.Native
17145-
| "bytecode" -> Bsb_global_backend.set_backend Bsb_config_types.Bytecode
17146-
| _ -> failwith "-backend should be one of: 'js', 'bytecode' or 'native'."
17147-
end;
17148-
1714917130
Bsb_ninja_regen.regenerate_ninja
1715017131
~toplevel_package_specs:None
1715117132
~forced:false
1715217133
~per_proj_dir:Bsb_global_paths.cwd |> ignore;
1715317134
ninja_command_exit [||]
17154-
1715517135
| argv ->
1715617136
begin
17157-
let i = Ext_array.rfind_with_index
17158-
argv Ext_string.equal separator in
17137+
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in
1715917138
if i < 0 then
1716017139
begin
17161-
Bsb_arg.parse_exn
17162-
~usage
17163-
~argv
17164-
17165-
bsb_main_flags
17166-
handle_anonymous_arg
17167-
;
17140+
Bsb_arg.parse_exn ~usage ~argv bsb_main_flags handle_anonymous_arg;
1716817141
(* first, check whether we're in boilerplate generation mode, aka -init foo -theme bar *)
1716917142
match !generate_theme_with_path with
1717017143
| Some path -> Bsb_theme_init.init_sample_project ~cwd:Bsb_global_paths.cwd ~theme:!current_theme path

0 commit comments

Comments
 (0)