Skip to content

make bspack not relying on c stubs so that it can be running without compiling #4460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jscomp/ext/ext_string.ml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ let replace_backward_slash (x : string)=

let empty = ""

#if BS_BROWSER then
#if BS_BROWSER || BS_PACK then
let compare = Bs_hash_stubs.string_length_based_compare
#else
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/ext/ext_string.mli
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ val replace_backward_slash : string -> string

val empty : string

#if BS_BROWSER then
#if BS_BROWSER || BS_PACK then
val compare : string -> string -> int
#else
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/snapshot.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ build $SNAP/unstable/all_ounit_tests.ml: bspack | ./bin/bspack.exe $LTO
main = Ounit_tests_main

build $SNAP/unstable/bspack.ml: bspack | ./bin/bspack.exe $LTO
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
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
main = Bspack_main

build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe $LTO
Expand Down
2 changes: 1 addition & 1 deletion jscomp/stubs/bs_hash_stubs.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#if BS_BROWSER then
#if BS_BROWSER || BS_PACK then


let hash_string : string -> int = Hashtbl.hash
Expand Down
52 changes: 24 additions & 28 deletions lib/4.06.1/unstable/bspack.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7270,6 +7270,28 @@ let get_or arr i cb =
if i >=0 && i < Array.length arr then
Array.unsafe_get arr i
else cb ()
end
module Bs_hash_stubs
= struct
#1 "bs_hash_stubs.ml"




let hash_string : string -> int = Hashtbl.hash
let hash_string_int s i = Hashtbl.hash (s,i)
let hash_string_small_int : string -> int -> int = hash_string_int
let hash_stamp_and_name (i:int) (s:string) = Hashtbl.hash(i,s)
let hash_int (i:int) = Hashtbl.hash i
let string_length_based_compare (x : string ) (y : string) =
let len1 = String.length x in
let len2 = String.length y in
if len1 = len2 then String.compare x y
else compare (len1:int) len2
let int_unsafe_blit: int array -> int -> int array -> int -> int -> unit =
Array.blit


end
module Ext_bytes : sig
#1 "ext_bytes.mli"
Expand Down Expand Up @@ -7515,7 +7537,7 @@ val replace_backward_slash : string -> string
val empty : string


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

val single_space : string

Expand Down Expand Up @@ -7897,7 +7919,7 @@ let replace_backward_slash (x : string)=
let empty = ""


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

let single_space = " "
let single_colon = ":"
Expand Down Expand Up @@ -10826,32 +10848,6 @@ let protect_list rvs body =
List.iter2 (fun (x,_) old -> x := old) rvs olds;
raise e

end
module Bs_hash_stubs
= struct
#1 "bs_hash_stubs.ml"


external hash_string : string -> int = "caml_bs_hash_string" [@@noalloc];;

external hash_string_int : string -> int -> int = "caml_bs_hash_string_and_int" [@@noalloc];;

external hash_string_small_int : string -> int -> int = "caml_bs_hash_string_and_small_int" [@@noalloc];;

external hash_stamp_and_name : int -> string -> int = "caml_bs_hash_stamp_and_name" [@@noalloc];;

external hash_small_int : int -> int = "caml_bs_hash_small_int" [@@noalloc];;

external hash_int : int -> int = "caml_bs_hash_int" [@@noalloc];;

external string_length_based_compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;

external
int_unsafe_blit :
int array -> int -> int array -> int -> int -> unit = "caml_int_array_blit" [@@noalloc];;



end
module Ext_util : sig
#1 "ext_util.mli"
Expand Down