solvuu / solvuu-build

DEPRECATED. We recommend Jane Street's dune (formerly jbuilder).
ISC License
24 stars 5 forks source link

Arguments for ppx rewriters ("the build system didn't pass -inline-test-lib") #66

Open copy opened 7 years ago

copy commented 7 years ago

I'm trying to use ppx_inline_test in a project that is being built with solvuu-build. ppx_inline_test has some specific requirements to the build system, which I believe can't be configured in solvuu-build right now, see https://github.com/janestreet/ppx_inline_test#building-and-running-the-tests-outside-of-jane-street

When building with the extension naively, the following error is thrown:

% make _build/test.native                                                                                                :(
ocamlbuild -verbose 0 -use-ocamlfind -plugin-tag "package(solvuu-build)" test.native
ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package solvuu-build myocamlbuild.ml /home/fabian/.opam/4.04.0+flambda/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
.merlin: registering rule to build file
.ocamlinit: registering rule to build file
project.mk: registering rule to build file
rank.install: registering rule to build file
File "lib/mylib.ml", line 1, characters 0-18:
Error: ppx_inline_test: extension is disabled because the tests would be ignored (the build system didn't pass -inline-test-lib)
Failure:
  Error while running: ocamlfind ocamldep -package ppx_inline_test -sort lib/mylib.ml.
make: *** [_build/project.mk:4: _build/test.native] Error 2
agarwal commented 7 years ago

The README for ppx_inline_test says:

The ppx_inline_test syntax extension will reject any test if it wasn't passed a -inline-test-lib libname flag.

Do you understand this sentence? Where do you pass the mentioned flag?

copy commented 7 years ago

The argument is passed here: https://github.com/janestreet/jane-street-tests/blob/master/test-inline-tests/with-oasis-method1/_tags

agarwal commented 7 years ago

I'm not sure how ocamlbuild translates its tags to command line invocations, but I kind of get what is needed. I think the possible solutions are:

copy commented 7 years ago

It works with ppx_inline_test.deprecated-ppx-method:

% ocamlfind ocamldep -verbose -package ppx_inline_test.deprecated-ppx-method -ppxopt 'ppx_inline_test.deprecated-ppx-method,-inline-test-lib mylib' -sort lib/mylib.ml 
+ ocamldep.opt -sort -ppx "~/.opam/4.04.0+flambda/lib/ppx_inline_test/./ppx.exe --as-ppx -inline-test-lib mylib" lib/mylib.ml
lib/mylib.ml 

This is bad and we should actually distinguish between ppx and normal dependencies. This would enable other performance optimizations.

That sounds like a good idea, indeed.