Skip to content

Commit 3d9f506

Browse files
committed
finish monorepo support
1 parent 76946df commit 3d9f506

17 files changed

+108
-38
lines changed

darwin/ninja.exe

8.31 KB
Binary file not shown.

jscomp/bsb/bsb_ninja_gen.ml

+9-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,15 @@ let output_ninja_and_namespace_map
236236

237237
let oc = open_out_bin (cwd_lib_bs // Literals.build_ninja) in
238238
mark_rescript oc;
239-
(* Bsb_ninja_targets.output_kv
240-
Bsb_ninja_global_vars.src_root_dir per_proj_dir
241-
oc ; *)
239+
let finger_file =
240+
fun (x : Bsb_config_types.dependency) -> x.package_install_path //".ninja_log"
241+
in
242+
Bsb_ninja_targets.output_finger
243+
Bsb_ninja_global_vars.g_finger
244+
(String.concat " "
245+
(Ext_list.map_append bs_dependencies
246+
(Ext_list.map bs_dev_dependencies finger_file) finger_file))
247+
oc ;
242248
output_static_resources static_resources rules.copy_resources oc ;
243249
(** Generate build statement for each file *)
244250
Ext_list.iter bs_file_groups

jscomp/bsb/bsb_ninja_global_vars.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
(* let src_root_dir = "g_root"
3434
3535
let lazy_src_root_dir = "$g_root" *)
36-
36+
let g_finger = "g_finger"
3737

3838

3939

jscomp/bsb/bsb_ninja_rule.ml

+6-4
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ let make_custom_rules
125125
~package_name
126126
~bsc
127127
~warnings
128-
~bs_dep
128+
~(bs_dep : string)
129129
~(ppx_files : Bsb_config_types.ppx list)
130130
~bsc_flags
131-
~dpkg_incls
132-
~lib_incls
133-
~dev_incls
131+
~(dpkg_incls : string)
132+
~(lib_incls : string)
133+
~(dev_incls : string)
134134
(custom_rules : command Map_string.t) :
135135
builtin =
136136
(** FIXME: We don't need set [-o ${out}] when building ast
@@ -172,6 +172,8 @@ let make_custom_rules
172172
Ext_buffer.add_string buf package_name;
173173
Ext_buffer.add_string buf (Bsb_package_specs.package_flag_of_package_specs package_specs "$in_d")
174174
end;
175+
Ext_buffer.add_string buf " -bs-v ";
176+
Ext_buffer.add_ninja_prefix_var buf '-' Bsb_ninja_global_vars.g_finger;
175177
Ext_buffer.add_string buf " $i";
176178
begin match postbuild with
177179
| None -> ()

jscomp/bsb/bsb_ninja_targets.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ let phony ?(order_only_deps=[]) ~inputs ~output oc =
5252
end;
5353
output_string oc "\n"
5454

55-
let output_kv key value oc =
55+
let output_finger key value oc =
5656
output_string oc key ;
57-
output_string oc " = ";
57+
output_string oc " := ";
5858
output_string oc value ;
5959
output_string oc "\n"
6060

jscomp/bsb/bsb_ninja_targets.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ val phony :
4545
out_channel ->
4646
unit
4747

48-
val output_kv : string -> string -> out_channel -> unit
48+
val output_finger : string -> string -> out_channel -> unit

jscomp/ext/ext_buffer.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ let add_char_string b c s =
110110
b.position <- new_position
111111

112112
(* equivalent to add_char " "; add_char "$"; add_string s *)
113-
let add_ninja_prefix_var b s =
113+
let add_ninja_prefix_var b char s =
114114
let s_len = String.length s in
115115
let len = s_len + 2 in
116116
let new_position = b.position + len in
117117
if new_position > b.length then resize b len;
118118
let b_buffer = b.buffer in
119119
let b_position = b.position in
120-
Bytes.unsafe_set b_buffer b_position ' ' ;
120+
Bytes.unsafe_set b_buffer b_position char ;
121121
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
122122
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
123123
b.position <- new_position

jscomp/ext/ext_buffer.mli

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ val add_string_char :
111111

112112
val add_ninja_prefix_var :
113113
t ->
114+
char ->
114115
string ->
115116
unit
116117

lib/4.06.1/bsb.ml

+66-12
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ val add_string_char :
648648

649649
val add_ninja_prefix_var :
650650
t ->
651+
char ->
651652
string ->
652653
unit
653654

@@ -771,14 +772,14 @@ let add_char_string b c s =
771772
b.position <- new_position
772773

773774
(* equivalent to add_char " "; add_char "$"; add_string s *)
774-
let add_ninja_prefix_var b s =
775+
let add_ninja_prefix_var b char s =
775776
let s_len = String.length s in
776777
let len = s_len + 2 in
777778
let new_position = b.position + len in
778779
if new_position > b.length then resize b len;
779780
let b_buffer = b.buffer in
780781
let b_position = b.position in
781-
Bytes.unsafe_set b_buffer b_position ' ' ;
782+
Bytes.unsafe_set b_buffer b_position char ;
782783
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
783784
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
784785
b.position <- new_position
@@ -12682,6 +12683,51 @@ let output
1268212683
write_file fname digest buf
1268312684

1268412685

12686+
end
12687+
module Bsb_ninja_global_vars
12688+
= struct
12689+
#1 "bsb_ninja_global_vars.ml"
12690+
(* Copyright (C) 2017 Authors of BuckleScript
12691+
*
12692+
* This program is free software: you can redistribute it and/or modify
12693+
* it under the terms of the GNU Lesser General Public License as published by
12694+
* the Free Software Foundation, either version 3 of the License, or
12695+
* (at your option) any later version.
12696+
*
12697+
* In addition to the permissions granted to you by the LGPL, you may combine
12698+
* or link a "work that uses the Library" with a publicly distributed version
12699+
* of this file to produce a combined library or application, then distribute
12700+
* that combined work under the terms of your choosing, with no requirement
12701+
* to comply with the obligations normally placed on you by section 4 of the
12702+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
12703+
* should you choose to use a later version).
12704+
*
12705+
* This program is distributed in the hope that it will be useful,
12706+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12707+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12708+
* GNU Lesser General Public License for more details.
12709+
*
12710+
* You should have received a copy of the GNU Lesser General Public License
12711+
* along with this program; if not, write to the Free Software
12712+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
12713+
12714+
12715+
12716+
12717+
12718+
(* Invariant: the two string literal has
12719+
to be "a" and "$a"
12720+
*)
12721+
12722+
(* let src_root_dir = "g_root"
12723+
12724+
let lazy_src_root_dir = "$g_root" *)
12725+
let g_finger = "g_finger"
12726+
12727+
12728+
12729+
12730+
1268512731
end
1268612732
module Bsb_ninja_rule : sig
1268712733
#1 "bsb_ninja_rule.mli"
@@ -12907,12 +12953,12 @@ let make_custom_rules
1290712953
~package_name
1290812954
~bsc
1290912955
~warnings
12910-
~bs_dep
12956+
~(bs_dep : string)
1291112957
~(ppx_files : Bsb_config_types.ppx list)
1291212958
~bsc_flags
12913-
~dpkg_incls
12914-
~lib_incls
12915-
~dev_incls
12959+
~(dpkg_incls : string)
12960+
~(lib_incls : string)
12961+
~(dev_incls : string)
1291612962
(custom_rules : command Map_string.t) :
1291712963
builtin =
1291812964
(** FIXME: We don't need set [-o ${out}] when building ast
@@ -12954,6 +13000,8 @@ let make_custom_rules
1295413000
Ext_buffer.add_string buf package_name;
1295513001
Ext_buffer.add_string buf (Bsb_package_specs.package_flag_of_package_specs package_specs "$in_d")
1295613002
end;
13003+
Ext_buffer.add_string buf " -bs-v ";
13004+
Ext_buffer.add_ninja_prefix_var buf '-' Bsb_ninja_global_vars.g_finger;
1295713005
Ext_buffer.add_string buf " $i";
1295813006
begin match postbuild with
1295913007
| None -> ()
@@ -13143,7 +13191,7 @@ val phony :
1314313191
out_channel ->
1314413192
unit
1314513193

13146-
val output_kv : string -> string -> out_channel -> unit
13194+
val output_finger : string -> string -> out_channel -> unit
1314713195

1314813196
end = struct
1314913197
#1 "bsb_ninja_targets.ml"
@@ -13201,9 +13249,9 @@ let phony ?(order_only_deps=[]) ~inputs ~output oc =
1320113249
end;
1320213250
output_string oc "\n"
1320313251

13204-
let output_kv key value oc =
13252+
let output_finger key value oc =
1320513253
output_string oc key ;
13206-
output_string oc " = ";
13254+
output_string oc " := ";
1320713255
output_string oc value ;
1320813256
output_string oc "\n"
1320913257

@@ -13762,9 +13810,15 @@ let output_ninja_and_namespace_map
1376213810

1376313811
let oc = open_out_bin (cwd_lib_bs // Literals.build_ninja) in
1376413812
mark_rescript oc;
13765-
(* Bsb_ninja_targets.output_kv
13766-
Bsb_ninja_global_vars.src_root_dir per_proj_dir
13767-
oc ; *)
13813+
let finger_file =
13814+
fun (x : Bsb_config_types.dependency) -> x.package_install_path //".ninja_log"
13815+
in
13816+
Bsb_ninja_targets.output_finger
13817+
Bsb_ninja_global_vars.g_finger
13818+
(String.concat " "
13819+
(Ext_list.map_append bs_dependencies
13820+
(Ext_list.map bs_dev_dependencies finger_file) finger_file))
13821+
oc ;
1376813822
output_static_resources static_resources rules.copy_resources oc ;
1376913823
(** Generate build statement for each file *)
1377013824
Ext_list.iter bs_file_groups

lib/4.06.1/bsb.ml.d

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_file_groups.mli
3333
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_gen.ml
3434
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_gen.mli
35+
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_global_vars.ml
3536
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_regen.ml
3637
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_regen.mli
3738
../lib/4.06.1/bsb.ml: ./bsb/bsb_ninja_rule.ml

lib/4.06.1/bsb_helper.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,7 @@ val add_string_char :
16671667

16681668
val add_ninja_prefix_var :
16691669
t ->
1670+
char ->
16701671
string ->
16711672
unit
16721673

@@ -1790,14 +1791,14 @@ let add_char_string b c s =
17901791
b.position <- new_position
17911792

17921793
(* equivalent to add_char " "; add_char "$"; add_string s *)
1793-
let add_ninja_prefix_var b s =
1794+
let add_ninja_prefix_var b char s =
17941795
let s_len = String.length s in
17951796
let len = s_len + 2 in
17961797
let new_position = b.position + len in
17971798
if new_position > b.length then resize b len;
17981799
let b_buffer = b.buffer in
17991800
let b_position = b.position in
1800-
Bytes.unsafe_set b_buffer b_position ' ' ;
1801+
Bytes.unsafe_set b_buffer b_position char ;
18011802
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
18021803
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
18031804
b.position <- new_position

lib/4.06.1/unstable/all_ounit_tests.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6463,6 +6463,7 @@ val add_string_char :
64636463

64646464
val add_ninja_prefix_var :
64656465
t ->
6466+
char ->
64666467
string ->
64676468
unit
64686469

@@ -6586,14 +6587,14 @@ let add_char_string b c s =
65866587
b.position <- new_position
65876588

65886589
(* equivalent to add_char " "; add_char "$"; add_string s *)
6589-
let add_ninja_prefix_var b s =
6590+
let add_ninja_prefix_var b char s =
65906591
let s_len = String.length s in
65916592
let len = s_len + 2 in
65926593
let new_position = b.position + len in
65936594
if new_position > b.length then resize b len;
65946595
let b_buffer = b.buffer in
65956596
let b_position = b.position in
6596-
Bytes.unsafe_set b_buffer b_position ' ' ;
6597+
Bytes.unsafe_set b_buffer b_position char ;
65976598
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
65986599
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
65996600
b.position <- new_position

lib/4.06.1/unstable/bspack.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8811,6 +8811,7 @@ val add_string_char :
88118811

88128812
val add_ninja_prefix_var :
88138813
t ->
8814+
char ->
88148815
string ->
88158816
unit
88168817

@@ -8934,14 +8935,14 @@ let add_char_string b c s =
89348935
b.position <- new_position
89358936

89368937
(* equivalent to add_char " "; add_char "$"; add_string s *)
8937-
let add_ninja_prefix_var b s =
8938+
let add_ninja_prefix_var b char s =
89388939
let s_len = String.length s in
89398940
let len = s_len + 2 in
89408941
let new_position = b.position + len in
89418942
if new_position > b.length then resize b len;
89428943
let b_buffer = b.buffer in
89438944
let b_position = b.position in
8944-
Bytes.unsafe_set b_buffer b_position ' ' ;
8945+
Bytes.unsafe_set b_buffer b_position char ;
89458946
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
89468947
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
89478948
b.position <- new_position

lib/4.06.1/unstable/js_compiler.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -69217,6 +69217,7 @@ val add_string_char :
6921769217

6921869218
val add_ninja_prefix_var :
6921969219
t ->
69220+
char ->
6922069221
string ->
6922169222
unit
6922269223

@@ -69340,14 +69341,14 @@ let add_char_string b c s =
6934069341
b.position <- new_position
6934169342

6934269343
(* equivalent to add_char " "; add_char "$"; add_string s *)
69343-
let add_ninja_prefix_var b s =
69344+
let add_ninja_prefix_var b char s =
6934469345
let s_len = String.length s in
6934569346
let len = s_len + 2 in
6934669347
let new_position = b.position + len in
6934769348
if new_position > b.length then resize b len;
6934869349
let b_buffer = b.buffer in
6934969350
let b_position = b.position in
69350-
Bytes.unsafe_set b_buffer b_position ' ' ;
69351+
Bytes.unsafe_set b_buffer b_position char ;
6935169352
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
6935269353
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
6935369354
b.position <- new_position

lib/4.06.1/unstable/js_refmt_compiler.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -69217,6 +69217,7 @@ val add_string_char :
6921769217

6921869218
val add_ninja_prefix_var :
6921969219
t ->
69220+
char ->
6922069221
string ->
6922169222
unit
6922269223

@@ -69340,14 +69341,14 @@ let add_char_string b c s =
6934069341
b.position <- new_position
6934169342

6934269343
(* equivalent to add_char " "; add_char "$"; add_string s *)
69343-
let add_ninja_prefix_var b s =
69344+
let add_ninja_prefix_var b char s =
6934469345
let s_len = String.length s in
6934569346
let len = s_len + 2 in
6934669347
let new_position = b.position + len in
6934769348
if new_position > b.length then resize b len;
6934869349
let b_buffer = b.buffer in
6934969350
let b_position = b.position in
69350-
Bytes.unsafe_set b_buffer b_position ' ' ;
69351+
Bytes.unsafe_set b_buffer b_position char ;
6935169352
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
6935269353
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
6935369354
b.position <- new_position

lib/4.06.1/whole_compiler.ml

+3-2
Original file line numberDiff line numberDiff line change
@@ -353418,6 +353418,7 @@ val add_string_char :
353418353418

353419353419
val add_ninja_prefix_var :
353420353420
t ->
353421+
char ->
353421353422
string ->
353422353423
unit
353423353424

@@ -353541,14 +353542,14 @@ let add_char_string b c s =
353541353542
b.position <- new_position
353542353543

353543353544
(* equivalent to add_char " "; add_char "$"; add_string s *)
353544-
let add_ninja_prefix_var b s =
353545+
let add_ninja_prefix_var b char s =
353545353546
let s_len = String.length s in
353546353547
let len = s_len + 2 in
353547353548
let new_position = b.position + len in
353548353549
if new_position > b.length then resize b len;
353549353550
let b_buffer = b.buffer in
353550353551
let b_position = b.position in
353551-
Bytes.unsafe_set b_buffer b_position ' ' ;
353552+
Bytes.unsafe_set b_buffer b_position char ;
353552353553
Bytes.unsafe_set b_buffer (b_position + 1) '$' ;
353553353554
Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 2) s_len;
353554353555
b.position <- new_position

0 commit comments

Comments
 (0)