@@ -5940,7 +5940,7 @@ end = struct
5940
5940
* You should have received a copy of the GNU Lesser General Public License
5941
5941
* along with this program; if not, write to the Free Software
5942
5942
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
5943
- let version = "9.1.3 "
5943
+ let version = "9.1.4 "
5944
5944
let header =
5945
5945
"// Generated by ReScript, PLEASE EDIT WITH CARE"
5946
5946
let package_name = ref "rescript"
@@ -7667,6 +7667,136 @@ let of_string (x : string) : t =
7667
7667
| _ -> Unknown_extension
7668
7668
7669
7669
7670
+ end
7671
+ module Bsb_spec_set : sig
7672
+ #1 "bsb_spec_set.mli"
7673
+ (* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
7674
+ *
7675
+ * This program is free software: you can redistribute it and/or modify
7676
+ * it under the terms of the GNU Lesser General Public License as published by
7677
+ * the Free Software Foundation, either version 3 of the License, or
7678
+ * (at your option) any later version.
7679
+ *
7680
+ * In addition to the permissions granted to you by the LGPL, you may combine
7681
+ * or link a "work that uses the Library" with a publicly distributed version
7682
+ * of this file to produce a combined library or application, then distribute
7683
+ * that combined work under the terms of your choosing, with no requirement
7684
+ * to comply with the obligations normally placed on you by section 4 of the
7685
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
7686
+ * should you choose to use a later version).
7687
+ *
7688
+ * This program is distributed in the hope that it will be useful,
7689
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7690
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7691
+ * GNU Lesser General Public License for more details.
7692
+ *
7693
+ * You should have received a copy of the GNU Lesser General Public License
7694
+ * along with this program; if not, write to the Free Software
7695
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
7696
+ type format = Ext_module_system.t
7697
+ type spec = {
7698
+ format : format;
7699
+ in_source : bool;
7700
+ suffix : Ext_js_suffix.t
7701
+ }
7702
+
7703
+ type t = private spec list
7704
+ val empty : t
7705
+ val add : spec -> t -> t
7706
+ val singleton : spec -> t
7707
+ val fold : (spec -> 'a -> 'a) -> t -> 'a -> 'a
7708
+ val iter : (spec -> unit) ->t -> unit
7709
+ end = struct
7710
+ #1 "bsb_spec_set.ml"
7711
+ (* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
7712
+ *
7713
+ * This program is free software: you can redistribute it and/or modify
7714
+ * it under the terms of the GNU Lesser General Public License as published by
7715
+ * the Free Software Foundation, either version 3 of the License, or
7716
+ * (at your option) any later version.
7717
+ *
7718
+ * In addition to the permissions granted to you by the LGPL, you may combine
7719
+ * or link a "work that uses the Library" with a publicly distributed version
7720
+ * of this file to produce a combined library or application, then distribute
7721
+ * that combined work under the terms of your choosing, with no requirement
7722
+ * to comply with the obligations normally placed on you by section 4 of the
7723
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
7724
+ * should you choose to use a later version).
7725
+ *
7726
+ * This program is distributed in the hope that it will be useful,
7727
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
7728
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7729
+ * GNU Lesser General Public License for more details.
7730
+ *
7731
+ * You should have received a copy of the GNU Lesser General Public License
7732
+ * along with this program; if not, write to the Free Software
7733
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
7734
+
7735
+ [@@@warning "+9"]
7736
+ (* TODO: sync up with {!Js_packages_info.module_system} *)
7737
+ type format = Ext_module_system.t =
7738
+ | NodeJS | Es6 | Es6_global
7739
+
7740
+ type spec = {
7741
+ format : format;
7742
+ in_source : bool;
7743
+ suffix : Ext_js_suffix.t
7744
+ }
7745
+ type t = spec list
7746
+
7747
+ let cmp (s1 : spec) ({format;in_source;suffix} : spec) =
7748
+ let v = compare s1.format format in
7749
+ if v <> 0 then v
7750
+ else
7751
+ let v = compare s1.in_source in_source in
7752
+ if v <> 0 then v
7753
+ else
7754
+ compare s1.suffix suffix
7755
+
7756
+ let empty = []
7757
+
7758
+ let rec insert lst piviot =
7759
+ match lst with
7760
+ | [] -> [piviot]
7761
+ | x::xs ->
7762
+ let v = cmp piviot x in
7763
+ if v = 0 then lst
7764
+ else if v < 0 then piviot :: lst
7765
+ else
7766
+ x :: insert xs piviot
7767
+
7768
+ let add spec specs =
7769
+ match specs with
7770
+ | [] -> [spec]
7771
+ | [a] ->
7772
+ let v = cmp spec a in
7773
+ if v < 0 then spec :: specs
7774
+ else if v = 0 then specs
7775
+ else [a; spec]
7776
+ | [a;b] ->
7777
+ let v = cmp spec a in
7778
+ if v < 0 then spec :: specs
7779
+ else if v = 0 then specs
7780
+ else
7781
+ let v1 = cmp spec b in
7782
+ if v < 0 then [a;spec;b]
7783
+ else if v1 = 0 then specs
7784
+ else
7785
+ [a;b;spec]
7786
+ | _::_::_::_ -> (* unlikely to happen *)
7787
+ insert specs spec
7788
+
7789
+ let singleton x = [x]
7790
+
7791
+ let rec fold f t acc =
7792
+ match t with
7793
+ | [] -> acc
7794
+ | x::xs -> fold f xs (f x acc)
7795
+
7796
+ let rec iter f t =
7797
+ match t with
7798
+ | [] -> ()
7799
+ | x::xs -> f x ; iter f xs
7670
7800
end
7671
7801
module Ext_filename : sig
7672
7802
#1 "ext_filename.mli"
@@ -8242,20 +8372,10 @@ let (//) = Ext_path.combine
8242
8372
8243
8373
8244
8374
8245
- (* TODO: sync up with {!Js_packages_info.module_system} *)
8246
- type format = Ext_module_system.t =
8247
- | NodeJS | Es6 | Es6_global
8248
8375
8249
- type spec = {
8250
- format : format;
8251
- in_source : bool;
8252
- suffix : Ext_js_suffix.t
8253
- }
8254
8376
8255
8377
(*FIXME: use assoc list instead *)
8256
- module Spec_set = Set.Make( struct type t = spec
8257
- let compare = Pervasives.compare
8258
- end)
8378
+ module Spec_set = Bsb_spec_set
8259
8379
8260
8380
type t = {
8261
8381
modules : Spec_set.t;
@@ -8274,13 +8394,13 @@ let bad_module_format_message_exn ~loc format =
8274
8394
Literals.es6
8275
8395
Literals.es6_global
8276
8396
8277
- let supported_format (x : string) loc =
8397
+ let supported_format (x : string) loc : Ext_module_system.t =
8278
8398
if x = Literals.commonjs then NodeJS
8279
8399
else if x = Literals.es6 then Es6
8280
8400
else if x = Literals.es6_global then Es6_global
8281
8401
else bad_module_format_message_exn ~loc x
8282
8402
8283
- let string_of_format (x : format ) =
8403
+ let string_of_format (x : Ext_module_system.t ) =
8284
8404
match x with
8285
8405
| NodeJS -> Literals.commonjs
8286
8406
| Es6 -> Literals.es6
@@ -8306,7 +8426,7 @@ let rec from_array suffix (arr : Ext_json_types.t array) : Spec_set.t =
8306
8426
!spec
8307
8427
8308
8428
(* TODO: FIXME: better API without mutating *)
8309
- and from_json_single suffix (x : Ext_json_types.t) : spec =
8429
+ and from_json_single suffix (x : Ext_json_types.t) : Bsb_spec_set. spec =
8310
8430
match x with
8311
8431
| Str {str = format; loc } ->
8312
8432
{format = supported_format format loc ; in_source = false ; suffix }
@@ -8351,7 +8471,7 @@ let bs_package_output = "-bs-package-output"
8351
8471
coordinate with command line flag
8352
8472
{[ -bs-package-output commonjs:lib/js/jscomp/test:.js ]}
8353
8473
*)
8354
- let package_flag ({format; in_source; suffix } : spec) dir =
8474
+ let package_flag ({format; in_source; suffix } : Bsb_spec_set. spec) dir =
8355
8475
Ext_string.inter2
8356
8476
bs_package_output
8357
8477
(Ext_string.concat5
@@ -8366,13 +8486,30 @@ let package_flag ({format; in_source; suffix } : spec) dir =
8366
8486
(* FIXME: we should adapt it *)
8367
8487
let package_flag_of_package_specs (package_specs : t)
8368
8488
~(dirname : string ) : string =
8369
- let res = Spec_set.fold (fun format acc ->
8370
- Ext_string.inter2 acc (package_flag format dirname )
8371
- ) package_specs.modules Ext_string.empty in
8489
+ let res =
8490
+ match (package_specs.modules :> Bsb_spec_set.spec list) with
8491
+ | [] -> Ext_string.empty
8492
+ | [format] ->
8493
+ Ext_string.inter2 Ext_string.empty (package_flag format dirname)
8494
+ | [a;b] ->
8495
+ Ext_string.inter3 Ext_string.empty
8496
+ (package_flag a dirname)
8497
+ (package_flag b dirname)
8498
+ | [a;b;c] ->
8499
+ Ext_string.inter4
8500
+ Ext_string.empty
8501
+ (package_flag a dirname)
8502
+ (package_flag b dirname)
8503
+ (package_flag c dirname)
8504
+ | _ ->
8505
+ Spec_set.fold (fun format acc ->
8506
+ Ext_string.inter2 acc (package_flag format dirname )
8507
+ ) package_specs.modules Ext_string.empty in
8372
8508
match package_specs.runtime with
8373
8509
| None -> res
8374
8510
| Some x ->
8375
- res ^ " -runtime " ^ x
8511
+ Ext_string.inter3 res "-runtime" x
8512
+
8376
8513
let default_package_specs suffix =
8377
8514
Spec_set.singleton
8378
8515
{ format = NodeJS ; in_source = false; suffix }
@@ -8388,7 +8525,7 @@ let get_list_of_output_js
8388
8525
(output_file_sans_extension : string)
8389
8526
=
8390
8527
Spec_set.fold
8391
- (fun (spec : spec) acc ->
8528
+ (fun (spec : Bsb_spec_set. spec) acc ->
8392
8529
let basename =
8393
8530
Ext_namespace.change_ext_ns_suffix
8394
8531
output_file_sans_extension
@@ -8404,7 +8541,7 @@ let list_dirs_by
8404
8541
(package_specs : t)
8405
8542
(f : string -> unit)
8406
8543
=
8407
- Spec_set.iter (fun (spec : spec) ->
8544
+ Spec_set.iter (fun (spec : Bsb_spec_set. spec) ->
8408
8545
if not spec.in_source then
8409
8546
f (Bsb_config.top_prefix_of_format spec.format)
8410
8547
) package_specs.modules
@@ -8478,6 +8615,18 @@ type t =
8478
8615
override the current settings
8479
8616
*)
8480
8617
8618
+
8619
+ let encode_no_nl ( x : t) =
8620
+ match x with
8621
+ | Toplevel -> "0"
8622
+ | Dependency x ->
8623
+ "1" ^
8624
+ Bsb_package_specs.package_flag_of_package_specs x
8625
+ ~dirname:"."
8626
+ | Pinned_dependency x ->
8627
+ "2" ^
8628
+ Bsb_package_specs.package_flag_of_package_specs x
8629
+ ~dirname:"."
8481
8630
end
8482
8631
module Bsc_warnings
8483
8632
= struct
@@ -12220,11 +12369,7 @@ let record
12220
12369
let buf = Ext_buffer.create 1_000 in
12221
12370
Ext_buffer.add_string_char buf Bs_version.version '\n';
12222
12371
Ext_buffer.add_string_char buf per_proj_dir '\n';
12223
- (match package_kind with
12224
- | Toplevel -> Ext_buffer.add_string buf "0\n"
12225
- | Dependency _ -> Ext_buffer.add_string buf "1\n"
12226
- | Pinned_dependency _ -> Ext_buffer.add_string buf "2\n"
12227
- );
12372
+ Ext_buffer.add_string_char buf (Bsb_package_kind.encode_no_nl package_kind) '\n';
12228
12373
Ext_list.iter file_or_dirs (fun f ->
12229
12374
Ext_buffer.add_string_char buf f '\t';
12230
12375
Ext_buffer.add_string_char buf
@@ -12261,12 +12406,7 @@ let check
12261
12406
if per_proj_dir <> source_directory then Bsb_source_directory_changed else
12262
12407
if forced then Bsb_forced (* No need walk through *)
12263
12408
else if
12264
-
12265
- not (match package_kind, package_kind_str with
12266
- | Toplevel, "0"
12267
- | Dependency _, "1"
12268
- | Pinned_dependency _, "2" -> true
12269
- | _ -> false ) then
12409
+ (Bsb_package_kind.encode_no_nl package_kind <> package_kind_str) then
12270
12410
Bsb_package_kind_inconsistent
12271
12411
else
12272
12412
begin
@@ -16603,8 +16743,8 @@ let force_regenerate = ref false
16603
16743
type spec = Bsb_arg.spec
16604
16744
16605
16745
let call_spec f : spec = Unit (Unit_call f )
16606
- let unit_set_spec b : spec = Unit (Unit_set b)
16607
-
16746
+ let unit_set_spec b : spec = Unit (Unit_set b)
16747
+ let string_set_spec s : spec = String (String_set s)
16608
16748
16609
16749
16610
16750
let failed_annon = (fun ~rev_args ->
@@ -16710,7 +16850,12 @@ let build_subcommand ~start argv argv_len =
16710
16850
"-with-deps", unit_set_spec make_world,
16711
16851
"Build with deps";
16712
16852
"-install", unit_set_spec do_install,
16713
- "Install public interface files for dependencies ";
16853
+ "*internal* Install public interface files for dependencies ";
16854
+ (* This should be put in a subcommand
16855
+ previously it works with the implication `bsb && bsb -install`
16856
+ *)
16857
+ "-ws", string_set_spec (ref ""),
16858
+ "[host]:port set the host, port for websocket build notifications";
16714
16859
"-regen", unit_set_spec force_regenerate,
16715
16860
"*internal* \n\
16716
16861
Always regenerate build.ninja no matter bsconfig.json is changed or not";
@@ -16743,10 +16888,11 @@ let clean_subcommand ~start argv =
16743
16888
Bsb_arg.parse_exn
16744
16889
~usage:clean_usage ~start ~argv [|
16745
16890
"-with-deps", unit_set_spec make_world,
16746
- "clean its deps too"
16891
+ "*internal* Clean dependencies too";
16892
+ "-verbose", call_spec Bsb_log.verbose,
16893
+ "Set the output to be verbose";
16747
16894
|] failed_annon;
16748
- if !make_world then
16749
- Bsb_clean.clean_bs_deps Bsb_global_paths.cwd ;
16895
+ Bsb_clean.clean_bs_deps Bsb_global_paths.cwd ;
16750
16896
Bsb_clean.clean_self Bsb_global_paths.cwd
16751
16897
let init_usage = "Init the project\n\
16752
16898
rescript init [project-name]\n\
0 commit comments