Skip to content

update build engine #4760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions jscomp/bsb/bsb_ninja_file_groups.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ let emit_module_build
;
Bsb_ninja_targets.output_build oc
~outputs:[output_cmi]
~order_only_deps:[output_d]
(* ~order_only_deps:[output_d] *)
~inputs:[output_iast]
~rule:(if is_dev then rules.mi_dev else rules.mi)
;
Expand All @@ -131,12 +131,10 @@ let emit_module_build
)
in
Bsb_ninja_targets.output_build oc
~outputs:[output_cmj]
~implicit_outputs:
(if has_intf_file then output_js else output_cmi::output_js )
~inputs:[output_ast]
~implicit_deps:(if has_intf_file then [output_cmi] else [] )
~order_only_deps:[output_d]
(* ~order_only_deps:[output_d] *)
~outputs:
(if has_intf_file then output_cmj :: output_js else output_cmj::output_cmi::output_js)
~inputs:(if has_intf_file then [output_ast; output_cmi] else [output_ast])
~rule
(* ;
{output_cmj; output_cmi} *)
Expand Down
21 changes: 10 additions & 11 deletions jscomp/bsb/bsb_ninja_rule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ let get_name (x : t) oc = x.name oc
let print_rule (oc : out_channel)
?description
?(restat : unit option)
?dyndep
?(dyndep : unit option)
~command
name =
output_string oc "rule "; output_string oc name ; output_string oc "\n";
output_string oc " command = "; output_string oc command; output_string oc "\n";
Ext_option.iter dyndep (fun f ->
output_string oc " dyndep = "; output_string oc f; output_string oc "\n"
);
(if dyndep <> None then
output_string oc " dyndep = 1\n");
(if restat <> None then
output_string oc " restat = 1\n");
begin match description with
Expand Down Expand Up @@ -170,7 +169,7 @@ let make_custom_rules
Ext_buffer.add_string buf package_name;
Ext_buffer.add_string buf (Bsb_package_specs.package_flag_of_package_specs package_specs "$in_d")
end;
Ext_buffer.add_string buf " -o $out $in";
Ext_buffer.add_string buf " -o $out $i";
begin match postbuild with
| None -> ()
| Some cmd ->
Expand Down Expand Up @@ -216,7 +215,7 @@ let make_custom_rules
);

Ext_buffer.add_char_string buf ' ' bsc_flags;
Ext_buffer.add_string buf " -bs-ast -o $out $in";
Ext_buffer.add_string buf " -bs-ast -o $out $i";
Ext_buffer.contents buf
in
let build_ast =
Expand All @@ -232,8 +231,8 @@ let make_custom_rules
define
~command:(
if Ext_sys.is_windows_or_cygwin then
"cmd.exe /C copy /Y $in $out > null"
else "cp $in $out"
"cmd.exe /C copy /Y $i $out > null"
else "cp $i $out"
)
"copy_resource" in

Expand All @@ -254,14 +253,14 @@ let make_custom_rules
~command:(mk_ml_cmj_cmd
~read_cmi ~is_dev:false
~postbuild)
~dyndep:"$in_e.d"
~dyndep:()
~restat:() (* Always restat when having mli *)
name,
define
~command:(mk_ml_cmj_cmd
~read_cmi ~is_dev:true
~postbuild)
~dyndep:"$in_e.d"
~dyndep:()
~restat:() (* Always restat when having mli *)
(name ^ "_dev")
in
Expand All @@ -278,7 +277,7 @@ let make_custom_rules
~name:"mi" in
let build_package =
define
~command:(bsc ^ " -w -49 -color always -no-alias-deps $in")
~command:(bsc ^ " -w -49 -color always -no-alias-deps $i")
~restat:()
"build_package"
in
Expand Down
19 changes: 0 additions & 19 deletions jscomp/bsb/bsb_ninja_targets.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,16 @@ let oc_list xs oc =
Ext_list.iter xs (fun s -> output_string oc Ext_string.single_space ; output_string oc s)

let output_build
?(order_only_deps=[])
?(implicit_deps=[])
?(implicit_outputs=[])
~outputs
~inputs
~rule
oc =
let rule = Bsb_ninja_rule.get_name rule oc in (* Trigger building if not used *)
output_string oc "o";
oc_list outputs oc;
if implicit_outputs <> [] then begin
output_string oc " |";
oc_list implicit_outputs oc
end;
output_string oc " : ";
output_string oc rule;
oc_list inputs oc;
if implicit_deps <> [] then
begin
output_string oc " |";
oc_list implicit_deps oc
end
;
if order_only_deps <> [] then
begin
output_string oc " ||";
oc_list order_only_deps oc
end
;
output_string oc "\n"

let phony ?(order_only_deps=[]) ~inputs ~output oc =
Expand Down
4 changes: 1 addition & 3 deletions jscomp/bsb/bsb_ninja_targets.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
however, for the command we don't need pass `-o`
*)
val output_build :
?order_only_deps:string list ->
?implicit_deps:string list ->
?implicit_outputs: string list ->
(* ?order_only_deps:string list -> *)
outputs:string list ->
inputs:string list ->
rule:Bsb_ninja_rule.t ->
Expand Down
5 changes: 2 additions & 3 deletions jscomp/depends/binary_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ let magic_sep_char = '\n'
1. for performance , easy skipping and calcuate the length
2. cut dependency, otherwise its type is {!Ast_extract.Set_string.t}
*)
let write_ast (type t) ~(sourcefile : string) ~output (kind : t kind) ( pt : t) : unit =
let oc = open_out_bin output in
let write_ast (type t) ~(sourcefile : string) ~output (kind : t kind) ( pt : t) : unit =
let output_set = Ast_extract.read_parse_and_extract kind pt in
let buf = Ext_buffer.create 1000 in

Ext_buffer.add_char buf magic_sep_char;
Set_string.iter (fun s ->
if s <> "" && s.[0] <> '*' then begin (* filter *predef* *)
Ext_buffer.add_string_char buf s magic_sep_char;
end
) output_set ;
let oc = open_out_bin output in
output_binary_int oc (Ext_buffer.length buf);
Ext_buffer.output_buffer oc buf;
output_string oc sourcefile;
Expand Down
Loading