-
Notifications
You must be signed in to change notification settings - Fork 409
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
Initial js_of_ocaml support (requires the unreleased jsoo.3.0) #60
Conversation
src/gen_rules.ml
Outdated
@@ -985,6 +985,128 @@ module Gen(P : Params) = struct | |||
| t :: ts -> dot_merlin ~dir (List.fold_left ts ~init:t ~f:merge_two) | |||
end | |||
|
|||
module Js_of_ocaml_rule = struct | |||
|
|||
let build_dir = List.fold_left ~init:(Path.relative ctx.build_dir ".js") ~f:Path.relative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the auto-generated ppx rewriters are generated in _build/.ppx/<context>
. The idea was to avoid reserving the .ppx
name. On second though maybe that's a bit extra, but at least we should be consistent and use _build/.js/<context>
.
BTW, shouldn't this be called in_build_dir
?
src/gen_rules.ml
Outdated
let build_dir = List.fold_left ~init:(Path.relative ctx.build_dir ".js") ~f:Path.relative | ||
|
||
let runtime_file ~dir fname = | ||
let _lib, file = Artifacts.file_of_lib ~dir ~use_provides:true (sprintf "js_of_ocaml-compiler:%s" fname) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be use_provides:false
. true
is only for ${findlib:...}
with (jbuild_version jane_street)
src/gen_rules.ml
Outdated
Utils.library_not_found ~context:ctx.name ~hint:"opam install js_of_ocaml-compiler" "js_of_ocaml-compiler") | ||
| Ok f -> Arg_spec.Dep f | ||
|
||
let binary bin = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same code is used for "refmt"
, we should factorize it, maybe as Artifacts.prog_spec
src/gen_rules.ml
Outdated
; spec | ||
] | ||
|
||
let get_runtimes (libs,_) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should go in lib.ml
src/gen_rules.ml
Outdated
@@ -1701,7 +1845,7 @@ module Gen(P : Params) = struct | |||
|> Merlin.gen ~dir:ctx_dir | |||
|
|||
let () = List.iter P.stanzas ~f:rules | |||
|
|||
let () = List.iter (Js_of_ocaml_rule.setup_findlib ()) ~f:add_rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be done only if we separate compilation is enabled, otherwise we are going to scan the whole findlib database for nothing on every start
The manual also need to be updated |
Ok, code looks good. BTW, since we don't use the fact that |
I started splitting gen_rules.ml to make it easier to add new systems. You should now be able to move the js_of_ocaml rules in their own module. Global variables should go in Super_context |
d7df3f1
to
ccaeb49
Compare
ccaeb49
to
ecbef77
Compare
Thanks! |
Documentation is still missing