(executables
 (names a b)
 (modes byte)
 (libraries js_of_ocaml))

(rule
 (target a.js)
 (action
  (run
   %{bin:js_of_ocaml}
   %{dep:./a.bc}
   --wrap-with-fun
   implemA
   -o
   a.js
   --pretty
   --target-env
   browser
   --no-extern-fs)))

(rule
 (target a-iife.js)
 (action
  (run
   %{bin:js_of_ocaml}
   %{dep:./a.bc}
   -o
   a-iife.js
   --target-env
   browser
   --no-extern-fs)))

(rule
 (target b.js)
 (action
  (run
   %{bin:js_of_ocaml}
   %{dep:./b.bc}
   --wrap-with-fun
   implemB
   -o
   b.js
   --pretty
   --target-env
   browser
   --no-extern-fs)))

(alias
 (name default)
 (deps a.js b.js a-iife.js index.html))

(rule
 (target for-node.actual)
 (deps a.js b.js a-iife.js for-node.js)
 (action
  (with-outputs-to
   %{target}
   (run node for-node.js))))

(rule
 (alias runtest-js)
 (action
  (diff %{dep:for-node.expected} %{dep:for-node.actual})))
