Selectively preprocessing files by extension

dune
#1

I’m currently working on a project using both *.eliom and *.ml files, where the *.eliom files can be treated exactly as normal OCaml files, except that they need to have the Eliom PPX run on them. How would I express this in Dune?

0 Likes

#2

In the preprocess specification. you can list how you want a particular module to be preprocessed.

  • There’s no way to set the preprocessor per filename
  • There’s no way to set the preprocessor globally by extension

Both are annoying limitations that we hope to address one day.

Finally, I don’t believe that building .eliom files is as simple as running a ppx. AFAIK it requires some build system orchestration that is done via special makefiles or an ocamlbuild plugin. Dune has not equivalent. (cc @Drup to confirm).

However, if you have such an interest to add eliom support to dune, then we’d gladly show you how to make it work on the dune side. You will need to understand how building eliom works however.

0 Likes

#3

Eliom is indeed a bit more than a simple ppx. Each *.eliom compiles to two sets of *.cm* files, one for the server, one for the client. The chalenging part being the associated dependency resolution.

If you are really motivated to work on this, I can give more detailed pointers, but it’s not a trivial task.

0 Likes

#4

The thing I’m currently working on is actually building eliom itself with dune, and Eliom uses its own OCamlbuild plugin and PPX’s in the process of building the library.

So this would necessitate adding new functionality to Dune itself?

0 Likes

#5

eliom is 2 things:

  • A language extension. This is written in normal OCaml
  • A “framework”/library. This is written in the eliom dialect, and thus need appropriate build tool.
0 Likes

#6

I’m a bit confused since, looking at the library source, there are a lot of files not written in the Eliom dialect: https://github.com/ocsigen/eliom/tree/master/src/lib

Unless I’m mistaken, the Eliom framework is composed of Eliom-dialect modules as well as normal OCaml.

0 Likes

#7

Not everything is written in the exact eliom dialect, but the whole framework uses eliom-style architecture, with .server.ml and .client.ml files, which must not be mixed, but both should be accessible inside eliom files (in server and client sections, respectively). You also have some “normal” ocaml files, which should be available in both.

0 Likes

#8

And there’s no clean way to represent such an architecture in pure Dune at this moment?

0 Likes

#9

Well, that’s precisely the part that need modifications in dune. :slight_smile:

0 Likes