Tyxml.ppx with jbuilder?

I’m trying to build a simple example with Tyxml.ppx syntax extension, using jbuilder:

example.ml

open Tyxml

let%html to_ocaml = "<a href='ocaml.org'>OCaml!</a>"

jbuild

(jbuild_version 1)

(executable
 ((name example)
  (libraries (tyxml))
  (preprocess (pps (tyxml.ppx)))
 ))

I’m getting

File "example.ml", line 3, characters 4-8:
Error: Uninterpreted extension 'html'.

I came across this GH issue in my search.
Is Tyxml.ppx also an “old style ppx extension” or am I doing something wrong here?

Yes, tyxml is “old style”. In order to migrate, I would need to either

  • Use omp’s driver while keeping oasis. This is quite annoying and complicated.
  • Moving to jbuilder, which causes lot’s of issues.

So it isn’t done yet. If you want to make efforts to move into one direction or the other (I would prefer 1. at first, because 2. is really too problematic right now), PRs are very welcome.

I’m probably going to spend a little bit of time on Tyxml again in the next month, so that would be a good ocasion to take care of these issues.

I appreciate the details Drup, thank you.

The two options are beyond what I can contribute at the moment, I’m at the “playing around” stage with Ocaml + the web. I’ll have to stick to plain Tyxml for now.

For posterity:
omp stands for ocaml-migrate-parsetree
And a–I imagine very incomplete–PR for jbuilder migration here.

Drup, the difficulty with using oasis is that you can’t generate the require META file with it, am I right? Have you considered using topkg/ocamlbuild then? This way you won’t have to change your codebase at all.

Or are there other problems apart from changing the META file?

If I have to choose between handwritten META or using ocamlbuild to build everything, I’m going to choose the former. Handling multiple interdependent libraries in pure ocamlbuild is nightmare-fuel. Topkg helps for packaging, but not building.

First shot: https://github.com/ocsigen/tyxml/pull/188

1 Like

Has the situation improved? I try to use tyxml.ppx with dune but get the following link error:

jbuilder build
    ocamlopt .ppx/ppx_sexp_conv+tyxml.ppx/ppx.exe (exit 2)
(cd _build/default && /home/pveber/.opam/4.06.1/bin/ocamlopt.opt -o .ppx/ppx_sexp_conv+tyxml.ppx/ppx.exe -I /home/pveber/.opam/4.06.1/lib/base -I /home/pveber/.opam/4.06.1/lib/base/caml -I /home/pveber/.opam/4.06.1/lib/base/shadow_stdlib -I /home/pveber/.opam/4.06.1/lib/bytes -I /home/pveber/.opam/4.06.1/lib/ocaml-compiler-libs/common -I /home/pveber/.opam/4.06.1/lib/ocaml-compiler-libs/shadow -I /home/pveber/.opam/4.06.1/lib/ocaml-migrate-parsetree -I /home/pveber/.opam/4.06.1/lib/ocaml-migrate-parsetree/driver-main -I /home/pveber/.opam/4.06.1/lib/ocaml/compiler-libs -I /home/pveber/.opam/4.06.1/lib/ppx_derivers -I /home/pveber/.opam/4.06.1/lib/ppx_sexp_conv -I /home/pveber/.opam/4.06.1/lib/ppx_sexp_conv/expander -I /home/pveber/.opam/4.06.1/lib/ppxlib -I /home/pveber/.opam/4.06.1/lib/ppxlib/ast -I /home/pveber/.opam/4.06.1/lib/ppxlib/print_diff -I /home/pveber/.opam/4.06.1/lib/ppxlib/traverse_builtins -I /home/pveber/.opam/4.06.1/lib/re -I /home/pveber/.opam/4.06.1/lib/result -I /home/pveber/.opam/4.06.1/lib/sexplib0 -I /home/pveber/.opam/4.06.1/lib/stdio -I /home/pveber/.opam/4.06.1/lib/tyxml -I /home/pveber/.opam/4.06.1/lib/uchar -I /home/pveber/.opam/4.06.1/lib/uutf /home/pveber/.opam/4.06.1/lib/base/caml/caml.cmxa /home/pveber/.opam/4.06.1/lib/base/shadow_stdlib/shadow_stdlib.cmxa /home/pveber/.opam/4.06.1/lib/sexplib0/sexplib0.cmxa /home/pveber/.opam/4.06.1/lib/base/base.cmxa /home/pveber/.opam/4.06.1/lib/ocaml/compiler-libs/ocamlcommon.cmxa /home/pveber/.opam/4.06.1/lib/ocaml-compiler-libs/common/ocaml_common.cmxa /home/pveber/.opam/4.06.1/lib/ocaml-compiler-libs/shadow/ocaml_shadow.cmxa /home/pveber/.opam/4.06.1/lib/result/result.cmxa /home/pveber/.opam/4.06.1/lib/ocaml-migrate-parsetree/migrate_parsetree.cmxa /home/pveber/.opam/4.06.1/lib/ppx_derivers/ppx_derivers.cmxa /home/pveber/.opam/4.06.1/lib/ppxlib/ast/ppxlib_ast.cmxa /home/pveber/.opam/4.06.1/lib/ppxlib/print_diff/ppxlib_print_diff.cmxa /home/pveber/.opam/4.06.1/lib/ppxlib/traverse_builtins/ppxlib_traverse_builtins.cmxa /home/pveber/.opam/4.06.1/lib/stdio/stdio.cmxa /home/pveber/.opam/4.06.1/lib/ppxlib/ppxlib.cmxa /home/pveber/.opam/4.06.1/lib/ppx_sexp_conv/expander/ppx_sexp_conv_expander.cmxa /home/pveber/.opam/4.06.1/lib/ppx_sexp_conv/ppx_sexp_conv.cmxa /home/pveber/.opam/4.06.1/lib/uutf/uutf.cmxa /home/pveber/.opam/4.06.1/lib/re/re.cmxa /home/pveber/.opam/4.06.1/lib/tyxml/tyxml_f.cmxa /home/pveber/.opam/4.06.1/lib/tyxml/tyxml.cmxa /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx /home/pveber/.opam/4.06.1/lib/ocaml-migrate-parsetree/driver-main/migrate_parsetree_driver_main.cmxa)
File "_none_", line 1:
Error: No implementations provided for the following modules:
         Ppx_namespace referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx
         Ast_convenience_405 referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx
         Ppx_common referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx
         Ppx_element_content referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx
         Ppx_tools_405 referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx
         Ppx_element referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx
         Markup referenced from /home/pveber/.opam/4.06.1/lib/tyxml/ppx_tyxml.cmx

For the record I successfully used ppxfind to run tyxml.ppx.

I really should make a release, which would fix that. In the meantime, ppxfind is the right solution!

yes, and I confirm pinning tyxml and tyxml-ppx to upstream works well with jbuilder/dune. Thanks!

PS +1 for a release ;o)