Currently @obazl//convert:dune
can handle these in some cases but not all. Dependency on ppx_inline_test
is not always directly expressed by dune stanzas. For example, ppx_bench/example/dune has:
(library (name ppx_bench_sample_lib) (libraries core)
(preprocess (pps ppx_bench)))
and the ppx_bench library (//src:ppx_bench
) depends on @ppx_inline_test//lib/libname
. So in order to discover the dependency we would have to inspect everything in the (preprocess (pps ...))
directive. The mibl data has all the required info, but implementing the search will be a PITA.
That would work internally for ppx_bench. But if some other project were to depend on an opam package that depends on ppx_inline_test, we would have no way of discovering the dependency short of crawling around in the opam dependency graph.
We need to discover the dependency because it means we need to add ["-inline-test-lib", "foo"]
to the ppx_args
attribute wherever a ppx transform uses the lib in question. So we see module FOO needs ppx.exe, which depends on ppx_bench, which depends on ppx_inline_test.
We currently do not have this capability. To add it we would need a library, but if we used an ocaml lib we would have a bootstrapping problem. We do not want @obazl//convert
to depend on an ocaml toolchain.
Ooops, spoke too soon. ppx_bench.opam
does list ppx_inline_test
in its depends:
clause. So maybe we can address this by adding opam file parsing to the converter.
Another alternative is to inspect the dune-package
file that gets added to the pkg directory in the switch. For ppx_bench it contains:
(library
(name ppx_bench)
(kind ppx_rewriter)
(archives (byte ppx_bench.cma) (native ppx_bench.cmxa))
(plugins (byte ppx_bench.cma) (native ppx_bench.cmxs))
(native_archives ppx_bench.a)
(requires ppxlib.ast ppxlib ppx_inline_test.libname)
(ppx_runtime_deps ppx_bench.runtime-lib)
...