(executables
 (names wasm_of_ocaml wasmoo_link_wasm)
 (public_names wasm_of_ocaml -)
 (package wasm_of_ocaml-compiler)
 (libraries
  jsoo_cmdline
  wasm_of_ocaml-compiler
  cmdliner
  compiler-libs.common
  js_of_ocaml-compiler.runtime-files
  yojson
  unix
  (select
   findlib_support.ml
   from
   ;; Only link wasm_of_ocaml-compiler.findlib-support if it exists
   (js_of_ocaml-compiler.findlib-support -> findlib_support.empty.ml)
   (-> findlib_support.empty.ml)))
 (modes
  byte
  (best exe))
 (flags
  (:standard -safe-string)))

(rule
 (target runtime_files.ml)
 (deps
  gen/gen.exe
  ../../runtime/wasm/runtime.js
  ../../runtime/wasm/deps.json
  ../../runtime/wasm/runtime-wasi.js
  ../../runtime/wasm/deps-wasi.json
  ../../runtime/wasm/libc.wasm
  (glob_files ../../runtime/wasm/*.wat)
  (glob_files ../../runtime/wasm/runtime-*.wasm)
  (glob_files ../../runtime/wasm/*-impl.wasm))
 (action
  (with-stdout-to
   %{target}
   (run %{deps}))))

(rule
 (target
  (dir cmdliner-support))
 (deps wasm_of_ocaml.exe)
 (action
  (ignore-stdout
   (run
    cmdliner
    install
    tool-support
    ./wasm_of_ocaml.exe:wasm_of_ocaml
    cmdliner-support))))

;; Restore once fixed in dune
;; (install
;;  (section share_root)
;;  (package wasm_of_ocaml-compiler)
;;  (dirs
;;   (cmdliner-support/share as .)))
