(executable
 (name main)
 (modules main)
 (libraries js_of_ocaml)
 (modes byte))

(rule
 (target main.js)
 (action
  (run %{bin:js_of_ocaml} --linkall -o %{target} %{dep:main.bc})))

(rule
 (target plugin.cmo)
 (action
  (run %{bin:ocamlc} -c %{dep:./plugin.ml})))

(rule
 (target plugin.js)
 (action
  (run %{bin:js_of_ocaml} %{dep:./plugin.cmo})))

(rule
 (target main.out)
 (deps plugin.js)
 (action
  (with-outputs-to
   %{target}
   (run %{bin:node} %{dep:./main.js}))))

(rule
 (alias runtest)
 (action
  (diff main.out.expected main.out)))
