I have library based on Ctypes and I use jbuilder to build and test it. I want to use dune now but I am not able to run my tests with dune. For those that prefer to see the modifications via the github interface here is the link https://github.com/cedlemo/OCaml-GObject-Introspection/compare/jbuilder_to_dune
In my project, I have a configurator that loads some C flags for Ctypes like described here : http://dune.readthedocs.io/en/latest/quick-start.html#defining-a-library-with-c-stubs-using-pkg-config
so I have 3 jbuild files that need to be transformed to 3 dune files:
in the config directory:
(jbuild_version 1)
(executable
((name discover)
(libraries (base stdio configurator))))
is transformed to
(executable
(name discover)
(libraries base stdio configurator))
the jbuild file in my lib directory :
(jbuild_version 1)
(library
((name GObject_introspection)
(public_name gobject-introspection)
(libraries (ctypes ctypes.foreign str))
(c_flags (:include c_flags.sexp))
(c_library_flags (:include c_library_flags.sexp))
(ocamlopt_flags (-ccopt ("-Wl,-no-as-needed")))
)
)
(rule
((targets (c_flags.sexp
c_library_flags.sexp))
(deps (../config/discover.exe))
(action (run ${<} -ocamlc ${OCAMLC}))
)
)
is transformed to:
(library
(name GObject_introspection)
(public_name gobject-introspection)
(libraries ctypes ctypes.foreign str)
(c_flags (:include c_flags.sexp))
(c_library_flags (:include c_library_flags.sexp))
(ocamlopt_flags (-ccopt ("-Wl,-no-as-needed")))
)
(rule
(targets c_flags.sexp c_library_flags.sexp)
(deps (:x ../config/discover.exe))
(action (run %{x} -ocamlc %{ocamlc}))
)
and the jbuild file in my test directory:
(jbuild_version 1)
(executables
((names (test))
(libraries (GObject_introspection oUnit ctypes ctypes.foreign))
))
(alias
((name runtest)
(deps (test.exe))
(action (run ${<}))))
is transformed in :
(executables
(names test)
(libraries GObject_introspection oUnit ctypes ctypes.foreign)
)
(alias
(name runtest)
(deps (:x test.exe))
(action (run %{x})))
Even though I did not modify any lines of code, I am not able to run my tests anymore both localy or on Travis.
for example on my computer, I have the following output:
dune runtest
ocamlc lib/.GObject_introspection.objs/GObject_introspection__Registered_type_info.{cmi,cmti} (exit 2)
(cd _build/default && /home/cedlemo/.opam/default/bin/ocamlc.opt -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I lib/.GObject_introspection.objs -I /home/cedlemo/.opam/default/lib/bytes -I /home/cedlemo/.opam/default/lib/ctypes -I /home/cedlemo/.opam/default/lib/integers -I /home/cedlemo/.opam/default/lib/ocaml/threads -no-alias-deps -open GObject_introspection -o lib/.GObject_introspection.objs/GObject_introspection__Registered_type_info.cmi -c -intf lib/Registered_type_info.mli)
File "lib/Registered_type_info.mli", line 22, characters 0-12:
Error (warning 33): unused open Foreign.
ocamlc lib/.GObject_introspection.objs/GObject_introspection__Types.{cmi,cmti} (exit 2)
(cd _build/default && /home/cedlemo/.opam/default/bin/ocamlc.opt -w @a-4-29-40-41-42-44-45-48-58-59-60-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I lib/.GObject_introspection.objs -I /home/cedlemo/.opam/default/lib/bytes -I /home/cedlemo/.opam/default/lib/ctypes -I /home/cedlemo/.opam/default/lib/integers -I /home/cedlemo/.opam/default/lib/ocaml/threads -no-alias-deps -open GObject_introspection -o lib/.GObject_introspection.objs/GObject_introspection__Types.cmi -c -intf lib/Types.mli)
File "lib/Types.mli", line 22, characters 0-12:
Error (warning 33): unused open Foreign.
discover lib/c_flags.sexp,lib/c_library_flags.sexp
==================== Configurator ================
>>>>>>>>>>>>>>>>>>>>> libs : <<<<<<<<<<<<<<<<<<<<<<
(-L/usr/lib/../lib -lffi -lgirepository-1.0 -lgobject-2.0 -lglib-2.0 -L/usr/lib/x86_64-linux-gnu -L/usr/lib)
>>>>>>>>>>>>>>>>>>>>> flags : <<<<<<<<<<<<<<<<<<<<<<
(-I/usr/lib/libffi-3.2.1/include -I/usr/include/gobject-introspection-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/lib/libffi-3.2.1/include -I/usr/include -I/usr/include/x86_64-linux-gnu)
==================== Configurator ================
I can not figure out what is wrong.