(copy_files ../../src/opamParserTypes.ml)

(test
  (name opamBaseParser)
  (modules OpamParserTypes OpamBaseParser)
  (flags :standard (:include flags.sexp))
  (action (run %{test} %{version:opam-file-format})))

(menhir (modules OpamBaseParser) (infer false))

(rule
  (with-stdout-to OpamBaseParser.mly
    (progn (cat ../../src/opamBaseParser.mly)
           ; If this assertion fails, OpamBaseParser.version is wrong
           (echo "let () = assert (Scanf.sscanf Sys.argv.(1) \"%u.%u\" (fun x y -> (x, y)) = version)"))))

(rule
  (with-stdout-to flags.ml
    (echo "print_string (if String.sub Sys.ocaml_version 0 5 = \"4.02.\" then \"(-w -50)\" else \"()\")")))

(rule
  (with-stdout-to flags.sexp
    (run ocaml %{dep:flags.ml})))
