Skip to content

Commit c1d2292

Browse files
committed
clean up info types
1 parent 349fd9e commit c1d2292

File tree

5 files changed

+90
-48
lines changed

5 files changed

+90
-48
lines changed

jscomp/bin/bsb.ml

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7080,7 +7080,14 @@ val phony :
70807080

70817081
val output_kvs : (string * string) list -> out_channel -> unit
70827082

7083-
type info = string list * string list
7083+
type info = {
7084+
all_config_deps : string list ;
7085+
all_installs : string list
7086+
}
7087+
7088+
val zero : info
7089+
7090+
70847091
val handle_file_groups : out_channel ->
70857092
package_specs:Bsb_default.package_specs ->
70867093
js_post_build_cmd:string option ->
@@ -7349,17 +7356,25 @@ let output_kvs kvs oc =
73497356

73507357

73517358
let (//) = Ext_filename.combine
7352-
type info = string list * string list
73537359

7354-
let zero : info = ([],[])
7360+
type info =
7361+
{ all_config_deps : string list ;
7362+
all_installs : string list}
7363+
7364+
let zero : info =
7365+
{ all_config_deps = [] ;
7366+
all_installs = []
7367+
}
73557368

73567369
let (++) (us : info) (vs : info) =
73577370
if us == zero then vs else
73587371
if vs == zero then us
73597372
else
7360-
let (xs,ys) = us in
7361-
let (xxs,yys) = vs in
7362-
(xs @ xxs, ys @ yys)
7373+
{
7374+
all_config_deps = us.all_config_deps @ vs.all_config_deps
7375+
;
7376+
all_installs = us.all_installs @ vs.all_installs
7377+
}
73637378

73647379

73657380

@@ -7374,7 +7389,7 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
73747389
| Export_all -> true
73757390
| Export_none -> false
73767391
| Export_set set -> String_set.mem module_name set in
7377-
let emit_build (kind : [`Ml | `Mll | `Re | `Mli | `Rei ]) input =
7392+
let emit_build (kind : [`Ml | `Mll | `Re | `Mli | `Rei ]) input : info =
73787393
let filename_sans_extension = Filename.chop_extension input in
73797394
let input = Bsb_config.proj_rel input in
73807395
let output_file_sans_extension = filename_sans_extension in
@@ -7487,7 +7502,8 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
74877502
~rule:Rules.copy_resources
74887503
)
74897504
end;
7490-
([output_mlastd] , [output_cmi])
7505+
{all_config_deps = [output_mlastd]; all_installs = [output_cmi]; }
7506+
74917507
end
74927508
| `Mli
74937509
| `Rei ->
@@ -7518,8 +7534,12 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
75187534
~input:output_cmi
75197535
~rule:Rules.copy_resources
75207536
end;
7521-
([output_mliastd] ,
7522-
[output_cmi] )
7537+
{
7538+
all_config_deps = [output_mliastd];
7539+
all_installs = [output_cmi] ;
7540+
7541+
}
7542+
75237543
end
75247544
in
75257545
begin match module_info.ml with
@@ -7626,6 +7646,10 @@ end = struct
76267646

76277647
let (//) = Ext_filename.combine
76287648

7649+
(* we need copy package.json into [_build] since it does affect build output
7650+
it is a bad idea to copy package.json which requires to copy js files
7651+
*)
7652+
76297653
let output_ninja
76307654
~builddir
76317655
~cwd
@@ -7697,23 +7721,16 @@ let output_ninja
76977721

76987722
]
76997723
in
7700-
let all_deps, all_cmis =
7724+
let all_info =
77017725
Bsb_ninja.handle_file_groups oc
7702-
~js_post_build_cmd ~package_specs bs_file_groups ([],[]) in
7703-
let all_deps =
7704-
(* we need copy package.json into [_build] since it does affect build output *)
7705-
(*
7706-
it is a bad idea to copy package.json which requires to copy js files
7707-
*)
7708-
static_resources
7709-
|> List.fold_left (fun all_deps x ->
7710-
Bsb_ninja.output_build oc
7726+
~js_post_build_cmd ~package_specs bs_file_groups Bsb_ninja.zero in
7727+
let () =
7728+
List.iter (fun x -> Bsb_ninja.output_build oc
77117729
~output:x
77127730
~input:(Bsb_config.proj_rel x)
7713-
~rule:Bsb_ninja.Rules.copy_resources;
7714-
x:: all_deps
7715-
) all_deps in
7716-
Bsb_ninja.phony oc ~order_only_deps:all_deps
7731+
~rule:Bsb_ninja.Rules.copy_resources) static_resources in
7732+
7733+
Bsb_ninja.phony oc ~order_only_deps:(static_resources @ all_info.all_config_deps)
77177734
~inputs:[]
77187735
~output:Literals.build_ninja ;
77197736
close_out oc;

jscomp/bsb/bsb_gen.ml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
let (//) = Ext_filename.combine
2626

27+
(* we need copy package.json into [_build] since it does affect build output
28+
it is a bad idea to copy package.json which requires to copy js files
29+
*)
30+
2731
let output_ninja
2832
~builddir
2933
~cwd
@@ -95,23 +99,15 @@ let output_ninja
9599

96100
]
97101
in
98-
let all_deps, all_cmis =
102+
let all_info =
99103
Bsb_ninja.handle_file_groups oc
100-
~js_post_build_cmd ~package_specs bs_file_groups ([],[]) in
101-
let all_deps =
102-
(* we need copy package.json into [_build] since it does affect build output *)
103-
(*
104-
it is a bad idea to copy package.json which requires to copy js files
105-
*)
106-
static_resources
107-
|> List.fold_left (fun all_deps x ->
108-
Bsb_ninja.output_build oc
104+
~js_post_build_cmd ~package_specs bs_file_groups Bsb_ninja.zero in
105+
let () =
106+
List.iter (fun x -> Bsb_ninja.output_build oc
109107
~output:x
110108
~input:(Bsb_config.proj_rel x)
111-
~rule:Bsb_ninja.Rules.copy_resources;
112-
x:: all_deps
113-
) all_deps in
114-
Bsb_ninja.phony oc ~order_only_deps:all_deps
109+
~rule:Bsb_ninja.Rules.copy_resources) static_resources in
110+
Bsb_ninja.phony oc ~order_only_deps:(static_resources @ all_info.all_config_deps)
115111
~inputs:[]
116112
~output:Literals.build_ninja ;
117113
close_out oc;

jscomp/bsb/bsb_ninja.ml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,25 @@ let output_kvs kvs oc =
258258

259259

260260
let (//) = Ext_filename.combine
261-
type info = string list * string list
262261

263-
let zero : info = ([],[])
262+
type info =
263+
{ all_config_deps : string list ;
264+
all_installs : string list}
265+
266+
let zero : info =
267+
{ all_config_deps = [] ;
268+
all_installs = []
269+
}
264270

265271
let (++) (us : info) (vs : info) =
266272
if us == zero then vs else
267273
if vs == zero then us
268274
else
269-
let (xs,ys) = us in
270-
let (xxs,yys) = vs in
271-
(xs @ xxs, ys @ yys)
275+
{
276+
all_config_deps = us.all_config_deps @ vs.all_config_deps
277+
;
278+
all_installs = us.all_installs @ vs.all_installs
279+
}
272280

273281

274282

@@ -283,7 +291,7 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
283291
| Export_all -> true
284292
| Export_none -> false
285293
| Export_set set -> String_set.mem module_name set in
286-
let emit_build (kind : [`Ml | `Mll | `Re | `Mli | `Rei ]) input =
294+
let emit_build (kind : [`Ml | `Mll | `Re | `Mli | `Rei ]) input : info =
287295
let filename_sans_extension = Filename.chop_extension input in
288296
let input = Bsb_config.proj_rel input in
289297
let output_file_sans_extension = filename_sans_extension in
@@ -396,7 +404,8 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
396404
~rule:Rules.copy_resources
397405
)
398406
end;
399-
([output_mlastd] , [output_cmi])
407+
{all_config_deps = [output_mlastd]; all_installs = [output_cmi]; }
408+
400409
end
401410
| `Mli
402411
| `Rei ->
@@ -427,8 +436,12 @@ let handle_file_group oc ~package_specs ~js_post_build_cmd acc (group: Bsb_buil
427436
~input:output_cmi
428437
~rule:Rules.copy_resources
429438
end;
430-
([output_mliastd] ,
431-
[output_cmi] )
439+
{
440+
all_config_deps = [output_mliastd];
441+
all_installs = [output_cmi] ;
442+
443+
}
444+
432445
end
433446
in
434447
begin match module_info.ml with

jscomp/bsb/bsb_ninja.mli

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ val phony :
7272

7373
val output_kvs : (string * string) list -> out_channel -> unit
7474

75-
type info = string list * string list
75+
type info = {
76+
all_config_deps : string list ;
77+
all_installs : string list
78+
}
79+
80+
val zero : info
81+
82+
7683
val handle_file_groups : out_channel ->
7784
package_specs:Bsb_default.package_specs ->
7885
js_post_build_cmd:string option ->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let ((>::),
2+
(>:::)) = OUnit.((>::),(>:::))
3+
4+
let (=~) = OUnit.assert_equal
5+
let suites =
6+
__FILE__
7+
>::: [
8+
9+
]

0 commit comments

Comments
 (0)