Skip to content

Commit 9d8e3a0

Browse files
authored
Merge pull request #4460 from BuckleScript/bspack_no_c_stubs
make bspack not relying on c stubs so that it can be running without compiling
2 parents e8f2190 + be63e86 commit 9d8e3a0

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

jscomp/ext/ext_string.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ let replace_backward_slash (x : string)=
332332

333333
let empty = ""
334334

335-
#if BS_BROWSER then
335+
#if BS_BROWSER || BS_PACK then
336336
let compare = Bs_hash_stubs.string_length_based_compare
337337
#else
338338
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;

jscomp/ext/ext_string.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ val replace_backward_slash : string -> string
164164

165165
val empty : string
166166

167-
#if BS_BROWSER then
167+
#if BS_BROWSER || BS_PACK then
168168
val compare : string -> string -> int
169169
#else
170170
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;

jscomp/snapshot.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ build $SNAP/unstable/all_ounit_tests.ml: bspack | ./bin/bspack.exe $LTO
4848
main = Ounit_tests_main
4949

5050
build $SNAP/unstable/bspack.ml: bspack | ./bin/bspack.exe $LTO
51-
flags = -bs-MD -module-alias Config=Config_whole_compiler -I $OCAML_SRC_PARSING -I $OCAML_SRC_UTILS -I stubs -I ext -I common -I depends -I core -I main -bs-main Bspack_main
51+
flags = -D BS_PACK=true -bs-MD -module-alias Config=Config_whole_compiler -I $OCAML_SRC_PARSING -I $OCAML_SRC_UTILS -I stubs -I ext -I common -I depends -I core -I main -bs-main Bspack_main
5252
main = Bspack_main
5353

5454
build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe $LTO

jscomp/stubs/bs_hash_stubs.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#if BS_BROWSER then
2+
#if BS_BROWSER || BS_PACK then
33

44

55
let hash_string : string -> int = Hashtbl.hash

lib/4.06.1/unstable/bspack.ml

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7270,6 +7270,28 @@ let get_or arr i cb =
72707270
if i >=0 && i < Array.length arr then
72717271
Array.unsafe_get arr i
72727272
else cb ()
7273+
end
7274+
module Bs_hash_stubs
7275+
= struct
7276+
#1 "bs_hash_stubs.ml"
7277+
7278+
7279+
7280+
7281+
let hash_string : string -> int = Hashtbl.hash
7282+
let hash_string_int s i = Hashtbl.hash (s,i)
7283+
let hash_string_small_int : string -> int -> int = hash_string_int
7284+
let hash_stamp_and_name (i:int) (s:string) = Hashtbl.hash(i,s)
7285+
let hash_int (i:int) = Hashtbl.hash i
7286+
let string_length_based_compare (x : string ) (y : string) =
7287+
let len1 = String.length x in
7288+
let len2 = String.length y in
7289+
if len1 = len2 then String.compare x y
7290+
else compare (len1:int) len2
7291+
let int_unsafe_blit: int array -> int -> int array -> int -> int -> unit =
7292+
Array.blit
7293+
7294+
72737295
end
72747296
module Ext_bytes : sig
72757297
#1 "ext_bytes.mli"
@@ -7515,7 +7537,7 @@ val replace_backward_slash : string -> string
75157537
val empty : string
75167538

75177539

7518-
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
7540+
val compare : string -> string -> int
75197541

75207542
val single_space : string
75217543

@@ -7897,7 +7919,7 @@ let replace_backward_slash (x : string)=
78977919
let empty = ""
78987920

78997921

7900-
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
7922+
let compare = Bs_hash_stubs.string_length_based_compare
79017923

79027924
let single_space = " "
79037925
let single_colon = ":"
@@ -10826,32 +10848,6 @@ let protect_list rvs body =
1082610848
List.iter2 (fun (x,_) old -> x := old) rvs olds;
1082710849
raise e
1082810850

10829-
end
10830-
module Bs_hash_stubs
10831-
= struct
10832-
#1 "bs_hash_stubs.ml"
10833-
10834-
10835-
external hash_string : string -> int = "caml_bs_hash_string" [@@noalloc];;
10836-
10837-
external hash_string_int : string -> int -> int = "caml_bs_hash_string_and_int" [@@noalloc];;
10838-
10839-
external hash_string_small_int : string -> int -> int = "caml_bs_hash_string_and_small_int" [@@noalloc];;
10840-
10841-
external hash_stamp_and_name : int -> string -> int = "caml_bs_hash_stamp_and_name" [@@noalloc];;
10842-
10843-
external hash_small_int : int -> int = "caml_bs_hash_small_int" [@@noalloc];;
10844-
10845-
external hash_int : int -> int = "caml_bs_hash_int" [@@noalloc];;
10846-
10847-
external string_length_based_compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
10848-
10849-
external
10850-
int_unsafe_blit :
10851-
int array -> int -> int array -> int -> int -> unit = "caml_int_array_blit" [@@noalloc];;
10852-
10853-
10854-
1085510851
end
1085610852
module Ext_util : sig
1085710853
#1 "ext_util.mli"

0 commit comments

Comments
 (0)