Skip to content

Commit bda18cf

Browse files
authored
Merge pull request #4760 from rescript-lang/update_build_engine
update build engine
2 parents e30e3d6 + eb83f46 commit bda18cf

File tree

17 files changed

+1093
-1143
lines changed

17 files changed

+1093
-1143
lines changed

jscomp/bsb/bsb_ninja_file_groups.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ let emit_module_build
116116
;
117117
Bsb_ninja_targets.output_build oc
118118
~outputs:[output_cmi]
119-
~order_only_deps:[output_d]
119+
(* ~order_only_deps:[output_d] *)
120120
~inputs:[output_iast]
121121
~rule:(if is_dev then rules.mi_dev else rules.mi)
122122
;
@@ -131,12 +131,10 @@ let emit_module_build
131131
)
132132
in
133133
Bsb_ninja_targets.output_build oc
134-
~outputs:[output_cmj]
135-
~implicit_outputs:
136-
(if has_intf_file then output_js else output_cmi::output_js )
137-
~inputs:[output_ast]
138-
~implicit_deps:(if has_intf_file then [output_cmi] else [] )
139-
~order_only_deps:[output_d]
134+
(* ~order_only_deps:[output_d] *)
135+
~outputs:
136+
(if has_intf_file then output_cmj :: output_js else output_cmj::output_cmi::output_js)
137+
~inputs:(if has_intf_file then [output_ast; output_cmi] else [output_ast])
140138
~rule
141139
(* ;
142140
{output_cmj; output_cmi} *)

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ let get_name (x : t) oc = x.name oc
3737
let print_rule (oc : out_channel)
3838
?description
3939
?(restat : unit option)
40-
?dyndep
40+
?(dyndep : unit option)
4141
~command
4242
name =
4343
output_string oc "rule "; output_string oc name ; output_string oc "\n";
4444
output_string oc " command = "; output_string oc command; output_string oc "\n";
45-
Ext_option.iter dyndep (fun f ->
46-
output_string oc " dyndep = "; output_string oc f; output_string oc "\n"
47-
);
45+
(if dyndep <> None then
46+
output_string oc " dyndep = 1\n");
4847
(if restat <> None then
4948
output_string oc " restat = 1\n");
5049
begin match description with
@@ -170,7 +169,7 @@ let make_custom_rules
170169
Ext_buffer.add_string buf package_name;
171170
Ext_buffer.add_string buf (Bsb_package_specs.package_flag_of_package_specs package_specs "$in_d")
172171
end;
173-
Ext_buffer.add_string buf " -o $out $in";
172+
Ext_buffer.add_string buf " -o $out $i";
174173
begin match postbuild with
175174
| None -> ()
176175
| Some cmd ->
@@ -216,7 +215,7 @@ let make_custom_rules
216215
);
217216

218217
Ext_buffer.add_char_string buf ' ' bsc_flags;
219-
Ext_buffer.add_string buf " -bs-ast -o $out $in";
218+
Ext_buffer.add_string buf " -bs-ast -o $out $i";
220219
Ext_buffer.contents buf
221220
in
222221
let build_ast =
@@ -232,8 +231,8 @@ let make_custom_rules
232231
define
233232
~command:(
234233
if Ext_sys.is_windows_or_cygwin then
235-
"cmd.exe /C copy /Y $in $out > null"
236-
else "cp $in $out"
234+
"cmd.exe /C copy /Y $i $out > null"
235+
else "cp $i $out"
237236
)
238237
"copy_resource" in
239238

@@ -254,14 +253,14 @@ let make_custom_rules
254253
~command:(mk_ml_cmj_cmd
255254
~read_cmi ~is_dev:false
256255
~postbuild)
257-
~dyndep:"$in_e.d"
256+
~dyndep:()
258257
~restat:() (* Always restat when having mli *)
259258
name,
260259
define
261260
~command:(mk_ml_cmj_cmd
262261
~read_cmi ~is_dev:true
263262
~postbuild)
264-
~dyndep:"$in_e.d"
263+
~dyndep:()
265264
~restat:() (* Always restat when having mli *)
266265
(name ^ "_dev")
267266
in
@@ -278,7 +277,7 @@ let make_custom_rules
278277
~name:"mi" in
279278
let build_package =
280279
define
281-
~command:(bsc ^ " -w -49 -color always -no-alias-deps $in")
280+
~command:(bsc ^ " -w -49 -color always -no-alias-deps $i")
282281
~restat:()
283282
"build_package"
284283
in

jscomp/bsb/bsb_ninja_targets.ml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,16 @@ let oc_list xs oc =
2727
Ext_list.iter xs (fun s -> output_string oc Ext_string.single_space ; output_string oc s)
2828

2929
let output_build
30-
?(order_only_deps=[])
31-
?(implicit_deps=[])
32-
?(implicit_outputs=[])
3330
~outputs
3431
~inputs
3532
~rule
3633
oc =
3734
let rule = Bsb_ninja_rule.get_name rule oc in (* Trigger building if not used *)
3835
output_string oc "o";
3936
oc_list outputs oc;
40-
if implicit_outputs <> [] then begin
41-
output_string oc " |";
42-
oc_list implicit_outputs oc
43-
end;
4437
output_string oc " : ";
4538
output_string oc rule;
4639
oc_list inputs oc;
47-
if implicit_deps <> [] then
48-
begin
49-
output_string oc " |";
50-
oc_list implicit_deps oc
51-
end
52-
;
53-
if order_only_deps <> [] then
54-
begin
55-
output_string oc " ||";
56-
oc_list order_only_deps oc
57-
end
58-
;
5940
output_string oc "\n"
6041

6142
let phony ?(order_only_deps=[]) ~inputs ~output oc =

jscomp/bsb/bsb_ninja_targets.mli

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
however, for the command we don't need pass `-o`
3232
*)
3333
val output_build :
34-
?order_only_deps:string list ->
35-
?implicit_deps:string list ->
36-
?implicit_outputs: string list ->
34+
(* ?order_only_deps:string list -> *)
3735
outputs:string list ->
3836
inputs:string list ->
3937
rule:Bsb_ninja_rule.t ->

jscomp/depends/binary_ast.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,16 @@ let magic_sep_char = '\n'
5353
1. for performance , easy skipping and calcuate the length
5454
2. cut dependency, otherwise its type is {!Ast_extract.Set_string.t}
5555
*)
56-
let write_ast (type t) ~(sourcefile : string) ~output (kind : t kind) ( pt : t) : unit =
57-
let oc = open_out_bin output in
56+
let write_ast (type t) ~(sourcefile : string) ~output (kind : t kind) ( pt : t) : unit =
5857
let output_set = Ast_extract.read_parse_and_extract kind pt in
5958
let buf = Ext_buffer.create 1000 in
60-
6159
Ext_buffer.add_char buf magic_sep_char;
6260
Set_string.iter (fun s ->
6361
if s <> "" && s.[0] <> '*' then begin (* filter *predef* *)
6462
Ext_buffer.add_string_char buf s magic_sep_char;
6563
end
6664
) output_set ;
65+
let oc = open_out_bin output in
6766
output_binary_int oc (Ext_buffer.length buf);
6867
Ext_buffer.output_buffer oc buf;
6968
output_string oc sourcefile;

0 commit comments

Comments
 (0)