Skip to content

Commit

Permalink
js_of_ocaml: look for runtime in the same dir as executable if ocamlf…
Browse files Browse the repository at this point in the history
…ind pkg unavailable

Signed-off-by: Nicolás Ojeda Bär <[email protected]>
  • Loading branch information
nojb committed Oct 16, 2018
1 parent d93fad9 commit 06c0447
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/js_of_ocaml_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,29 @@ let install_jsoo_hint = "try: opam install js_of_ocaml-compiler"
let in_build_dir ~ctx args =
Path.L.relative ctx.Context.build_dir (".js" :: args)

let jsoo sctx =
SC.resolve_program sctx ~loc:None ~hint:install_jsoo_hint "js_of_ocaml"

let runtime_file ~sctx file =
match
Artifacts.file_of_lib (SC.artifacts sctx)
~loc:Loc.none
~lib:(Lib_name.of_string_exn ~loc:None "js_of_ocaml-compiler") ~file
with
| Error _ ->
Arg_spec.Dyn (fun _ ->
Utils.library_not_found ~context:(SC.context sctx).name
~hint:install_jsoo_hint
"js_of_ocaml-compiler")
begin match jsoo sctx with
| Ok path when Path.exists (Path.relative path file) ->
Arg_spec.Dep path
| _ ->
Arg_spec.Dyn (fun _ ->
Utils.library_not_found ~context:(SC.context sctx).name
~hint:install_jsoo_hint
"js_of_ocaml-compiler")
end
| Ok f -> Arg_spec.Dep f

let js_of_ocaml_rule sctx ~dir ~flags ~spec ~target =
let jsoo =
SC.resolve_program sctx ~loc:None ~hint:install_jsoo_hint "js_of_ocaml" in
let jsoo = jsoo sctx in
let runtime = runtime_file ~sctx "runtime.js" in
Build.run ~dir
jsoo
Expand Down

0 comments on commit 06c0447

Please sign in to comment.