Skip to content

Commit 0784d69

Browse files
authored
Merge pull request #4836 from rescript-lang/mark_rescript
finish monorepo support
2 parents 3647256 + 3d9f506 commit 0784d69

17 files changed

+108
-38
lines changed

darwin/ninja.exe

8.31 KB
Binary file not shown.

jscomp/bsb/bsb_ninja_gen.ml

Lines changed: 9 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 66 additions & 12 deletions
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

Lines changed: 1 addition & 0 deletions
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

0 commit comments

Comments
 (0)