Skip to content

Commit 8cf2965

Browse files
committed
snapshot
1 parent f8c88ea commit 8cf2965

File tree

5 files changed

+360
-67
lines changed

5 files changed

+360
-67
lines changed

lib/4.06.1/bsb.ml

Lines changed: 173 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7667,6 +7667,136 @@ let of_string (x : string) : t =
76677667
| _ -> Unknown_extension
76687668

76697669

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
76707800
end
76717801
module Ext_filename : sig
76727802
#1 "ext_filename.mli"
@@ -8242,20 +8372,10 @@ let (//) = Ext_path.combine
82428372

82438373

82448374

8245-
(* TODO: sync up with {!Js_packages_info.module_system} *)
8246-
type format = Ext_module_system.t =
8247-
| NodeJS | Es6 | Es6_global
82488375

8249-
type spec = {
8250-
format : format;
8251-
in_source : bool;
8252-
suffix : Ext_js_suffix.t
8253-
}
82548376

82558377
(*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
82598379

82608380
type t = {
82618381
modules : Spec_set.t;
@@ -8274,13 +8394,13 @@ let bad_module_format_message_exn ~loc format =
82748394
Literals.es6
82758395
Literals.es6_global
82768396

8277-
let supported_format (x : string) loc =
8397+
let supported_format (x : string) loc : Ext_module_system.t =
82788398
if x = Literals.commonjs then NodeJS
82798399
else if x = Literals.es6 then Es6
82808400
else if x = Literals.es6_global then Es6_global
82818401
else bad_module_format_message_exn ~loc x
82828402

8283-
let string_of_format (x : format) =
8403+
let string_of_format (x : Ext_module_system.t) =
82848404
match x with
82858405
| NodeJS -> Literals.commonjs
82868406
| Es6 -> Literals.es6
@@ -8306,7 +8426,7 @@ let rec from_array suffix (arr : Ext_json_types.t array) : Spec_set.t =
83068426
!spec
83078427

83088428
(* 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 =
83108430
match x with
83118431
| Str {str = format; loc } ->
83128432
{format = supported_format format loc ; in_source = false ; suffix }
@@ -8351,7 +8471,7 @@ let bs_package_output = "-bs-package-output"
83518471
coordinate with command line flag
83528472
{[ -bs-package-output commonjs:lib/js/jscomp/test:.js ]}
83538473
*)
8354-
let package_flag ({format; in_source; suffix } : spec) dir =
8474+
let package_flag ({format; in_source; suffix } : Bsb_spec_set.spec) dir =
83558475
Ext_string.inter2
83568476
bs_package_output
83578477
(Ext_string.concat5
@@ -8366,13 +8486,30 @@ let package_flag ({format; in_source; suffix } : spec) dir =
83668486
(* FIXME: we should adapt it *)
83678487
let package_flag_of_package_specs (package_specs : t)
83688488
~(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
83728508
match package_specs.runtime with
83738509
| None -> res
83748510
| Some x ->
8375-
res ^ " -runtime " ^ x
8511+
Ext_string.inter3 res "-runtime" x
8512+
83768513
let default_package_specs suffix =
83778514
Spec_set.singleton
83788515
{ format = NodeJS ; in_source = false; suffix }
@@ -8388,7 +8525,7 @@ let get_list_of_output_js
83888525
(output_file_sans_extension : string)
83898526
=
83908527
Spec_set.fold
8391-
(fun (spec : spec) acc ->
8528+
(fun (spec : Bsb_spec_set.spec) acc ->
83928529
let basename =
83938530
Ext_namespace.change_ext_ns_suffix
83948531
output_file_sans_extension
@@ -8404,7 +8541,7 @@ let list_dirs_by
84048541
(package_specs : t)
84058542
(f : string -> unit)
84068543
=
8407-
Spec_set.iter (fun (spec : spec) ->
8544+
Spec_set.iter (fun (spec : Bsb_spec_set.spec) ->
84088545
if not spec.in_source then
84098546
f (Bsb_config.top_prefix_of_format spec.format)
84108547
) package_specs.modules
@@ -8478,6 +8615,18 @@ type t =
84788615
override the current settings
84798616
*)
84808617

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:"."
84818630
end
84828631
module Bsc_warnings
84838632
= struct
@@ -12220,11 +12369,7 @@ let record
1222012369
let buf = Ext_buffer.create 1_000 in
1222112370
Ext_buffer.add_string_char buf Bs_version.version '\n';
1222212371
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';
1222812373
Ext_list.iter file_or_dirs (fun f ->
1222912374
Ext_buffer.add_string_char buf f '\t';
1223012375
Ext_buffer.add_string_char buf
@@ -12261,12 +12406,7 @@ let check
1226112406
if per_proj_dir <> source_directory then Bsb_source_directory_changed else
1226212407
if forced then Bsb_forced (* No need walk through *)
1226312408
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
1227012410
Bsb_package_kind_inconsistent
1227112411
else
1227212412
begin
@@ -14175,6 +14315,7 @@ let regenerate_ninja
1417514315
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result;
1417614316
if check_result = Bsb_bsc_version_mismatch then begin
1417714317
Bsb_log.warn "@{<info>Different compiler version@}: clean current repo@.";
14318+
Bsb_clean.clean_bs_deps per_proj_dir;
1417814319
Bsb_clean.clean_self per_proj_dir;
1417914320
end ;
1418014321

lib/4.06.1/bsb.ml.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
../lib/4.06.1/bsb.ml: ./bsb/bsb_real_path.mli
5353
../lib/4.06.1/bsb.ml: ./bsb/bsb_regex.ml
5454
../lib/4.06.1/bsb.ml: ./bsb/bsb_regex.mli
55+
../lib/4.06.1/bsb.ml: ./bsb/bsb_spec_set.ml
56+
../lib/4.06.1/bsb.ml: ./bsb/bsb_spec_set.mli
5557
../lib/4.06.1/bsb.ml: ./bsb/bsb_templates.ml
5658
../lib/4.06.1/bsb.ml: ./bsb/bsb_templates.mli
5759
../lib/4.06.1/bsb.ml: ./bsb/bsb_theme_init.ml

0 commit comments

Comments
 (0)