Skip to content

Commit

Permalink
Merge pull request #72 from ocaml-wasm/reduced-js-runtime
Browse files Browse the repository at this point in the history
Only link `jslib_js_of_ocaml` from the JavaScript runtime
  • Loading branch information
vouillon authored Sep 13, 2024
2 parents 9a01ecd + a02584d commit db04a4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
4 changes: 1 addition & 3 deletions compiler/bin-wasm_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,15 @@ let run
| None -> `Fst name)
in
let t1 = Timer.make () in
let builtin = Js_of_ocaml_compiler_runtime_files.runtime @ builtin in
let builtin = [Js_of_ocaml_compiler_runtime_files.jslib_js_of_ocaml] @ builtin in
List.iter builtin ~f:(fun t ->
let filename = Builtins.File.name t in
let runtimes = Linker.Fragment.parse_builtin t in
Linker.load_fragments
~ignore_always_annotation:true
~target_env:Target_env.Isomorphic
~filename
runtimes);
Linker.load_files
~ignore_always_annotation:true
~target_env:Target_env.Isomorphic
runtime_js_files;
Linker.check_deps ();
Expand Down
16 changes: 7 additions & 9 deletions compiler/lib/linker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ let list_all ?from () =
provided
StringSet.empty

let load_fragment ~ignore_always_annotation ~target_env ~filename (f : Fragment.t) =
let load_fragment ~target_env ~filename (f : Fragment.t) =
match f with
| Always_include code ->
always_included :=
Expand Down Expand Up @@ -482,8 +482,6 @@ let load_fragment ~ignore_always_annotation ~target_env ~filename (f : Fragment.
filename;
if always
then (
if not ignore_always_annotation
then
always_included :=
{ ar_filename = filename; ar_program = code; ar_requires = requires }
:: !always_included;
Expand Down Expand Up @@ -588,24 +586,24 @@ let check_deps () =
())
code_pieces

let load_file ~ignore_always_annotation ~target_env filename =
let load_file ~target_env filename =
List.iter (Fragment.parse_file filename) ~f:(fun frag ->
let (`Ok | `Ignored) =
load_fragment ~ignore_always_annotation ~target_env ~filename frag
load_fragment ~target_env ~filename frag
in
())

let load_fragments ?(ignore_always_annotation = false) ~target_env ~filename l =
let load_fragments ~target_env ~filename l =
List.iter l ~f:(fun frag ->
let (`Ok | `Ignored) =
load_fragment ~ignore_always_annotation ~target_env ~filename frag
load_fragment ~target_env ~filename frag
in
());
check_deps ()

let load_files ?(ignore_always_annotation = false) ~target_env l =
let load_files ~target_env l =
List.iter l ~f:(fun filename ->
load_file ~ignore_always_annotation ~target_env filename);
load_file ~target_env filename);
check_deps ()

(* resolve *)
Expand Down
5 changes: 2 additions & 3 deletions compiler/lib/linker.mli
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ end
val reset : unit -> unit

val load_files :
?ignore_always_annotation:bool -> target_env:Target_env.t -> string list -> unit
target_env:Target_env.t -> string list -> unit

val load_fragments :
?ignore_always_annotation:bool
-> target_env:Target_env.t
target_env:Target_env.t
-> filename:string
-> Fragment.t list
-> unit
Expand Down

0 comments on commit db04a4a

Please sign in to comment.