(library
  (name js_of_ocaml_compiler)
  (public_name js_of_ocaml-compiler)
  (synopsis "Js_of_ocaml compiler library")
  (libraries compiler-libs.common compiler-libs.bytecomp bytes
   (select source_map_io.ml from
    (yojson -> source_map_yojson.ml.in)
    (       -> source_map_unsupported.ml.in))
  )
  (flags (:standard -w -7-37 -safe-string))
  (preprocess (pps ppx_optcomp_light))
  )

(rule
  (targets js_lexer.ml)
  (mode promote)
  (action (chdir %{workspace_root} (run %{bin:ocamllex} -q %{dep:js_lexer.mll} -o %{targets}))))

(rule
  (targets annot_lexer.ml)
  (mode promote)
  (action (chdir %{workspace_root} (run %{bin:ocamllex} -q %{dep:annot_lexer.mll} -o %{targets}))))

;; cp $(ocamlfind printconf path)/menhir/standard.mly standard.mly

;; menhir is just noisy, both because this parser has conflicts, or
;; because we don't use --infer (to avoid having to write  manually and
;; badly specified dependencieds), so we just discard stderr.
(rule
 (targets js_parser.mli js_parser.ml)
 (deps standard.mly)
 (mode promote)
 (action (ignore-stderr (run menhir --stdlib . --external-tokens Js_token --explain %{dep:js_parser.mly}))))

(rule
 (targets annot_parser.mli annot_parser.ml)
 (deps standard.mly)
 (mode promote)
 (action (ignore-stderr (run menhir --stdlib . --explain %{dep:annot_parser.mly}))))

(rule
 (targets compiler_version.ml)
 (deps (:input-file ../../version.ml.in))
 (action (copy %{input-file} %{targets})))
