Skip to content
Open
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
39 changes: 39 additions & 0 deletions src/dune_rules/exe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ let link_js
~promote
~link_time_code_gen
~jsoo_mode
~standalone_runtime
cctx
=
let in_context =
Expand Down Expand Up @@ -285,6 +286,7 @@ let link_js
~link_time_code_gen
~linkall
~jsoo_mode
~standalone_runtime
;;

type dep_graphs = { for_exes : Module.t list Action_builder.t list }
Expand All @@ -306,6 +308,39 @@ let link_many
in
let modules = Compilation_context.modules cctx in
let* link_time_code_gen = Link_time_code_gen.handle_special_libs cctx in
(* Build shared jsoo standalone runtimes (one per mode) *)
let* (shared_runtimes : Jsoo_rules.standalone_runtime option Js_of_ocaml.Mode.Pair.t) =
let in_context_for jsoo_mode =
Compilation_context.js_of_ocaml cctx
|> Js_of_ocaml.Mode.Pair.select ~mode:jsoo_mode
|> Option.value ~default:Js_of_ocaml.In_context.default
in
let loc =
match programs with
| p :: _ -> p.Program.loc
| [] -> Loc.none
in
let+ js =
if List.exists linkages ~f:(Linkage.is_jsoo ~mode:JS)
then
Jsoo_rules.build_standalone_runtime
cctx
~loc
~in_context:(in_context_for JS)
~jsoo_mode:JS
else Memo.return None
and+ wasm =
if List.exists linkages ~f:(Linkage.is_jsoo ~mode:Wasm)
then
Jsoo_rules.build_standalone_runtime
cctx
~loc
~in_context:(in_context_for Wasm)
~jsoo_mode:Wasm
else Memo.return None
in
{ Js_of_ocaml.Mode.Pair.js; wasm }
in
let+ for_exes =
Memo.parallel_map programs ~f:(fun { Program.name; main_module_name; loc } ->
let top_sorted_modules =
Expand Down Expand Up @@ -338,6 +373,9 @@ let link_many
match linkage.Linkage.mode with
| Jsoo jsoo_mode ->
let obj_dir = Compilation_context.obj_dir cctx in
let standalone_runtime =
Js_of_ocaml.Mode.Pair.select ~mode:jsoo_mode shared_runtimes
in
link_js
~loc
~name
Expand All @@ -348,6 +386,7 @@ let link_many
cctx
~link_time_code_gen
~jsoo_mode
~standalone_runtime
| Ocaml linkage_mode ->
let* link_time_code_gen =
match Linkage.is_plugin linkage with
Expand Down
3 changes: 2 additions & 1 deletion src/dune_rules/gen_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ let gen_rules ctx sctx ~dir components : Gen_rules.result Memo.t =
has_rules
~dir
(match rest with
| [] -> Subdir_set.all
| [] | [ _ ] -> Subdir_set.all
| [ _; ".runtime" ] -> Subdir_set.all
| _ -> Subdir_set.empty)
(fun () ->
(* XXX the use of the super context is dubious here. We're using it to
Expand Down
Loading
Loading