From 06c04475e0d15c91329976ed0bda671095d93249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ojeda=20B=C3=A4r?= Date: Tue, 16 Oct 2018 09:24:20 +0200 Subject: [PATCH] js_of_ocaml: look for runtime in the same dir as executable if ocamlfind pkg unavailable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Ojeda Bär --- src/js_of_ocaml_rules.ml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/js_of_ocaml_rules.ml b/src/js_of_ocaml_rules.ml index 350ba820c452..55a7c40791b6 100644 --- a/src/js_of_ocaml_rules.ml +++ b/src/js_of_ocaml_rules.ml @@ -19,6 +19,9 @@ 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) @@ -26,15 +29,19 @@ let runtime_file ~sctx file = ~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