@@ -1787,67 +1787,6 @@ let parse_exn (speclist : t) anonfun errmsg =
1787
1787
*)
1788
1788
1789
1789
end
1790
- module Ext_digest : sig
1791
- #1 " ext_digest.mli"
1792
- (* Copyright (C) 2019- Authors of BuckleScript
1793
- *
1794
- * This program is free software: you can redistribute it and/or modify
1795
- * it under the terms of the GNU Lesser General Public License as published by
1796
- * the Free Software Foundation, either version 3 of the License, or
1797
- * (at your option) any later version.
1798
- *
1799
- * In addition to the permissions granted to you by the LGPL, you may combine
1800
- * or link a "work that uses the Library" with a publicly distributed version
1801
- * of this file to produce a combined library or application, then distribute
1802
- * that combined work under the terms of your choosing, with no requirement
1803
- * to comply with the obligations normally placed on you by section 4 of the
1804
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
1805
- * should you choose to use a later version).
1806
- *
1807
- * This program is distributed in the hope that it will be useful,
1808
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1809
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1810
- * GNU Lesser General Public License for more details.
1811
- *
1812
- * You should have received a copy of the GNU Lesser General Public License
1813
- * along with this program; if not, write to the Free Software
1814
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1815
-
1816
-
1817
- val length : int
1818
-
1819
- val hex_length : int
1820
- end = struct
1821
- #1 " ext_digest.ml"
1822
- (* Copyright (C) 2019- Authors of BuckleScript
1823
- *
1824
- * This program is free software: you can redistribute it and/or modify
1825
- * it under the terms of the GNU Lesser General Public License as published by
1826
- * the Free Software Foundation, either version 3 of the License, or
1827
- * (at your option) any later version.
1828
- *
1829
- * In addition to the permissions granted to you by the LGPL, you may combine
1830
- * or link a "work that uses the Library" with a publicly distributed version
1831
- * of this file to produce a combined library or application, then distribute
1832
- * that combined work under the terms of your choosing, with no requirement
1833
- * to comply with the obligations normally placed on you by section 4 of the
1834
- * LGPL version 3 (or the corresponding section of a later version of the LGPL
1835
- * should you choose to use a later version).
1836
- *
1837
- * This program is distributed in the hope that it will be useful,
1838
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1839
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1840
- * GNU Lesser General Public License for more details.
1841
- *
1842
- * You should have received a copy of the GNU Lesser General Public License
1843
- * along with this program; if not, write to the Free Software
1844
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
1845
-
1846
-
1847
- let length = 16
1848
-
1849
- let hex_length = 32
1850
- end
1851
1790
module Ext_pervasives : sig
1852
1791
#1 " ext_pervasives.mli"
1853
1792
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -3304,19 +3243,7 @@ module Bsb_db_decode : sig
3304
3243
3305
3244
type t
3306
3245
3307
- type group = {
3308
- modules : string array ;
3309
- dir_length : int ;
3310
- dir_info_offset : int ;
3311
- module_info_offset : int ;
3312
- }
3313
-
3314
- (* exposed only for testing *)
3315
- val decode_internal :
3316
- string ->
3317
- int ref ->
3318
- group array
3319
-
3246
+ type group
3320
3247
3321
3248
3322
3249
val read_build_cache :
@@ -3363,49 +3290,49 @@ end = struct
3363
3290
let bsbuild_cache = Literals. bsbuild_cache
3364
3291
3365
3292
3366
- type group = {
3367
- modules : string array ;
3368
- dir_length : int ;
3369
- dir_info_offset : int ;
3370
- module_info_offset : int ;
3371
- }
3293
+ type group =
3294
+ | Dummy
3295
+ | Group of {
3296
+ modules : string array ;
3297
+ dir_length : int ;
3298
+ dir_info_offset : int ;
3299
+ module_info_offset : int ;
3300
+ }
3372
3301
3373
- type t = group array * string (* string is whole content*)
3302
+ type t = {
3303
+ lib : group ;
3304
+ dev : group ;
3305
+ content : string (* string is whole content*)
3306
+ }
3374
3307
3375
3308
3376
3309
type cursor = int ref
3377
3310
3378
3311
3379
3312
(* TODO: special case when module_count is zero *)
3380
- let rec decode_internal (x : string ) (offset : cursor ) =
3381
- (* let len = Ext_pervasives.parse_nat_of_string x offset in
3382
- incr offset; *)
3313
+ let rec decode_internal (x : string ) : t =
3314
+ let (offset : cursor ) = ref 0 in
3383
3315
let lib = decode_single x offset in
3384
3316
let dev = decode_single x offset in
3385
- [|lib;dev|]
3386
- (* if len = 1 then [|first|]
3387
- else
3388
- let result = Array.make len first in
3389
- for i = 1 to len - 1 do
3390
- Array.unsafe_set result i (decode_single x offset)
3391
- done ;
3392
- result
3393
- *)
3317
+ {lib; dev; content = x}
3318
+
3394
3319
and decode_single (x : string ) (offset : cursor ) : group =
3395
3320
let module_number = Ext_pervasives. parse_nat_of_string x offset in
3396
3321
incr offset;
3397
- let modules = decode_modules x offset module_number in
3398
- let dir_info_offset = ! offset in
3399
- let module_info_offset =
3400
- String. index_from x dir_info_offset '\n' + 1 in
3401
- let dir_length = Char. code x.[module_info_offset] - 48 (* Char.code '0'*) in
3402
- offset :=
3403
- module_info_offset +
3404
- 1 +
3405
- dir_length * module_number +
3406
- 1
3322
+ if module_number <> 0 then begin
3323
+ let modules = decode_modules x offset module_number in
3324
+ let dir_info_offset = ! offset in
3325
+ let module_info_offset =
3326
+ String. index_from x dir_info_offset '\n' + 1 in
3327
+ let dir_length = Char. code x.[module_info_offset] - 48 (* Char.code '0'*) in
3328
+ offset :=
3329
+ module_info_offset +
3330
+ 1 +
3331
+ dir_length * module_number +
3332
+ 1
3407
3333
;
3408
- { modules ; dir_info_offset; module_info_offset ; dir_length}
3334
+ Group { modules ; dir_info_offset; module_info_offset ; dir_length}
3335
+ end else Dummy
3409
3336
and decode_modules (x : string ) (offset : cursor ) module_number : string array =
3410
3337
let result = Array. make module_number " " in
3411
3338
let last = ref ! offset in
@@ -3431,7 +3358,7 @@ and decode_modules (x : string) (offset : cursor) module_number : string array =
3431
3358
let read_build_cache ~dir : t =
3432
3359
let all_content =
3433
3360
Ext_io. load_file (Filename. concat dir bsbuild_cache) in
3434
- decode_internal all_content ( ref ( Ext_digest. length + 1 )), all_content
3361
+ decode_internal all_content
3435
3362
3436
3363
3437
3364
@@ -3442,11 +3369,13 @@ type module_info = {
3442
3369
3443
3370
3444
3371
let find_opt
3445
- (( sorteds , whole ) : t )
3446
- ( i : int ) (key : string )
3372
+ ({ content = whole } as db : t )
3373
+ lib (key : string )
3447
3374
: module_info option =
3448
- let group = sorteds.(i) in
3449
- let i = Ext_string_array. find_sorted group.modules key in
3375
+ match if lib then db.lib else db.dev with
3376
+ | Dummy -> None
3377
+ | Group ({modules ;} as group ) ->
3378
+ let i = Ext_string_array. find_sorted modules key in
3450
3379
match i with
3451
3380
| None -> None
3452
3381
| Some count ->
@@ -3472,12 +3401,12 @@ let find_opt
3472
3401
Some {case ; dir_name = String. sub whole dir_name_start (dir_name_finish - dir_name_start)}
3473
3402
3474
3403
let find db dependent_module is_not_lib_dir =
3475
- let opt = find_opt db 0 dependent_module in
3404
+ let opt = find_opt db true dependent_module in
3476
3405
match opt with
3477
3406
| Some _ -> opt
3478
3407
| None ->
3479
3408
if is_not_lib_dir then
3480
- find_opt db 1 dependent_module
3409
+ find_opt db false dependent_module
3481
3410
else None
3482
3411
end
3483
3412
module Ext_filename : sig
0 commit comments