Skip to content
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

js_of_ocaml: look for runtime in the same dir as executable if ocamlfind pkg unavailable #1467

Merged
2 commits merged into from
Dec 19, 2018
Merged
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: 27 additions & 12 deletions src/js_of_ocaml_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,44 @@ 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 runtime_file ~sctx file =
let jsoo ~dir sctx =
SC.resolve_program sctx ~dir ~loc:None ~hint:install_jsoo_hint
"js_of_ocaml"

let runtime_file ~dir ~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")
| Ok f -> Arg_spec.Dep f
let fail =
let fail () =
Utils.library_not_found ~context:(SC.context sctx).name
~hint:install_jsoo_hint
"js_of_ocaml-compiler"
in
Build.fail {fail}
in
begin match jsoo ~dir sctx with
| Ok path ->
let path = Path.relative (Path.parent_exn path) file in
Build.if_file_exists path ~then_:(Build.arr (fun _ -> path)) ~else_:fail
| _ ->
fail
end
| Ok f ->
Build.arr (fun _ -> f)

let js_of_ocaml_rule sctx ~dir ~flags ~spec ~target =
let jsoo =
SC.resolve_program sctx ~dir ~loc:None ~hint:install_jsoo_hint
"js_of_ocaml" in
let runtime = runtime_file ~sctx "runtime.js" in
let jsoo = jsoo ~dir sctx in
(Build.arr (fun x -> x) &&& runtime_file ~dir ~sctx "runtime.js") >>>
Build.run ~dir
jsoo
[ Arg_spec.Dyn flags
[ Arg_spec.Dyn (fun (x, _) -> flags x)
; Arg_spec.A "-o"; Target target
; Arg_spec.A "--no-runtime"; runtime
; Arg_spec.A "--no-runtime"
; Arg_spec.Dyn (fun (_, runtime) -> Dep runtime)
; spec
]

Expand Down