From 0f8a92a85f0215914ec36378c60fca8e22484302 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 21 Jun 2023 17:53:32 +0200 Subject: [PATCH] Port to dune Motivation ========== With a port to dune, the ctypes library can be embedded in larger dune projects simply by including it in the directory tree of the bigger project. This in turn will allow MirageOS unikernels to use Ctypes seamlessly as part of embedded compilation, using the standard cross-compilation and library variants support built into Dune. The goal is to make Ctypes the default FFI interface to MirageOS, and have it work out of the box on all of the backends. All existing OS platforms should be supported as well before merge, including Windows. Porting Approach ================ This PR still installs ocamlfind libraries in the same way as the previous Makefile infrastructure, so backwards compat is preserved. However, the findlib schema has been slightly modified to separate out the foreign library from the core ctypes library. We now install: - ctypes that contains ctypes.top and ctypes.stubs as before. There are aliases to ctypes.foreign that redirect existing uses of those. - ctypes-foreign contains the foreign library. All of the configuration logic for libffi is now in src/ctypes-foreign-base, so deleting these directories will remove the ffi build logic without touching the core library. Since dune by default has stricter warnings enabled (the default --profile=dev mode), the PR currently sprinkles files with [@@@warning tags. The warnings can be fixed as well if desired, but that would muddy this PR so not done yet. Layout ====== The previous packaging would install ctypes and ctypes.stubs in the same library. Depending on the build system, it means that it's possible to specify a dependency on ctypes and use ctypes.stubs succesfully. This is not the case with Dune since it installs these in different directories. This means that it is necessary to patch these reverse dependencies, though it can be argued that they were relying on a bug. Followup work ============= A test uses OCaml syntax to skip test on windows. Once it's acceptable to use Dune 3.9, it should be updated to use build_if. Test and dynamic libraries ========================== Due to a different linking model, there are some changes in the test suite regarding dynamic library loading. Dynamic symbols in ocaml <4.06 ------------------------------ The setup for tests is that each test executable tests some properties using both "stubs" and "foreign" strategies to refer to some symbols define in `tests/clib/` (the `test_functions` library). The symbols are accessed through both strategies: - as a linked symbol (through an `external` via stubs) - through the dynamic loader (through `dlopen` via foreign) Dune links the stubs statically, so by default the symbols would not be visible to the dynamic loader. OCaml sets `-Wl,-E` in `LDFLAGS` to make these symbols visible at runtime, but until https://github.com/ocaml/ocaml/commit/edbba02a83e58e08c5632a6eceb7a58c13672d83 (between 4.05 and 4.06), this was ignored when linking executables. So this commit adds these flags when building tests for older versions. An alternative would be to use `(link_flag)` in an `(env)` stanza but this requires dune 3. This issue does not affect the original make-based build because it assembles the test executables a bit differently: the `test_functions` library is linked dynamically to the test executable. So the symbols are already visible to the dynamic loader, even when `-Wl,-E` is not set. clib loading ------------ This change is specific to windows (but does not change the behavior on Linux) It modifies the test setup a bit so that the contents of `clib` are dynamically loaded at the beginning of each test. This ensures that later foreign calls (that use the default handle) will succeed. It was not necessary before because `clib` was linked dynamically. Now that it is linked statically, dynamic symbols do not have access to the symbols in the main executable. This is a problem on windows which does not have the concept of `-Wl,--export-dynamic`. Also, on windows the stubs DLL can not be loaded directly so we recompile the library using plain `%{cc}` instead of going through ocamlopt and flexlink. Instrumentation =============== This uses dune instrumentation for coverage The instructions are now: opam install bisect_ppx dune runtest --instrument-with bisect_ppx --force bisect-ppx-report html See Depext handling =============== This port uses conf-libffi instead of hardcoding depexts in ctypes-foreign. Co-authored-by: Anil Madhavapeddy --- .depend | 175 --- .github/workflows/test.yml | 7 +- .gitignore | 31 +- .merlin | 19 - META | 43 - Makefile | 204 +-- Makefile.examples | 147 -- Makefile.rules | 137 -- Makefile.tests | 1396 ----------------- ctypes-foreign.opam | 83 +- ctypes.opam | 92 +- dune | 8 + dune-project | 61 + examples/date/foreign/dune | 3 + examples/date/stub-generation/bindings/dune | 3 + examples/date/stub-generation/dune | 3 + .../stub-generator/date_stub_generator.ml | 4 +- .../date/stub-generation/stub-generator/dune | 18 + examples/fts/foreign/dune | 7 + examples/fts/foreign/fts.ml | 6 +- examples/fts/foreign/fts.mli | 2 +- examples/fts/foreign/fts_cmd.ml | 19 +- examples/fts/stub-generation/bindings/dune | 5 + .../fts/stub-generation/bindings/fts_types.ml | 2 + .../fts/stub-generation/config/discover.ml | 25 + .../fts/stub-generation/config/discover.mli | 1 + examples/fts/stub-generation/config/dune | 8 + examples/fts/stub-generation/dune | 18 + examples/fts/stub-generation/fts_cmd.ml | 19 +- examples/fts/stub-generation/fts_if.ml | 3 +- .../fts/stub-generation/stub-generator/dune | 27 + .../stub-generator/fts_stub_generator.ml | 4 +- examples/ncurses/foreign/dune | 11 + .../ncurses/stub-generation/bindings/dune | 3 + examples/ncurses/stub-generation/dune | 3 + .../stub-generation/stub-generator/dune | 19 + .../stub-generator/ncurses_stub_generator.ml | 4 +- src/configure/dune | 4 + src/configure/extract_from_c.ml | 104 -- src/configure/gen_c_primitives.ml | 53 +- src/cstubs/cstubs.ml | 2 + src/cstubs/cstubs_c_language.ml | 2 + src/cstubs/cstubs_emit_c.ml | 2 + src/cstubs/cstubs_generate_c.ml | 2 + src/cstubs/cstubs_generate_ml.ml | 2 + src/cstubs/cstubs_inverted.ml | 2 + src/cstubs/cstubs_structs.ml | 5 +- src/cstubs/dune | 9 + src/ctypes-foreign/config/discover.ml | 37 + src/ctypes-foreign/config/dune | 9 + .../config}/gen_libffi_abi.ml | 47 +- src/ctypes-foreign/ctypes_ffi.ml | 2 + src/ctypes-foreign/dl.ml.unix | 1 + src/ctypes-foreign/dl.ml.win | 4 +- src/ctypes-foreign/dune | 33 + src/ctypes-top/dune | 6 + src/ctypes/ctypes.mli | 5 +- src/ctypes/ctypes_coerce.ml | 2 + src/ctypes/ctypes_memory.ml | 2 + src/ctypes/ctypes_ptr.ml | 2 + src/ctypes/ctypes_static.ml | 2 + src/ctypes/ctypes_std_views.ml | 4 +- src/ctypes/ctypes_structs_computed.ml | 2 + src/ctypes/ctypes_type_printing.ml | 2 + src/ctypes/ctypes_value_printing.ml | 2 + src/ctypes/dune | 42 + src/ctypes/lDouble.ml | 2 + src/discover/commands.ml | 81 - src/discover/commands.mli | 21 - src/discover/determine_as_needed_flags.sh | 10 - src/discover/discover.ml | 284 ---- tests/bench-micro/.merlin | 6 - tests/clib/dune | 25 + tests/clib/test_functions.h | 2 +- tests/config/dune | 24 + tests/config/test_config.ml | 13 + tests/flags/dune | 7 + tests/flags/gen.ml | 9 + tests/flags/gen.mli | 1 + tests/test-alignment/dune | 4 + tests/test-alignment/test_alignment.ml | 1 + tests/test-arrays/dune | 15 + tests/test-arrays/stub-generator/dune | 23 + tests/test-arrays/stubs/dune | 4 + tests/test-arrays/test_array.ml | 4 +- tests/test-bigarrays/dune | 14 + tests/test-bigarrays/stub-generator/dune | 23 + tests/test-bigarrays/stubs/dune | 4 + tests/test-bigarrays/stubs/functions.ml | 1 - tests/test-bigarrays/test_bigarrays.ml | 2 + tests/test-bools/dune | 14 + tests/test-bools/stub-generator/dune | 23 + tests/test-bools/stubs/dune | 4 + tests/test-bools/test_bools.ml | 3 +- tests/test-builtins/dune | 11 + tests/test-builtins/stub-generator/dune | 23 + tests/test-builtins/stubs/dune | 4 + tests/test-callback_lifetime/dune | 14 + .../stub-generator/dune | 23 + tests/test-callback_lifetime/stubs/dune | 4 + .../test_callback_lifetime.ml | 4 +- tests/test-closure-type-promotion/dune | 14 + .../stub-generator/dune | 23 + tests/test-closure-type-promotion/stubs/dune | 4 + .../test_closure_type_promotion.ml | 4 +- tests/test-coercions/dune | 11 + tests/test-coercions/stub-generator/dune | 23 + tests/test-coercions/stubs/dune | 4 + tests/test-coercions/test_coercions.ml | 6 +- tests/test-complex/dune | 14 + tests/test-complex/stub-generator/dune | 23 + tests/test-complex/stubs/dune | 4 + tests/test-complex/test_complex.ml | 4 +- tests/test-constants/dune | 64 + tests/test-constants/stub-generator/dune | 4 + tests/test-constants/stubs/dune | 4 + tests/test-constants/stubs/types.ml | 2 - tests/test-constants/test_constants.ml | 3 +- tests/test-cstdlib/dune | 12 + tests/test-cstdlib/stub-generator/dune | 23 + tests/test-cstdlib/stubs/dune | 4 + tests/test-cstdlib/test_cstdlib.ml | 3 +- tests/test-custom_ops/dune | 3 + tests/test-enums/dune | 47 + tests/test-enums/struct-stub-generator/dune | 4 + tests/test-enums/struct-stubs/dune | 4 + tests/test-enums/stub-generator/dune | 4 + tests/test-enums/stubs/dune | 11 + tests/test-enums/test_enums.ml | 2 + tests/test-finalisers/dune | 3 + tests/test-foreign-errno/dune | 4 + tests/test-foreign_values/dune | 14 + tests/test-foreign_values/stub-generator/dune | 23 + tests/test-foreign_values/stubs/dune | 4 + .../test_foreign_values.ml | 1 + tests/test-funptrs/dune | 12 + tests/test-funptrs/stub-generator/dune | 24 + tests/test-funptrs/stubs/dune | 4 + tests/test-funptrs/test_funptrs.ml | 3 +- tests/test-higher_order/dune | 14 + tests/test-higher_order/stub-generator/dune | 23 + tests/test-higher_order/stubs/dune | 4 + tests/test-higher_order/test_higher_order.ml | 3 +- tests/test-integers/dune | 14 + tests/test-integers/stub-generator/dune | 23 + tests/test-integers/stubs/dune | 4 + tests/test-integers/test_integers.ml | 3 +- tests/test-ldouble/dune | 3 + tests/test-ldouble/test_ldouble.ml | 13 +- tests/test-lifetime/dune | 14 + tests/test-lifetime/stub-generator/dune | 23 + tests/test-lifetime/stubs/dune | 4 + tests/test-lifetime/stubs/functions.ml | 1 - tests/test-lifetime/test_lifetime.ml | 3 +- tests/test-lwt-jobs/dune | 65 + tests/test-lwt-jobs/stub-generator/dune | 4 + tests/test-lwt-jobs/stubs/dune | 4 + tests/test-lwt-preemptive/dune | 65 + tests/test-lwt-preemptive/stub-generator/dune | 4 + tests/test-lwt-preemptive/stubs/dune | 4 + tests/test-macros/dune | 11 + tests/test-macros/stub-generator/dune | 23 + tests/test-macros/stubs/dune | 4 + tests/test-macros/test_macros.ml | 1 - tests/test-marshal/dune | 3 + tests/test-marshal/test_marshal.ml | 1 - tests/test-oo_style/dune | 14 + tests/test-oo_style/stub-generator/dune | 23 + tests/test-oo_style/stubs/dune | 4 + tests/test-oo_style/stubs/functions.ml | 1 - tests/test-oo_style/test_oo_style.ml | 5 +- tests/test-passable/dune | 4 + tests/test-passable/test_passable.ml | 6 +- tests/test-passing-ocaml-values/dune | 11 + .../stub-generator/dune | 23 + tests/test-passing-ocaml-values/stubs/dune | 4 + .../test_passing_ocaml_values.ml | 5 +- tests/test-pointers/dune | 15 + tests/test-pointers/stub-generator/dune | 23 + tests/test-pointers/stubs/dune | 4 + tests/test-pointers/test_pointers.ml | 3 +- tests/test-raw/dune | 4 + tests/test-raw/test_raw.ml | 3 +- tests/test-returning-errno-lwt-jobs/dune | 65 + .../stub-generator/dune | 4 + .../test-returning-errno-lwt-jobs/stubs/dune | 4 + .../test_returning_errno.ml | 1 + .../test-returning-errno-lwt-preemptive/dune | 65 + .../stub-generator/dune | 4 + .../stubs/dune | 4 + .../test_returning_errno.ml | 1 + tests/test-returning-errno/dune | 65 + .../test-returning-errno/stub-generator/dune | 4 + tests/test-returning-errno/stubs/dune | 4 + tests/test-roots/dune | 5 + tests/test-roots/test_roots.ml | 2 +- tests/test-sizeof/dune | 4 + tests/test-sizeof/test_sizeof.ml | 3 +- tests/test-structs/dune | 68 + tests/test-structs/stub-generator/dune | 4 + tests/test-structs/stubs/dune | 4 + tests/test-structs/test_structs.ml | 3 +- tests/test-stubs/dune | 4 + tests/test-stubs/test_stubs.ml | 4 +- tests/test-threads/dune | 14 + tests/test-threads/stub-generator/dune | 23 + tests/test-threads/stubs/dune | 4 + tests/test-threads/test_threads.ml | 5 +- tests/test-type_printing/dune | 63 + tests/test-type_printing/stub-generator/dune | 4 + tests/test-type_printing/stubs/dune | 4 + tests/test-type_printing/stubs/types.ml | 2 - tests/test-unions/dune | 68 + tests/test-unions/stub-generator/dune | 4 + tests/test-unions/stubs/dune | 4 + tests/test-unions/test_unions.ml | 10 +- tests/test-value_printing/dune | 14 + tests/test-value_printing/stub-generator/dune | 23 + tests/test-value_printing/stubs/dune | 4 + .../test_value_printing.ml | 1 + tests/test-variadic/dune | 10 + tests/test-variadic/stub-generator/dune | 23 + tests/test-variadic/stubs/dune | 4 + tests/test-variadic/test_variadic.ml | 4 +- tests/test-views/dune | 7 + tests/test-views/stub-generator/dune | 23 + tests/test-views/stubs/dune | 4 + tests/test-views/test_views.ml | 3 + tests/tests-common/dune | 3 + tests/tests-common/tests_common.ml | 6 +- 230 files changed, 2433 insertions(+), 2851 deletions(-) delete mode 100644 .depend delete mode 100644 .merlin delete mode 100644 META delete mode 100644 Makefile.examples delete mode 100644 Makefile.rules delete mode 100644 Makefile.tests create mode 100644 dune create mode 100644 dune-project create mode 100644 examples/date/foreign/dune create mode 100644 examples/date/stub-generation/bindings/dune create mode 100644 examples/date/stub-generation/dune create mode 100644 examples/date/stub-generation/stub-generator/dune create mode 100644 examples/fts/foreign/dune create mode 100644 examples/fts/stub-generation/bindings/dune create mode 100644 examples/fts/stub-generation/config/discover.ml create mode 100644 examples/fts/stub-generation/config/discover.mli create mode 100644 examples/fts/stub-generation/config/dune create mode 100644 examples/fts/stub-generation/dune create mode 100644 examples/fts/stub-generation/stub-generator/dune create mode 100644 examples/ncurses/foreign/dune create mode 100644 examples/ncurses/stub-generation/bindings/dune create mode 100644 examples/ncurses/stub-generation/dune create mode 100644 examples/ncurses/stub-generation/stub-generator/dune create mode 100644 src/configure/dune delete mode 100644 src/configure/extract_from_c.ml create mode 100644 src/cstubs/dune create mode 100644 src/ctypes-foreign/config/discover.ml create mode 100644 src/ctypes-foreign/config/dune rename src/{configure => ctypes-foreign/config}/gen_libffi_abi.ml (58%) create mode 100644 src/ctypes-foreign/dune create mode 100644 src/ctypes-top/dune create mode 100644 src/ctypes/dune delete mode 100644 src/discover/commands.ml delete mode 100644 src/discover/commands.mli delete mode 100755 src/discover/determine_as_needed_flags.sh delete mode 100644 src/discover/discover.ml delete mode 100644 tests/bench-micro/.merlin create mode 100644 tests/clib/dune create mode 100644 tests/config/dune create mode 100644 tests/config/test_config.ml create mode 100644 tests/flags/dune create mode 100644 tests/flags/gen.ml create mode 100644 tests/flags/gen.mli create mode 100644 tests/test-alignment/dune create mode 100644 tests/test-arrays/dune create mode 100644 tests/test-arrays/stub-generator/dune create mode 100644 tests/test-arrays/stubs/dune create mode 100644 tests/test-bigarrays/dune create mode 100644 tests/test-bigarrays/stub-generator/dune create mode 100644 tests/test-bigarrays/stubs/dune create mode 100644 tests/test-bools/dune create mode 100644 tests/test-bools/stub-generator/dune create mode 100644 tests/test-bools/stubs/dune create mode 100644 tests/test-builtins/dune create mode 100644 tests/test-builtins/stub-generator/dune create mode 100644 tests/test-builtins/stubs/dune create mode 100644 tests/test-callback_lifetime/dune create mode 100644 tests/test-callback_lifetime/stub-generator/dune create mode 100644 tests/test-callback_lifetime/stubs/dune create mode 100644 tests/test-closure-type-promotion/dune create mode 100644 tests/test-closure-type-promotion/stub-generator/dune create mode 100644 tests/test-closure-type-promotion/stubs/dune create mode 100644 tests/test-coercions/dune create mode 100644 tests/test-coercions/stub-generator/dune create mode 100644 tests/test-coercions/stubs/dune create mode 100644 tests/test-complex/dune create mode 100644 tests/test-complex/stub-generator/dune create mode 100644 tests/test-complex/stubs/dune create mode 100644 tests/test-constants/dune create mode 100644 tests/test-constants/stub-generator/dune create mode 100644 tests/test-constants/stubs/dune create mode 100644 tests/test-cstdlib/dune create mode 100644 tests/test-cstdlib/stub-generator/dune create mode 100644 tests/test-cstdlib/stubs/dune create mode 100644 tests/test-custom_ops/dune create mode 100644 tests/test-enums/dune create mode 100644 tests/test-enums/struct-stub-generator/dune create mode 100644 tests/test-enums/struct-stubs/dune create mode 100644 tests/test-enums/stub-generator/dune create mode 100644 tests/test-enums/stubs/dune create mode 100644 tests/test-finalisers/dune create mode 100644 tests/test-foreign-errno/dune create mode 100644 tests/test-foreign_values/dune create mode 100644 tests/test-foreign_values/stub-generator/dune create mode 100644 tests/test-foreign_values/stubs/dune create mode 100644 tests/test-funptrs/dune create mode 100644 tests/test-funptrs/stub-generator/dune create mode 100644 tests/test-funptrs/stubs/dune create mode 100644 tests/test-higher_order/dune create mode 100644 tests/test-higher_order/stub-generator/dune create mode 100644 tests/test-higher_order/stubs/dune create mode 100644 tests/test-integers/dune create mode 100644 tests/test-integers/stub-generator/dune create mode 100644 tests/test-integers/stubs/dune create mode 100644 tests/test-ldouble/dune create mode 100644 tests/test-lifetime/dune create mode 100644 tests/test-lifetime/stub-generator/dune create mode 100644 tests/test-lifetime/stubs/dune create mode 100644 tests/test-lwt-jobs/dune create mode 100644 tests/test-lwt-jobs/stub-generator/dune create mode 100644 tests/test-lwt-jobs/stubs/dune create mode 100644 tests/test-lwt-preemptive/dune create mode 100644 tests/test-lwt-preemptive/stub-generator/dune create mode 100644 tests/test-lwt-preemptive/stubs/dune create mode 100644 tests/test-macros/dune create mode 100644 tests/test-macros/stub-generator/dune create mode 100644 tests/test-macros/stubs/dune create mode 100644 tests/test-marshal/dune create mode 100644 tests/test-oo_style/dune create mode 100644 tests/test-oo_style/stub-generator/dune create mode 100644 tests/test-oo_style/stubs/dune create mode 100644 tests/test-passable/dune create mode 100644 tests/test-passing-ocaml-values/dune create mode 100644 tests/test-passing-ocaml-values/stub-generator/dune create mode 100644 tests/test-passing-ocaml-values/stubs/dune create mode 100644 tests/test-pointers/dune create mode 100644 tests/test-pointers/stub-generator/dune create mode 100644 tests/test-pointers/stubs/dune create mode 100644 tests/test-raw/dune create mode 100644 tests/test-returning-errno-lwt-jobs/dune create mode 100644 tests/test-returning-errno-lwt-jobs/stub-generator/dune create mode 100644 tests/test-returning-errno-lwt-jobs/stubs/dune create mode 100644 tests/test-returning-errno-lwt-preemptive/dune create mode 100644 tests/test-returning-errno-lwt-preemptive/stub-generator/dune create mode 100644 tests/test-returning-errno-lwt-preemptive/stubs/dune create mode 100644 tests/test-returning-errno/dune create mode 100644 tests/test-returning-errno/stub-generator/dune create mode 100644 tests/test-returning-errno/stubs/dune create mode 100644 tests/test-roots/dune create mode 100644 tests/test-sizeof/dune create mode 100644 tests/test-structs/dune create mode 100644 tests/test-structs/stub-generator/dune create mode 100644 tests/test-structs/stubs/dune create mode 100644 tests/test-stubs/dune create mode 100644 tests/test-threads/dune create mode 100644 tests/test-threads/stub-generator/dune create mode 100644 tests/test-threads/stubs/dune create mode 100644 tests/test-type_printing/dune create mode 100644 tests/test-type_printing/stub-generator/dune create mode 100644 tests/test-type_printing/stubs/dune create mode 100644 tests/test-unions/dune create mode 100644 tests/test-unions/stub-generator/dune create mode 100644 tests/test-unions/stubs/dune create mode 100644 tests/test-value_printing/dune create mode 100644 tests/test-value_printing/stub-generator/dune create mode 100644 tests/test-value_printing/stubs/dune create mode 100644 tests/test-variadic/dune create mode 100644 tests/test-variadic/stub-generator/dune create mode 100644 tests/test-variadic/stubs/dune create mode 100644 tests/test-views/dune create mode 100644 tests/test-views/stub-generator/dune create mode 100644 tests/test-views/stubs/dune create mode 100644 tests/tests-common/dune diff --git a/.depend b/.depend deleted file mode 100644 index 1df8a5189..000000000 --- a/.depend +++ /dev/null @@ -1,175 +0,0 @@ -_build/examples/cstubs_structs/bindings.cmo : _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_structs.cmi -_build/examples/cstubs_structs/bindings.cmx : _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_structs.cmx -_build/examples/cstubs_structs/bindings_c_gen.cmo : _build/src/cstubs/cstubs_structs.cmi -_build/examples/cstubs_structs/bindings_c_gen.cmx : _build/src/cstubs/cstubs_structs.cmx -_build/examples/cstubs_structs/main.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes-foreign/foreign.cmi _build/src/ctypes/ctypes.cmi -_build/examples/cstubs_structs/main.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes-foreign/foreign.cmx _build/src/ctypes/ctypes.cmx -_build/examples/cstubs_structs/myocamlbuild.cmo : -_build/examples/cstubs_structs/myocamlbuild.cmx : -_build/examples/date/foreign/date.cmi : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/ctypes.cmi -_build/examples/date/foreign/date.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes-foreign/foreign.cmi _build/src/ctypes/ctypes.cmi _build/examples/date/foreign/date.cmi -_build/examples/date/foreign/date.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes-foreign/foreign.cmx _build/src/ctypes/ctypes.cmx _build/examples/date/foreign/date.cmi -_build/examples/date/stub-generation/bindings/date_stubs.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/ctypes.cmi -_build/examples/date/stub-generation/bindings/date_stubs.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes/ctypes.cmx -_build/examples/date/stub-generation/date_cmd.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/ctypes.cmi -_build/examples/date/stub-generation/date_cmd.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes/ctypes.cmx -_build/examples/date/stub-generation/stub-generator/date_stub_generator.cmo : _build/src/cstubs/cstubs.cmi -_build/examples/date/stub-generation/stub-generator/date_stub_generator.cmx : _build/src/cstubs/cstubs.cmx -_build/examples/fts/foreign/fts.cmi : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/ctypes.cmi -_build/examples/fts/foreign/fts.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes-foreign/foreign.cmi _build/src/ctypes/ctypes_coerce.cmi _build/src/ctypes/ctypes.cmi _build/examples/fts/foreign/fts.cmi -_build/examples/fts/foreign/fts.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes-foreign/foreign.cmx _build/src/ctypes/ctypes_coerce.cmx _build/src/ctypes/ctypes.cmx _build/examples/fts/foreign/fts.cmi -_build/examples/fts/foreign/fts_cmd.cmo : _build/src/ctypes/ctypes.cmi -_build/examples/fts/foreign/fts_cmd.cmx : _build/src/ctypes/ctypes.cmx -_build/examples/fts/stub-generation/bindings/fts.cmi : _build/src/ctypes/ctypes.cmi -_build/examples/fts/stub-generation/bindings/fts_bindings.cmo : _build/src/ctypes/ctypes.cmi -_build/examples/fts/stub-generation/bindings/fts_bindings.cmx : _build/src/ctypes/ctypes.cmx -_build/examples/fts/stub-generation/bindings/fts_types.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes-foreign/foreign.cmi _build/src/ctypes/ctypes_coerce.cmi _build/src/ctypes/ctypes.cmi -_build/examples/fts/stub-generation/bindings/fts_types.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes-foreign/foreign.cmx _build/src/ctypes/ctypes_coerce.cmx _build/src/ctypes/ctypes.cmx -_build/examples/fts/stub-generation/fts_cmd.cmo : _build/src/ctypes/ctypes.cmi -_build/examples/fts/stub-generation/fts_cmd.cmx : _build/src/ctypes/ctypes.cmx -_build/examples/fts/stub-generation/fts_if.cmo : _build/src/ctypes/ctypes.cmi -_build/examples/fts/stub-generation/fts_if.cmx : _build/src/ctypes/ctypes.cmx -_build/examples/fts/stub-generation/stub-generator/fts_stub_generator.cmo : _build/src/cstubs/cstubs.cmi -_build/examples/fts/stub-generation/stub-generator/fts_stub_generator.cmx : _build/src/cstubs/cstubs.cmx -_build/examples/ncurses/foreign/ncurses.cmi : -_build/examples/ncurses/foreign/ncurses.cmo : _build/src/ctypes-foreign/foreign.cmi _build/src/ctypes/ctypes.cmi _build/examples/ncurses/foreign/ncurses.cmi -_build/examples/ncurses/foreign/ncurses.cmx : _build/src/ctypes-foreign/foreign.cmx _build/src/ctypes/ctypes.cmx _build/examples/ncurses/foreign/ncurses.cmi -_build/examples/ncurses/foreign/ncurses_cmd.cmo : -_build/examples/ncurses/foreign/ncurses_cmd.cmx : -_build/examples/ncurses/stub-generation/bindings/ncurses_bindings.cmo : _build/src/ctypes/ctypes.cmi -_build/examples/ncurses/stub-generation/bindings/ncurses_bindings.cmx : _build/src/ctypes/ctypes.cmx -_build/examples/ncurses/stub-generation/ncurses_stub_cmd.cmo : -_build/examples/ncurses/stub-generation/ncurses_stub_cmd.cmx : -_build/examples/ncurses/stub-generation/stub-generator/ncurses_stub_generator.cmo : _build/src/cstubs/cstubs.cmi -_build/examples/ncurses/stub-generation/stub-generator/ncurses_stub_generator.cmx : _build/src/cstubs/cstubs.cmx -_build/examples/sigset/sigset.cmi : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/ctypes.cmi -_build/examples/sigset/sigset.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes-foreign/foreign.cmi _build/src/ctypes/ctypes.cmi _build/examples/sigset/sigset.cmi -_build/examples/sigset/sigset.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes-foreign/foreign.cmx _build/src/ctypes/ctypes.cmx _build/examples/sigset/sigset.cmi -_build/src/configure/extract_from_c.cmo : -_build/src/configure/extract_from_c.cmx : -_build/src/configure/gen_c_primitives.cmo : -_build/src/configure/gen_c_primitives.cmx : -_build/src/configure/gen_libffi_abi.cmo : -_build/src/configure/gen_libffi_abi.cmx : -_build/src/cstubs/cstubs.cmi : _build/src/ctypes/ctypes.cmi -_build/src/cstubs/cstubs.cmo : _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_structs.cmi _build/src/cstubs/cstubs_generate_ml.cmi _build/src/cstubs/cstubs_generate_c.cmi _build/src/cstubs/cstubs.cmi -_build/src/cstubs/cstubs.cmx : _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_structs.cmx _build/src/cstubs/cstubs_generate_ml.cmx _build/src/cstubs/cstubs_generate_c.cmx _build/src/cstubs/cstubs.cmi -_build/src/cstubs/cstubs_analysis.cmi : _build/src/ctypes/ctypes_static.cmi -_build/src/cstubs/cstubs_analysis.cmo : _build/src/ctypes/lDouble.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_bigarray.cmi _build/src/ctypes/complexL.cmi _build/src/cstubs/cstubs_analysis.cmi -_build/src/cstubs/cstubs_analysis.cmx : _build/src/ctypes/lDouble.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes_bigarray.cmx _build/src/ctypes/complexL.cmx _build/src/cstubs/cstubs_analysis.cmi -_build/src/cstubs/cstubs_c_language.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_errors.cmi -_build/src/cstubs/cstubs_c_language.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_errors.cmx -_build/src/cstubs/cstubs_emit_c.cmo : _build/src/ctypes/ctypes_type_printing.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_c_language.cmo -_build/src/cstubs/cstubs_emit_c.cmx : _build/src/ctypes/ctypes_type_printing.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_c_language.cmx -_build/src/cstubs/cstubs_errors.cmi : -_build/src/cstubs/cstubs_errors.cmo : _build/src/cstubs/cstubs_errors.cmi -_build/src/cstubs/cstubs_errors.cmx : _build/src/cstubs/cstubs_errors.cmi -_build/src/cstubs/cstubs_generate_c.cmi : _build/src/ctypes/ctypes.cmi -_build/src/cstubs/cstubs_generate_c.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_emit_c.cmo _build/src/cstubs/cstubs_c_language.cmo _build/src/cstubs/cstubs_generate_c.cmi -_build/src/cstubs/cstubs_generate_c.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_emit_c.cmx _build/src/cstubs/cstubs_c_language.cmx _build/src/cstubs/cstubs_generate_c.cmi -_build/src/cstubs/cstubs_generate_ml.cmi : _build/src/ctypes/ctypes.cmi -_build/src/cstubs/cstubs_generate_ml.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_primitive_types.cmi _build/src/cstubs/ctypes_path.cmi _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_public_name.cmi _build/src/cstubs/cstubs_errors.cmi _build/src/cstubs/cstubs_analysis.cmi _build/src/cstubs/cstubs_generate_ml.cmi -_build/src/cstubs/cstubs_generate_ml.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/cstubs/ctypes_path.cmx _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_public_name.cmx _build/src/cstubs/cstubs_errors.cmx _build/src/cstubs/cstubs_analysis.cmx _build/src/cstubs/cstubs_generate_ml.cmi -_build/src/cstubs/cstubs_inverted.cmi : _build/src/ctypes/ctypes.cmi -_build/src/cstubs/cstubs_inverted.cmo : _build/src/ctypes/ctypes_type_printing.cmi _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_generate_ml.cmi _build/src/cstubs/cstubs_generate_c.cmi _build/src/cstubs/cstubs_inverted.cmi -_build/src/cstubs/cstubs_inverted.cmx : _build/src/ctypes/ctypes_type_printing.cmx _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_generate_ml.cmx _build/src/cstubs/cstubs_generate_c.cmx _build/src/cstubs/cstubs_inverted.cmi -_build/src/cstubs/cstubs_public_name.cmi : _build/src/ctypes/ctypes_primitive_types.cmi _build/src/cstubs/ctypes_path.cmi -_build/src/cstubs/cstubs_public_name.cmo : _build/src/ctypes/ctypes_primitive_types.cmi _build/src/cstubs/ctypes_path.cmi _build/src/cstubs/cstubs_public_name.cmi -_build/src/cstubs/cstubs_public_name.cmx : _build/src/ctypes/ctypes_primitive_types.cmx _build/src/cstubs/ctypes_path.cmx _build/src/cstubs/cstubs_public_name.cmi -_build/src/cstubs/cstubs_structs.cmi : _build/src/ctypes/ctypes_types.cmi -_build/src/cstubs/cstubs_structs.cmo : _build/src/ctypes/ctypes_types.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_primitives.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/cstubs/ctypes_path.cmi _build/src/ctypes/ctypes.cmi _build/src/cstubs/cstubs_public_name.cmi _build/src/cstubs/cstubs_c_language.cmo _build/src/cstubs/cstubs_structs.cmi -_build/src/cstubs/cstubs_structs.cmx : _build/src/ctypes/ctypes_types.cmi _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_primitives.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/cstubs/ctypes_path.cmx _build/src/ctypes/ctypes.cmx _build/src/cstubs/cstubs_public_name.cmx _build/src/cstubs/cstubs_c_language.cmx _build/src/cstubs/cstubs_structs.cmi -_build/src/cstubs/ctypes_path.cmi : -_build/src/cstubs/ctypes_path.cmo : _build/src/cstubs/ctypes_path.cmi -_build/src/cstubs/ctypes_path.cmx : _build/src/cstubs/ctypes_path.cmi -_build/src/ctypes-foreign/ctypes_closure_properties.cmi : -_build/src/ctypes-foreign/ctypes_closure_properties.cmo : _build/src/ctypes-foreign/ctypes_closure_properties.cmi -_build/src/ctypes-foreign/ctypes_closure_properties.cmx : _build/src/ctypes-foreign/ctypes_closure_properties.cmi -_build/src/ctypes-foreign/ctypes_ffi.cmi : _build/src/ctypes-foreign/libffi_abi.cmi _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes-foreign/ctypes_ffi.cmo : _build/src/ctypes-foreign/libffi_abi.cmi _build/src/ctypes-foreign/ctypes_weak_ref.cmi _build/src/ctypes/ctypes_type_printing.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitives.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_memory_stubs.cmo _build/src/ctypes/ctypes_memory.cmo _build/src/ctypes-foreign/ctypes_ffi_stubs.cmo _build/src/ctypes-foreign/ctypes_ffi.cmi -_build/src/ctypes-foreign/ctypes_ffi.cmx : _build/src/ctypes-foreign/libffi_abi.cmx _build/src/ctypes-foreign/ctypes_weak_ref.cmx _build/src/ctypes/ctypes_type_printing.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitives.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes_memory_stubs.cmx _build/src/ctypes/ctypes_memory.cmx _build/src/ctypes-foreign/ctypes_ffi_stubs.cmx _build/src/ctypes-foreign/ctypes_ffi.cmi -_build/src/ctypes-foreign/ctypes_ffi_stubs.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes-foreign/ctypes_ffi_stubs.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitive_types.cmx -_build/src/ctypes-foreign/ctypes_foreign_basis.cmo : _build/src/ctypes-foreign/libffi_abi.cmi _build/src/ctypes-foreign/dl.cmi _build/src/ctypes/ctypes_std_views.cmo _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes-foreign/ctypes_ffi_stubs.cmo _build/src/ctypes-foreign/ctypes_ffi.cmi _build/src/ctypes/ctypes_coerce.cmi _build/src/ctypes/ctypes.cmi -_build/src/ctypes-foreign/ctypes_foreign_basis.cmx : _build/src/ctypes-foreign/libffi_abi.cmx _build/src/ctypes-foreign/dl.cmx _build/src/ctypes/ctypes_std_views.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes-foreign/ctypes_ffi_stubs.cmx _build/src/ctypes-foreign/ctypes_ffi.cmx _build/src/ctypes/ctypes_coerce.cmx _build/src/ctypes/ctypes.cmx -_build/src/ctypes-foreign/ctypes_weak_ref.cmi : -_build/src/ctypes-foreign/ctypes_weak_ref.cmo : _build/src/ctypes-foreign/ctypes_weak_ref.cmi -_build/src/ctypes-foreign/ctypes_weak_ref.cmx : _build/src/ctypes-foreign/ctypes_weak_ref.cmi -_build/src/ctypes-foreign/dl.cmi : -_build/src/ctypes-foreign/dl.cmo : _build/src/ctypes-foreign/dl.cmi -_build/src/ctypes-foreign/dl.cmx : _build/src/ctypes-foreign/dl.cmi -_build/src/ctypes-foreign/libffi_abi.cmi : -_build/src/ctypes-foreign/libffi_abi.cmo : _build/src/ctypes/ctypes.cmi _build/src/ctypes-foreign/libffi_abi.cmi -_build/src/ctypes-foreign/libffi_abi.cmx : _build/src/ctypes/ctypes.cmx _build/src/ctypes-foreign/libffi_abi.cmi -_build/src/ctypes-foreign/ctypes_foreign_threaded_stubs.cmo : -_build/src/ctypes-foreign/ctypes_foreign_threaded_stubs.cmx : -_build/src/ctypes-foreign/foreign.cmi : _build/src/ctypes-foreign/libffi_abi.cmi _build/src/ctypes-foreign/dl.cmi _build/src/ctypes/ctypes.cmi -_build/src/ctypes-foreign/foreign.cmo : _build/src/ctypes-foreign/ctypes_foreign_threaded_stubs.cmo _build/src/ctypes-foreign/ctypes_foreign_basis.cmo _build/src/ctypes-foreign/ctypes_closure_properties.cmi _build/src/ctypes-foreign/foreign.cmi -_build/src/ctypes-foreign/foreign.cmx : _build/src/ctypes-foreign/ctypes_foreign_threaded_stubs.cmx _build/src/ctypes-foreign/ctypes_foreign_basis.cmx _build/src/ctypes-foreign/ctypes_closure_properties.cmx _build/src/ctypes-foreign/foreign.cmi -_build/src/ctypes-top/ctypes_printers.cmi : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/lDouble.cmi _build/src/ctypes/ctypes.cmi _build/src/ctypes/complexL.cmi -_build/src/ctypes-top/ctypes_printers.cmo : _build/src/ctypes/posixTypes.cmi _build/src/ctypes/lDouble.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes.cmi _build/src/ctypes/complexL.cmi _build/src/ctypes-top/ctypes_printers.cmi -_build/src/ctypes-top/ctypes_printers.cmx : _build/src/ctypes/posixTypes.cmx _build/src/ctypes/lDouble.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes.cmx _build/src/ctypes/complexL.cmx _build/src/ctypes-top/ctypes_printers.cmi -_build/src/ctypes-top/install_ctypes_printers.cmo : -_build/src/ctypes-top/install_ctypes_printers.cmx : -_build/src/ctypes/complexL.cmi : _build/src/ctypes/lDouble.cmi -_build/src/ctypes/complexL.cmo : _build/src/ctypes/lDouble.cmi _build/src/ctypes/complexL.cmi -_build/src/ctypes/complexL.cmx : _build/src/ctypes/lDouble.cmx _build/src/ctypes/complexL.cmi -_build/src/ctypes/cstubs_internals.cmi : _build/src/ctypes/lDouble.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_memory_stubs.cmo _build/src/ctypes/ctypes_bigarray.cmi _build/src/ctypes/ctypes.cmi _build/src/ctypes/complexL.cmi -_build/src/ctypes/cstubs_internals.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_memory_stubs.cmo _build/src/ctypes/ctypes.cmi _build/src/ctypes/cstubs_internals.cmi -_build/src/ctypes/cstubs_internals.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes_memory_stubs.cmx _build/src/ctypes/ctypes.cmx _build/src/ctypes/cstubs_internals.cmi -_build/src/ctypes/ctypes.cmi : _build/src/ctypes/ctypes_types.cmi _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes.cmo : _build/src/ctypes/ctypes_value_printing.cmo _build/src/ctypes/ctypes_types.cmi _build/src/ctypes/ctypes_type_printing.cmi _build/src/ctypes/ctypes_structs_computed.cmi _build/src/ctypes/ctypes_std_views.cmo _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_memory.cmo _build/src/ctypes/ctypes_coerce.cmi _build/src/ctypes/ctypes.cmi -_build/src/ctypes/ctypes.cmx : _build/src/ctypes/ctypes_value_printing.cmx _build/src/ctypes/ctypes_types.cmi _build/src/ctypes/ctypes_type_printing.cmx _build/src/ctypes/ctypes_structs_computed.cmx _build/src/ctypes/ctypes_std_views.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_memory.cmx _build/src/ctypes/ctypes_coerce.cmx _build/src/ctypes/ctypes.cmi -_build/src/ctypes/ctypes_bigarray.cmi : _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes/ctypes_bigarray.cmo : _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitives.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_memory_stubs.cmo _build/src/ctypes/ctypes_bigarray_stubs.cmo _build/src/ctypes/ctypes_bigarray.cmi -_build/src/ctypes/ctypes_bigarray.cmx : _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitives.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes_memory_stubs.cmx _build/src/ctypes/ctypes_bigarray_stubs.cmx _build/src/ctypes/ctypes_bigarray.cmi -_build/src/ctypes/ctypes_bigarray_stubs.cmo : _build/src/ctypes/ctypes_ptr.cmo -_build/src/ctypes/ctypes_bigarray_stubs.cmx : _build/src/ctypes/ctypes_ptr.cmx -_build/src/ctypes/ctypes_coerce.cmi : _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes_coerce.cmo : _build/src/ctypes/ctypes_type_printing.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_coerce.cmi -_build/src/ctypes/ctypes_coerce.cmx : _build/src/ctypes/ctypes_type_printing.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes_coerce.cmi -_build/src/ctypes/ctypes_memory.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_roots_stubs.cmo _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_memory_stubs.cmo _build/src/ctypes/ctypes_bigarray.cmi -_build/src/ctypes/ctypes_memory.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_roots_stubs.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_memory_stubs.cmx _build/src/ctypes/ctypes_bigarray.cmx -_build/src/ctypes/ctypes_memory_stubs.cmo : _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes/ctypes_memory_stubs.cmx : _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitive_types.cmx -_build/src/ctypes/ctypes_primitive_types.cmi : _build/src/ctypes/lDouble.cmi _build/src/ctypes/complexL.cmi -_build/src/ctypes/ctypes_primitive_types.cmo : _build/src/ctypes/lDouble.cmi _build/src/ctypes/complexL.cmi _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes/ctypes_primitive_types.cmx : _build/src/ctypes/lDouble.cmx _build/src/ctypes/complexL.cmx _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes/ctypes_primitives.cmo : _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes/ctypes_primitives.cmx : _build/src/ctypes/ctypes_primitive_types.cmx -_build/src/ctypes/ctypes_ptr.cmo : -_build/src/ctypes/ctypes_ptr.cmx : -_build/src/ctypes/ctypes_roots_stubs.cmo : _build/src/ctypes/ctypes_ptr.cmo -_build/src/ctypes/ctypes_roots_stubs.cmx : _build/src/ctypes/ctypes_ptr.cmx -_build/src/ctypes/ctypes_static.cmi : _build/src/ctypes/lDouble.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_bigarray.cmi _build/src/ctypes/complexL.cmi -_build/src/ctypes/ctypes_static.cmo : _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitives.cmo _build/src/ctypes/ctypes_primitive_types.cmi _build/src/ctypes/ctypes_bigarray.cmi _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes_static.cmx : _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitives.cmx _build/src/ctypes/ctypes_primitive_types.cmx _build/src/ctypes/ctypes_bigarray.cmx _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes_std_view_stubs.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_memory_stubs.cmo -_build/src/ctypes/ctypes_std_view_stubs.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_memory_stubs.cmx -_build/src/ctypes/ctypes_std_views.cmo : _build/src/ctypes/ctypes_std_view_stubs.cmo _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_memory_stubs.cmo _build/src/ctypes/ctypes_memory.cmo _build/src/ctypes/ctypes_coerce.cmi -_build/src/ctypes/ctypes_std_views.cmx : _build/src/ctypes/ctypes_std_view_stubs.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_memory_stubs.cmx _build/src/ctypes/ctypes_memory.cmx _build/src/ctypes/ctypes_coerce.cmx -_build/src/ctypes/ctypes_structs.cmi : _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes_structs.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_structs.cmi -_build/src/ctypes/ctypes_structs.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_structs.cmi -_build/src/ctypes/ctypes_structs_computed.cmi : _build/src/ctypes/ctypes_structs.cmi _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes_structs_computed.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_structs_computed.cmi -_build/src/ctypes/ctypes_structs_computed.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_structs_computed.cmi -_build/src/ctypes/ctypes_type_printing.cmi : _build/src/ctypes/ctypes_static.cmi -_build/src/ctypes/ctypes_type_printing.cmo : _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_primitives.cmo _build/src/ctypes/ctypes_bigarray.cmi _build/src/ctypes/ctypes_type_printing.cmi -_build/src/ctypes/ctypes_type_printing.cmx : _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_primitives.cmx _build/src/ctypes/ctypes_bigarray.cmx _build/src/ctypes/ctypes_type_printing.cmi -_build/src/ctypes/ctypes_types.cmi : _build/src/ctypes/lDouble.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/complexL.cmi -_build/src/ctypes/ctypes_value_printing.cmo : _build/src/ctypes/ctypes_value_printing_stubs.cmo _build/src/ctypes/ctypes_type_printing.cmi _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_memory.cmo -_build/src/ctypes/ctypes_value_printing.cmx : _build/src/ctypes/ctypes_value_printing_stubs.cmx _build/src/ctypes/ctypes_type_printing.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_memory.cmx -_build/src/ctypes/ctypes_value_printing_stubs.cmo : _build/src/ctypes/ctypes_ptr.cmo _build/src/ctypes/ctypes_primitive_types.cmi -_build/src/ctypes/ctypes_value_printing_stubs.cmx : _build/src/ctypes/ctypes_ptr.cmx _build/src/ctypes/ctypes_primitive_types.cmx -_build/src/ctypes/lDouble.cmi : -_build/src/ctypes/lDouble.cmo : _build/src/ctypes/lDouble.cmi -_build/src/ctypes/lDouble.cmx : _build/src/ctypes/lDouble.cmi -_build/src/ctypes/posixTypes.cmi : _build/src/ctypes/ctypes.cmi -_build/src/ctypes/posixTypes.cmo : _build/src/ctypes/ctypes_std_views.cmo _build/src/ctypes/ctypes_static.cmi _build/src/ctypes/ctypes.cmi _build/src/ctypes/posixTypes.cmi -_build/src/ctypes/posixTypes.cmx : _build/src/ctypes/ctypes_std_views.cmx _build/src/ctypes/ctypes_static.cmx _build/src/ctypes/ctypes.cmx _build/src/ctypes/posixTypes.cmi -_build/src/discover/commands.cmi : -_build/src/discover/commands.cmo : _build/src/discover/commands.cmi -_build/src/discover/commands.cmx : _build/src/discover/commands.cmi -_build/src/discover/discover.cmo : -_build/src/discover/discover.cmx : diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 000d92202..6886b0e16 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,10 +63,7 @@ jobs: opam install -t --deps-only . - name: Build - run: opam exec -- make + run: opam exec -- dune build - name: Test - run: opam exec -- make test - - - name: Test inverted stubs - run: opam pin add ctypes-inverted-stubs-example https://github.com/yallop/ocaml-ctypes-inverted-stubs-example.git + run: opam exec -- dune runtest diff --git a/.gitignore b/.gitignore index b80a2984a..6d6fc6bb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,5 @@ +.*.swp _build _opam -libffi.config -asneeded.config -discover -gen_c_primitives -gen_c_primitives.log -gen_libffi_abi -gen_libffi_abi.log -src/ctypes/ctypes_primitives.ml -src/ctypes_config.h -src/ctypes_config.ml -src/ctypes-foreign/dl_stubs.c -src/ctypes-foreign/dl.ml -src/discover/commands.cm* -src/discover/discover.cm* -src/configure/extract_from_c.cm* -src/configure/gen_c_primitives.cm* -src/configure/gen_libffi_abi.cm* -*~ -generated_stubs.c -generated_bindings.ml -generated_struct_bindings.ml -ncurses_generated.ml -ncurses_stubs.c -date_generated.ml -date_stubs.c -fts_generated.ml -fts_stubs.c -libffi_abi.ml +*.install +.merlin diff --git a/.merlin b/.merlin deleted file mode 100644 index 531c84965..000000000 --- a/.merlin +++ /dev/null @@ -1,19 +0,0 @@ -PRJ ctypes -S src -S src/cstubs -S src/libffi-abigen -S src/discover -S src/ctypes -S src/ctypes-top -S src/configure -S src/ctypes-foreign -B _build -B _build/src -B _build/src/cstubs -B _build/src/libffi-abigen -B _build/src/ctypes -B _build/src/ctypes-top -B _build/src/configure -B _build/src/ctypes-foreign -PKG bytes -PKG integers diff --git a/META b/META deleted file mode 100644 index 28364c0d8..000000000 --- a/META +++ /dev/null @@ -1,43 +0,0 @@ -version = "0.20.2" -description = "Combinators for binding to C libraries without writing any C." -requires = "bigarray-compat bytes integers" -archive(byte) = "ctypes.cma" -archive(byte, plugin) = "ctypes.cma" -archive(byte, toploop) = "ctypes.cma ctypes-top.cma" -archive(native) = "ctypes.cmxa" -archive(native, plugin) = "ctypes.cmxs" -exists_if = "ctypes.cma" - -package "top" ( - version = "0.20.2" - description = "Toplevel printers for C types" - requires = "ctypes" - archive(byte) = "ctypes-top.cma" - archive(byte, plugin) = "ctypes-top.cma" - archive(native) = "ctypes-top.cmxa" - archive(native, plugin) = "ctypes-top.cmxs" - exists_if = "ctypes-top.cma" -) - -package "stubs" ( - version = "0.20.2" - description = "Stub generation from C types" - requires = "ctypes str" - archive(byte) = "cstubs.cma" - archive(byte, plugin) = "cstubs.cma" - archive(native) = "cstubs.cmxa" - archive(native, plugin) = "cstubs.cmxs" - xen_linkopts = "-lctypes_stubs_xen" - exists_if = "cstubs.cma" -) - -package "foreign" ( - version = "0.20.2" - description = "Dynamic linking of C functions" - requires = "threads ctypes" - archive(byte) = "ctypes-foreign.cma" - archive(byte, plugin) = "ctypes-foreign.cma" - archive(native) = "ctypes-foreign.cmxa" - archive(native, plugin) = "ctypes-foreign.cmxs" - exists_if = "ctypes-foreign.cma" -) diff --git a/Makefile b/Makefile index 765b29ab5..472c0c1d3 100644 --- a/Makefile +++ b/Makefile @@ -1,200 +1,10 @@ -.SECONDEXPANSION: +.PHONY: build clean test -BEST:=$(shell if ocamlopt > /dev/null 2>&1; then echo native; else echo byte; fi) -OPAQUE:=$(shell if ocamlopt -opaque 2>/dev/null; then echo -opaque; fi) -NO_KEEP_LOCS:=$(shell if ocamlopt -no-keep-locs 2>/dev/null; then echo -no-keep-locs; fi) -DEBUG=true -COVERAGE=false -OCAML=ocaml -OCAMLFIND=ocamlfind $(OCAMLFINDFLAGS) -HOSTOCAMLFIND=$(OCAMLFIND) -OCAMLDEP=$(OCAMLFIND) ocamldep -OCAMLMKLIB=$(OCAMLFIND) ocamlmklib -VPATH=src examples -BUILDDIR=_build -BASE_PROJECTS=configure libffi-abigen configured ctypes ctypes-top -FOREIGN_PROJECTS=test-libffi ctypes-foreign -STUB_PROJECTS=cstubs -PROJECTS=$(BASE_PROJECTS) $(FOREIGN_PROJECTS) $(STUB_PROJECTS) -DEP_DIRS=$(foreach project,$(PROJECTS),$($(project).dir)) -GENERATED=src/ctypes/ctypes_primitives.ml \ - src/ctypes-foreign/libffi_abi.ml \ - src/ctypes-foreign/dl.ml \ - src/ctypes-foreign/dl_stubs.c \ - libffi.config \ - asneeded.config \ - discover \ - gen_c_primitives \ - gen_c_primitives.log \ - gen_libffi_abi \ - src/configure/extract_from_c.cmi \ - src/configure/extract_from_c.cmo \ - src/configure/gen_c_primitives.cmi \ - src/configure/gen_c_primitives.cmo \ - src/configure/gen_libffi_abi.cmi \ - src/configure/gen_libffi_abi.cmo \ - src/discover/commands.cmi \ - src/discover/commands.cmo \ - src/discover/discover.cmi \ - src/discover/discover.cmo +build: + dune build -OCAML_FFI_INCOPTS=$(libffi_opt) -export CFLAGS DEBUG +test: + dune runtest -EXTDLL:=$(shell $(OCAMLFIND) ocamlc -config | awk '/^ext_dll:/{print $$2}') -OSYSTEM:=$(shell $(OCAMLFIND) ocamlc -config | awk '/^system:/{print $$2}') - -ifneq (,$(filter mingw%,$(OSYSTEM))) -OS_ALT_SUFFIX=.win -else -OS_ALT_SUFFIX=.unix -endif - -# public targets -all: libffi.config $(PROJECTS) - -ctypes-base: $(BASE_PROJECTS) -ctypes-foreign: ctypes-base test-libffi -ctypes-stubs: ctypes-base $(STUB_PROJECTS) - -clean: clean-examples clean-tests - rm -fr _build - rm -f $(GENERATED) - -# ctypes subproject -ctypes.cmi_only = ctypes_static ctypes_primitive_types ctypes_structs cstubs_internals -ctypes.public = lDouble complexL ctypes posixTypes ctypes_types -ctypes.dir = src/ctypes -ctypes.extra_mls = ctypes_primitives.ml -ctypes.deps = bigarray-compat integers -ctypes.linkdeps = integers_stubs -ctypes.install = yes -ctypes.install_native_objects = yes -ifeq ($(XEN),enable) -ctypes.xen = yes -endif - -ctypes: PROJECT=ctypes -ctypes: $(ctypes.dir)/$(ctypes.extra_mls) $$(LIB_TARGETS) - -# cstubs subproject -cstubs.public = cstubs_structs cstubs cstubs_inverted -cstubs.dir = src/cstubs -cstubs.subproject_deps = ctypes -cstubs.deps = str integers -cstubs.install = yes -cstubs.install_native_objects = yes -cstubs.extra_hs = $(package_integers_path)/ocaml_integers.h - -cstubs: PROJECT=cstubs -cstubs: $(cstubs.dir)/$(cstubs.extra_mls) $$(LIB_TARGETS) - -# ctypes-foreign subproject -ctypes-foreign.public = dl libffi_abi foreign -ctypes-foreign.dir = src/ctypes-foreign -ctypes-foreign.subproject_deps = ctypes -ctypes-foreign.deps = integers -ctypes-foreign.install = yes -ctypes-foreign.install_native_objects = yes -ctypes-foreign.extra_cs = dl_stubs.c -ctypes-foreign.extra_mls = libffi_abi.ml dl.ml -ctypes-foreign.cmi_opts = $(OPAQUE) $(NO_KEEP_LOCS) -ctypes-foreign.cmo_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %) -ctypes-foreign.cmx_opts = $(OCAML_FFI_INCOPTS:%=-ccopt %) -ctypes-foreign.link_flags = $(libffi_lib) $(lib_process) -ctypes-foreign.threads = yes - -ctypes-foreign: PROJECT=ctypes-foreign -ctypes-foreign: $$(LIB_TARGETS) - -# ctypes-top subproject -ctypes-top.public = ctypes_printers -ctypes-top.dir = src/ctypes-top -ctypes-top.install = yes -ctypes-top.deps = compiler-libs integers -ctypes-top.subproject_deps = ctypes -ctypes-top.install_native_objects = yes - -ctypes-top: PROJECT=ctypes-top -ctypes-top: $$(LIB_TARGETS) - -# configuration -configured: src/ctypes/ctypes_primitives.ml src/ctypes-foreign/libffi_abi.ml src/ctypes-foreign/dl.ml src/ctypes-foreign/dl_stubs.c - -src/ctypes-foreign/dl.ml: src/ctypes-foreign/dl.ml$(OS_ALT_SUFFIX) - cp $< $@ -src/ctypes-foreign/dl_stubs.c: src/ctypes-foreign/dl_stubs.c$(OS_ALT_SUFFIX) - cp $< $@ - -src/ctypes/ctypes_primitives.ml: src/configure/extract_from_c.ml src/configure/gen_c_primitives.ml - $(HOSTOCAMLFIND) ocamlc -o gen_c_primitives -package str -strict-sequence -linkpkg $^ -I src/configure - ./gen_c_primitives > $@ 2> gen_c_primitives.log || (rm $@ && cat gen_c_primitives.log && false) - -src/ctypes-foreign/libffi_abi.ml: src/configure/extract_from_c.ml src/configure/gen_libffi_abi.ml - $(HOSTOCAMLFIND) ocamlc -o gen_libffi_abi -package str -strict-sequence -linkpkg $^ -I src/configure - ./gen_libffi_abi > $@ 2> gen_c_primitives.log || (rm $@ && cat gen_c_primitives.log && false) - -libffi.config: src/discover/commands.mli src/discover/commands.ml src/discover/discover.ml - $(HOSTOCAMLFIND) ocamlc -o discover -package str -strict-sequence -linkpkg $^ -I src/discover - ./discover -ocamlc "$(OCAMLFIND) ocamlc" > $@ || (rm $@ && false) - -asneeded.config: - ./src/discover/determine_as_needed_flags.sh >> $@ - -# dependencies -depend: configure - $(OCAMLDEP) -one-line $(foreach dir,$(DEP_DIRS),-I $(dir)) \ - $(shell find src examples -name '*.mli' -o -name '*.ml') \ - | sed "s!src/!_build/src/!g; s!examples/!_build/examples/!g" | sort > .depend - -#installation -META-install: - $(OCAMLFIND) install ctypes META CHANGES.md - -install-%: PROJECT=$* -install-%: - $(if $(filter yes,$($(PROJECT).install)),\ - $(OCAMLFIND) install -add ctypes -optional $^ \ - $(LIB_TARGETS) $(LIB_TARGET_EXTRAS) \ - $(INSTALL_MLIS) $(INSTALL_CMIS) \ - $(INSTALL_CMTS) $(INSTALL_CMTIS) \ - $(INSTALL_HEADERS) \ - $(if $(filter yes,$($(PROJECT).install_native_objects)),$(NATIVE_OBJECTS))) - -$(PROJECTS:%=install-%): META-install - -install: META-install $(PROJECTS:%=install-%) - -uninstall: - $(OCAMLFIND) remove ctypes - -DOCFILES=$(foreach project,$(PROJECTS),\ - $(foreach mli,$($(project).public),\ - $($(project).dir)/$(mli).mli)) -DOCFLAGS=-I $(shell ocamlfind query integers) $(foreach project,$(PROJECTS),-I $(BUILDDIR)/$($(project).dir)) - -doc: - ocamldoc -html $(DOCFLAGS) $(DOCFILES) - - -.PHONY: depend clean configure all install doc $(PROJECTS) - -include .depend Makefile.rules Makefile.examples Makefile.tests --include libffi.config --include asneeded.config - -ifeq ($(libffi_available),false) -test-libffi: - @echo "The following required C libraries are missing: libffi." - @echo "Please install them and retry. If they are installed in a non-standard location" - @echo "or need special flags, set the environment variables _CFLAGS and _LIBS" - @echo "accordingly and retry." - @echo - @echo " For example, if libffi is installed in /opt/local, you can type:" - @echo - @echo " export LIBFFI_CFLAGS=-I/opt/local/include" - @echo " export LIBFFI_LIBS=\"-L/opt/local/lib -lffi\"" - @exit 1 -else: -test-libffi: -endif +clean: + dune clean diff --git a/Makefile.examples b/Makefile.examples deleted file mode 100644 index dd3eb55d6..000000000 --- a/Makefile.examples +++ /dev/null @@ -1,147 +0,0 @@ -# -*- Makefile -*- - -# subproject: fts with stub generation -fts-stubs.install = no -fts-stubs.dir = examples/fts/stub-generation/bindings -fts-stubs.threads = yes -fts-stubs.deps = integers -fts-stubs.subproject_deps = ctypes ctypes-foreign -fts-stubs: PROJECT=fts-stubs -fts-stubs: $$(LIB_TARGETS) - -fts-stub-generator.install = no -fts-stub-generator.dir = examples/fts/stub-generation/stub-generator -fts-stub-generator.threads = yes -fts-stub-generator.deps = integers -fts-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign fts-stubs -fts-stub-generator.deps = str unix bigarray-compat integers -fts-stub-generator: PROJECT=fts-stub-generator -fts-stub-generator: $$(NATIVE_TARGET) - -fts-cmd.install = no -fts-cmd.dir = examples/fts/stub-generation -fts-cmd.threads = yes -fts-cmd.subproject_deps = ctypes \ - ctypes-foreign fts-stubs -fts-cmd.deps = str unix bigarray-compat integers -fts-cmd.extra_mls = fts_generated.ml -fts-cmd.extra_cs = fts_stubs.c -fts-cmd: CFLAGS+=-D_FILE_OFFSET_BITS=32 -fts-cmd: PROJECT=fts-cmd -fts-cmd: $$(NATIVE_TARGET) - -fts-cmd-build: examples/fts/stub-generation/fts_generated.ml -examples/fts/stub-generation/fts_generated.ml: fts-stub-generator - _build/fts-stub-generator.native - -# subproject: fts using dynamic linking (foreign) -fts.install = no -fts.dir = examples/fts/foreign -fts.threads = yes -fts.deps = unix bigarray-compat str integers -fts.subproject_deps = ctypes ctypes-foreign -fts: PROJECT=fts -fts: $$(NATIVE_TARGET) - -# subproject: date with stub generation -date-stubs.install = no -date-stubs.dir = examples/date/stub-generation/bindings -date-stubs.subproject_deps = ctypes -date-stubs: PROJECT=date-stubs -date-stubs: $$(LIB_TARGETS) - -date-stub-generator.install = no -date-stub-generator.dir = examples/date/stub-generation/stub-generator -date-stub-generator.subproject_deps = ctypes cstubs date-stubs -date-stub-generator.deps = str unix bigarray-compat integers -date-stub-generator: PROJECT=date-stub-generator -date-stub-generator: $$(NATIVE_TARGET) - -date-cmd.install = no -date-cmd.dir = examples/date/stub-generation -date-cmd.subproject_deps = ctypes date-stubs -date-cmd.deps = str unix bigarray-compat integers -date-cmd.extra_mls = date_generated.ml -date-cmd.extra_cs = date_stubs.c -date-cmd: PROJECT=date-cmd -date-cmd: $$(NATIVE_TARGET) - -date-cmd-build: examples/date/stub-generation/date_generated.ml -examples/date/stub-generation/date_generated.ml: - _build/date-stub-generator.native - -# subproject: date using dynamic linking (foreign) -date.install = no -date.dir = examples/date/foreign -date.threads = yes -date.subproject_deps = ctypes ctypes-foreign -date.deps = unix bigarray-compat str integers -date: PROJECT=date -date: $$(NATIVE_TARGET) - -# subproject: ncurses with stub generation -ncurses-stubs.install = no -ncurses-stubs.dir = examples/ncurses/stub-generation/bindings -ncurses-stubs.subproject_deps = ctypes -ncurses-stubs.deps = str unix bigarray-compat integers -ncurses-stubs: PROJECT=ncurses-stubs -ncurses-stubs: $$(NATIVE_TARGET) $$(LIB_TARGETS) - -ncurses-stub-generator.install = no -ncurses-stub-generator.dir = examples/ncurses/stub-generation/stub-generator -ncurses-stub-generator.threads = yes -ncurses-stub-generator.deps = integers -ncurses-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign ncurses-stubs -ncurses-stub-generator.deps = str unix bigarray-compat integers -ncurses-stub-generator: PROJECT=ncurses-stub-generator -ncurses-stub-generator: $$(NATIVE_TARGET) - -ncurses-cmd.install = no -ncurses-cmd.dir = examples/ncurses/stub-generation -ncurses-cmd.subproject_deps = ctypes ncurses-stubs -ncurses-cmd.deps = str unix bigarray-compat integers -ncurses-cmd.extra_mls = ncurses_generated.ml -ncurses-cmd.extra_cs = ncurses_stubs.c -ncurses-cmd.link_flags = -lncurses -ncurses-cmd: PROJECT=ncurses-cmd -ncurses-cmd: $$(NATIVE_TARGET) - -ncurses-cmd-build: examples/ncurses/stub-generation/ncurses_generated.ml -examples/ncurses/stub-generation/ncurses_generated.ml: ncurses-stubs - _build/ncurses-stub-generator.native - -# subproject: ncurses using dynamic linking (foreign) -ncurses.install = no -ncurses.dir = examples/ncurses/foreign -ncurses.threads = yes -ncurses.subproject_deps = ctypes ctypes-foreign -ncurses.deps = unix bigarray-compat str integers -ncurses.link_flags = -lncurses -ncurses: PROJECT=ncurses -ncurses: $$(NATIVE_TARGET) - -EXAMPLES = -EXAMPLES += ncurses ncurses-stubs ncurses-stub-generator ncurses-cmd-build ncurses-cmd -EXAMPLES += fts fts-stubs fts-stub-generator fts-cmd-build fts-cmd -EXAMPLES += date date-stubs date-stub-generator date-cmd-build date-cmd - -run-examples: examples - # this doesn't run the ncurses example, which takes control of the terminal - _build/date.native - _build/date-cmd.native - _build/fts-cmd.native src - -EXAMPLES_GENERATED=$(foreach example,$(EXAMPLES),\ - $(if $($(example).extra_mls), \ - $($(example).dir)/$($(example).extra_mls)) \ - $(if $($(example).extra_cs), \ - $($(example).dir)/$($(example).extra_cs))) - -clean-examples: - rm -f $(EXAMPLES_GENERATED) - -.PHONY: build $(EXAMPLES) clean-examples - -examples: build $(EXAMPLES) diff --git a/Makefile.rules b/Makefile.rules deleted file mode 100644 index 605e3c4d0..000000000 --- a/Makefile.rules +++ /dev/null @@ -1,137 +0,0 @@ -# -*- Makefile -*- - -.SECONDARY: - -package_integers_path = $(shell $(OCAMLFIND) query integers) -ifneq (,$(filter mingw%,$(OSYSTEM))) -lib_process=-lpsapi -OCAMLMKLIB_EXTRA_FLAGS=-ldopt "-link -static-libgcc" # see GPR#1535 -ifeq ($(DEBUG),false) - CFLAGS=-std=c99 -Wall -O3 $(OCAML_FFI_INCOPTS) "-I$(package_integers_path)" -else - CFLAGS=-std=c99 -Wall -g $(OCAML_FFI_INCOPTS) "-I$(package_integers_path)" -endif -else -ifeq ($(DEBUG),false) - CFLAGS=-fPIC -Wall -O3 $(OCAML_FFI_INCOPTS) "-I$(package_integers_path)" -else - CFLAGS=-fPIC -Wall -g $(OCAML_FFI_INCOPTS) "-I$(package_integers_path)" -endif -endif - -ifeq ($(DEBUG),false) - OCAMLFLAGS=-principal -short-paths -strict-sequence -ccopt "-I$(package_integers_path)" -else - OCAMLFLAGS=-principal -short-paths -strict-sequence -g -ccopt "-I$(package_integers_path)" -endif -ifneq ($(COVERAGE),false) - OCAMLFIND_BISECT_FLAGS=-package bisect_ppx -endif - -C_SOURCE = $(sort $(wildcard $($(PROJECT).dir)/*.c) $(patsubst %,$($(PROJECT).dir)/%,$($(PROJECT).extra_cs))) -ML_SOURCE = $(shell $(OCAMLDEP) -sort $(sort $(wildcard $($(PROJECT).dir)/*.ml) \ - $(patsubst %,$($(PROJECT).dir)/%,$($(PROJECT).extra_mls)))) - -NATIVE_OBJECTS = $(ML_SOURCE:$($(PROJECT).dir)/%.ml=$(BUILDDIR)/$($(PROJECT).dir)/%.cmx) -BYTE_OBJECTS = $(ML_SOURCE:$($(PROJECT).dir)/%.ml=$(BUILDDIR)/$($(PROJECT).dir)/%.cmo) -C_OBJECTS = $(C_SOURCE:$($(PROJECT).dir)/%.c=$(BUILDDIR)/$($(PROJECT).dir)/%.o) -XEN_OBJECTS = $(C_SOURCE:$($(PROJECT).dir)/%.c=$(BUILDDIR)/xen/$($(PROJECT).dir)/%.o) - -STUB_LIB = $(if $(C_OBJECTS),$(BUILDDIR)/dll$(PROJECT)_stubs$(EXTDLL)) - -OPAM_PREFIX=$(shell opam config var prefix) -XEN_LIB = $(if $($(PROJECT).xen),$(BUILDDIR)/dll$(PROJECT)_stubs_xen$(EXTDLL)) -XEN_CFLAGS=$(if $(XEN_LIB), \ - $(CFLAGS) -DMINIOS $(shell env PKG_CONFIG_PATH="$(OPAM_PREFIX)/lib/pkgconfig" \ - pkg-config --cflags mirage-xen) -fno-builtin) - -CMO_OPTS = $($(PROJECT).cmo_opts) -CMX_OPTS = $($(PROJECT).cmx_opts) -CMI_OPTS = $($(PROJECT).cmi_opts) -CMA_OPTS = $(if $(C_OBJECTS),-cclib -l$(PROJECT)_stubs -dllib -l$(PROJECT)_stubs) \ - $(foreach libdep,$($(PROJECT).linkdeps),\ - -cclib -l$(libdep) -dllib -l$(libdep)) -SUBPROJECT_DEPS = $($(PROJECT).subproject_deps) -LOCAL_CMXAS = $(SUBPROJECT_DEPS:%=$(BUILDDIR)/%.cmxa) -LOCAL_CMAS = $(SUBPROJECT_DEPS:%=$(BUILDDIR)/%.cma) -CMXA_OPTS = $(if $(C_OBJECTS),-cclib -l$(PROJECT)_stubs)\ - $(foreach libdep,$($(PROJECT).linkdeps),\ - -cclib -l$(libdep)) - -OCAMLINCLUDES = -I $(BUILDDIR)/$($(PROJECT).dir) \ - $(foreach spdep,$($(PROJECT).subproject_deps),\ - -I $(BUILDDIR)/$($(spdep).dir)) -NATIVE_LIB=$(BUILDDIR)/$(PROJECT).cmxa -NATIVE_TARGET=$(BUILDDIR)/$(PROJECT).native -BEST_TARGET=$(BUILDDIR)/$(PROJECT).$(BEST) -LIB_TARGETS = $(BUILDDIR)/$(PROJECT).cma \ - $(STUB_LIB) \ - $(XEN_LIB) -ifeq ($(BEST),native) -LIB_TARGETS += $(BUILDDIR)/$(PROJECT).cmxa -endif -OCAMLC_WHERE:=$(shell $(OCAMLFIND) ocamlc -where) -ifneq ($(wildcard $(OCAMLC_WHERE)/dynlink.cmxa $(OCAMLC_WHERE)/dynlink/dynlink.cmxa),) -LIB_TARGETS += $(BUILDDIR)/$(PROJECT).cmxs -endif -LIB_TARGET_EXTRAS = $(if $(STUB_LIB),$(BUILDDIR)/lib$(PROJECT)_stubs.a) \ - $(if $(XEN_LIB),$(BUILDDIR)/lib$(PROJECT)_stubs_xen.a) \ - $(BUILDDIR)/$(PROJECT).a -INSTALL_CMIS = $($(PROJECT).public:%=$(BUILDDIR)/$($(PROJECT).dir)/%.cmi) \ - $($(PROJECT).cmi_only:%=$(BUILDDIR)/$($(PROJECT).dir)/%.cmi) -INSTALL_CMTIS = $($(PROJECT).public:%=$(BUILDDIR)/$($(PROJECT).dir)/%.cmti) -INSTALL_CMTS = $($(PROJECT).public:%=$(BUILDDIR)/$($(PROJECT).dir)/%.cmt) -INSTALL_MLIS = $($(PROJECT).public:%=$($(PROJECT).dir)/%.mli) -INSTALL_HEADERS = $(wildcard $($(PROJECT).dir)/*.h) $($(PROJECT).extra_hs) -THREAD_FLAG = $(if $(filter yes,$($(PROJECT).threads)),-thread) -LINK_FLAGS = $(as_needed_flags) $($(PROJECT).link_flags) -OCAML_LINK_FLAGS=$(LINK_FLAGS:%=-cclib %) -OCAMLMKLIB_FLAGS_PLAIN=$($(PROJECT).link_flags) -OCAMLMKLIB_FLAGS=$(OCAMLMKLIB_FLAGS_PLAIN:%=-ldopt %) -OCAMLFIND_PACKAGE_FLAGS=$(patsubst %,-package %,$($(PROJECT).deps)) \ - $(patsubst %,-thread -package threads,$(THREAD_FLAG)) \ - $(OCAMLFIND_BISECT_FLAGS) -$(BUILDDIR)/%.cmxa: $$(NATIVE_OBJECTS) - $(OCAMLFIND) opt -a -linkall $(OCAMLFLAGS) $(THREAD_FLAG) $(OCAMLFIND_PACKAGE_FLAGS) $(CMXA_OPTS) -o $@ $(NATIVE_OBJECTS) $(OCAML_LINK_FLAGS) - -$(BUILDDIR)/dll%_stubs$(EXTDLL): $$(C_OBJECTS) - $(OCAMLMKLIB) -o $(BUILDDIR)/$*_stubs $^ $(OCAMLMKLIB_FLAGS) $(OCAMLMKLIB_EXTRA_FLAGS) - -$(BUILDDIR)/dll%_stubs_xen$(EXTDLL): $$(XEN_OBJECTS) - $(OCAMLMKLIB) -o $(BUILDDIR)/$*_stubs_xen $^ $(OCAMLMKLIB_FLAGS) $(OCAMLMKLIB_EXTRA_FLAGS) - -$(BUILDDIR)/%.cmxs : $$(NATIVE_OBJECTS) $(C_OBJECTS) - $(OCAMLFIND) opt -shared -linkall $(OCAMLFLAGS) $(THREAD_FLAG) $(OCAMLFIND_PACKAGE_FLAGS) -o $@ $(NATIVE_OBJECTS) $(C_OBJECTS) $(OCAML_LINK_FLAGS) - -$(BUILDDIR)/%.cma: $$(BYTE_OBJECTS) - $(OCAMLFIND) ocamlc -a -linkall $(OCAMLFLAGS) $(THREAD_FLAG) $(CMA_OPTS) $(OCAMLFIND_PACKAGE_FLAGS) -o $@ $(BYTE_OBJECTS) $(OCAML_LINK_FLAGS) - -$(BUILDDIR)/%.cmo : %.ml - @mkdir -p $(@D) - $(OCAMLFIND) ocamlc $(OCAMLFIND_PACKAGE_FLAGS) $(OCAMLFLAGS) $(THREAD_FLAG) $(CMO_OPTS) -c -o $@ $(OCAMLINCLUDES) $< - -$(BUILDDIR)/%.cmx : %.ml - @mkdir -p $(@D) - $(OCAMLFIND) opt -bin-annot -c -o $@ $(OCAMLFIND_PACKAGE_FLAGS) $(OCAMLFLAGS) $(THREAD_FLAG) $(OCAMLFIND_PACKAGE_FLAGS) $(CMX_OPTS) $(OCAMLINCLUDES) $(filter %.ml,$<) - -$(BUILDDIR)/%.o : %.c - @mkdir -p $(@D) - cd $(@D) && $(OCAMLFIND) ocamlc -c $(OCAMLFIND_PACKAGE_FLAGS) $(CFLAGS:%=-ccopt %) -o $(@F) $(OCAMLFLAGS) $(realpath $<) - -$(BUILDDIR)/xen/%.o : %.c - @mkdir -p $(@D) - cd $(@D) && $(OCAMLFIND) ocamlc -c $(OCAMLFIND_PACKAGE_FLAGS) $(XEN_CFLAGS:%=-ccopt %) -o $(@F) $(OCAMLFLAGS) $(realpath $<) - -$(BUILDDIR)/%.cmi : %.mli - @mkdir -p $(@D) -ifeq ($(BEST),native) - $(OCAMLFIND) ocamlopt -bin-annot -c -o $@ $(OCAMLFIND_PACKAGE_FLAGS) $(CMI_OPTS) $(OCAMLFLAGS) $(OCAMLINCLUDES) $< -else - $(OCAMLFIND) ocamlc -bin-annot -c -o $@ $(OCAMLFIND_PACKAGE_FLAGS) $(CMI_OPTS) $(OCAMLFLAGS) $(OCAMLINCLUDES) $< -endif - -$(BUILDDIR)/%.native : $$(NATIVE_OBJECTS) $$(C_OBJECTS) - $(OCAMLFIND) opt -I $(BUILDDIR) -linkpkg $(OCAMLFLAGS) $(THREAD_FLAG) $(OCAMLFIND_PACKAGE_FLAGS) $(LOCAL_CMXAS) -o $@ $(NATIVE_OBJECTS) $(C_OBJECTS) $(OCAML_LINK_FLAGS) - -$(BUILDDIR)/%.byte : $$(BYTE_OBJECTS) $$(C_OBJECTS) - $(OCAMLFIND) ocamlc -custom -I $(BUILDDIR) -linkpkg $(OCAMLFLAGS) $(THREAD_FLAG) $(OCAMLFIND_PACKAGE_FLAGS) $(LOCAL_CMAS) -o $@ $(BYTE_OBJECTS) $(C_OBJECTS) $(OCAML_LINK_FLAGS) diff --git a/Makefile.tests b/Makefile.tests deleted file mode 100644 index 21dfe228b..000000000 --- a/Makefile.tests +++ /dev/null @@ -1,1396 +0,0 @@ -# -*- Makefile -*- - -VPATH += tests - -CFLAGS += -I "$(CURDIR)/src/ctypes" -I "$(CURDIR)/tests" - -CC=$(shell ocamlc -config | sed -n '/native_c_compiler/{ s/[^:]*://; p;}') - -# tests-common subproject -tests-common.dir = tests/tests-common -tests-common.subproject_deps = ctypes cstubs \ - ctypes-foreign -tests-common.install = no -tests-common.install_native_objects = yes - -tests-common: PROJECT=tests-common -tests-common: $$(LIB_TARGETS) - - -test-raw.dir = tests/test-raw -test-raw.threads = yes -test-raw.deps = bigarray-compat oUnit str integers -test-raw.subproject_deps = ctypes ctypes-foreign -test-raw: PROJECT=test-raw -test-raw: $$(BEST_TARGET) - -test-pointers-stubs.dir = tests/test-pointers/stubs -test-pointers-stubs.threads = yes -test-pointers-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-pointers-stubs: PROJECT=test-pointers-stubs -test-pointers-stubs: $$(LIB_TARGETS) - -test-pointers-stub-generator.dir = tests/test-pointers/stub-generator -test-pointers-stub-generator.threads = yes -test-pointers-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-pointers-stubs tests-common -test-pointers-stub-generator.deps = str bigarray-compat integers -test-pointers-stub-generator: PROJECT=test-pointers-stub-generator -test-pointers-stub-generator: $$(BEST_TARGET) - -test-pointers.dir = tests/test-pointers -test-pointers.threads = yes -test-pointers.deps = str bigarray-compat oUnit integers -test-pointers.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-pointers-stubs -test-pointers.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-pointers: PROJECT=test-pointers -test-pointers: $$(BEST_TARGET) - -test-pointers-generated= \ - tests/test-pointers/generated_bindings.ml \ - tests/test-pointers/generated_stubs.c - -test-pointers-generated: $(test-pointers-generated) - -tests/test-pointers/generated_stubs.c: $(BUILDDIR)/test-pointers-stub-generator.$(BEST) - $< --c-file $@ -tests/test-pointers/generated_bindings.ml: $(BUILDDIR)/test-pointers-stub-generator.$(BEST) - $< --ml-file $@ - -test-integers-stubs.dir = tests/test-integers/stubs -test-integers-stubs.threads = yes -test-integers-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-integers-stubs: PROJECT=test-integers-stubs -test-integers-stubs: $$(LIB_TARGETS) - -test-integers-stub-generator.dir = tests/test-integers/stub-generator -test-integers-stub-generator.threads = yes -test-integers-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-integers-stubs tests-common -test-integers-stub-generator.deps = str bigarray-compat integers -test-integers-stub-generator: PROJECT=test-integers-stub-generator -test-integers-stub-generator: $$(BEST_TARGET) - -test-integers.dir = tests/test-integers -test-integers.threads = yes -test-integers.deps = str bigarray-compat oUnit integers -test-integers.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-integers-stubs -test-integers.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-integers: PROJECT=test-integers -test-integers: $$(BEST_TARGET) - -test-integers-generated= \ - tests/test-integers/generated_bindings.ml \ - tests/test-integers/generated_stubs.c - -test-integers-generated: $(test-integers-generated) - -tests/test-integers/generated_stubs.c: $(BUILDDIR)/test-integers-stub-generator.$(BEST) - $< --c-file $@ -tests/test-integers/generated_bindings.ml: $(BUILDDIR)/test-integers-stub-generator.$(BEST) - $< --ml-file $@ - -test-variadic-stubs.dir = tests/test-variadic/stubs -test-variadic-stubs.threads = yes -test-variadic-stubs.deps = integers -test-variadic-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-variadic-stubs: PROJECT=test-variadic-stubs -test-variadic-stubs: $$(LIB_TARGETS) - -test-variadic-stub-generator.dir = tests/test-variadic/stub-generator -test-variadic-stub-generator.threads = yes -test-variadic-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-variadic-stubs tests-common -test-variadic-stub-generator.deps = str bigarray-compat integers -test-variadic-stub-generator: PROJECT=test-variadic-stub-generator -test-variadic-stub-generator: $$(BEST_TARGET) - -test-variadic.dir = tests/test-variadic -test-variadic.threads = yes -test-variadic.deps = str bigarray-compat oUnit integers -test-variadic.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-variadic-stubs -test-variadic.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-variadic: PROJECT=test-variadic -test-variadic: $$(BEST_TARGET) - -test-variadic-generated= \ - tests/test-variadic/generated_bindings.ml \ - tests/test-variadic/generated_stubs.c - -test-variadic-generated: $(test-variadic-generated) - -tests/test-variadic/generated_stubs.c: $(BUILDDIR)/test-variadic-stub-generator.$(BEST) - $< --c-file $@ -tests/test-variadic/generated_bindings.ml: $(BUILDDIR)/test-variadic-stub-generator.$(BEST) - $< --ml-file $@ - - -test-builtins-stubs.dir = tests/test-builtins/stubs -test-builtins-stubs.threads = yes -test-builtins-stubs.subproject_deps = ctypes tests-common -test-builtins-stubs: PROJECT=test-builtins-stubs -test-builtins-stubs: $$(LIB_TARGETS) - -test-builtins-stub-generator.dir = tests/test-builtins/stub-generator -test-builtins-stub-generator.threads = yes -test-builtins-stub-generator.subproject_deps = ctypes cstubs \ - test-builtins-stubs ctypes-foreign tests-common -test-builtins-stub-generator.deps = str bigarray-compat integers -test-builtins-stub-generator: PROJECT=test-builtins-stub-generator -test-builtins-stub-generator: $$(BEST_TARGET) - -test-builtins.dir = tests/test-builtins -test-builtins.threads = yes -test-builtins.deps = str bigarray-compat oUnit integers -test-builtins.subproject_deps = ctypes cstubs test-builtins-stubs \ - ctypes-foreign tests-common -test-builtins.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-builtins: PROJECT=test-builtins -test-builtins: $$(BEST_TARGET) - -test-builtins-generated= \ - tests/test-builtins/generated_bindings.ml \ - tests/test-builtins/generated_stubs.c - -test-builtins-generated: $(test-builtins-generated) - -tests/test-builtins/generated_stubs.c: $(BUILDDIR)/test-builtins-stub-generator.$(BEST) - $< --c-file $@ -tests/test-builtins/generated_bindings.ml: $(BUILDDIR)/test-builtins-stub-generator.$(BEST) - $< --ml-file $@ - - -test-macros-stubs.dir = tests/test-macros/stubs -test-macros-stubs.threads = yes -test-macros-stubs.subproject_deps = ctypes tests-common -test-macros-stubs: PROJECT=test-macros-stubs -test-macros-stubs: $$(LIB_TARGETS) - -test-macros-stub-generator.dir = tests/test-macros/stub-generator -test-macros-stub-generator.threads = yes -test-macros-stub-generator.subproject_deps = ctypes cstubs \ - test-macros-stubs ctypes-foreign tests-common -test-macros-stub-generator.deps = str bigarray-compat integers -test-macros-stub-generator: PROJECT=test-macros-stub-generator -test-macros-stub-generator: $$(BEST_TARGET) - -test-macros.dir = tests/test-macros -test-macros.threads = yes -test-macros.deps = str bigarray-compat oUnit integers -test-macros.subproject_deps = ctypes cstubs test-macros-stubs \ - ctypes-foreign tests-common -test-macros.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-macros: PROJECT=test-macros -test-macros: $$(BEST_TARGET) - -test-macros-generated= \ - tests/test-macros/generated_bindings.ml \ - tests/test-macros/generated_stubs.c - -test-macros-generated: $(test-macros-generated) - -tests/test-macros/generated_stubs.c: $(BUILDDIR)/test-macros-stub-generator.$(BEST) - $< --c-file $@ -tests/test-macros/generated_bindings.ml: $(BUILDDIR)/test-macros-stub-generator.$(BEST) - $< --ml-file $@ - - -test-higher_order-stubs.dir = tests/test-higher_order/stubs -test-higher_order-stubs.threads = yes -test-higher_order-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-higher_order-stubs: PROJECT=test-higher_order-stubs -test-higher_order-stubs: $$(LIB_TARGETS) - -test-higher_order-stub-generator.dir = tests/test-higher_order/stub-generator -test-higher_order-stub-generator.threads = yes -test-higher_order-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-higher_order-stubs tests-common -test-higher_order-stub-generator.deps = str bigarray-compat integers -test-higher_order-stub-generator: PROJECT=test-higher_order-stub-generator -test-higher_order-stub-generator: $$(BEST_TARGET) - -test-higher_order.dir = tests/test-higher_order -test-higher_order.threads = yes -test-higher_order.deps = str bigarray-compat oUnit integers -test-higher_order.subproject_deps = ctypes ctypes-foreign \ - cstubs test-higher_order-stubs tests-common -test-higher_order.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-higher_order: PROJECT=test-higher_order -test-higher_order: $$(BEST_TARGET) - -test-higher_order-generated= \ - tests/test-higher_order/generated_bindings.ml \ - tests/test-higher_order/generated_stubs.c - -test-higher_order-generated: $(test-higher_order-generated) - -tests/test-higher_order/generated_stubs.c: $(BUILDDIR)/test-higher_order-stub-generator.$(BEST) - $< --c-file $@ -tests/test-higher_order/generated_bindings.ml: $(BUILDDIR)/test-higher_order-stub-generator.$(BEST) - $< --ml-file $@ - -test-enums-struct-stubs.dir = tests/test-enums/struct-stubs -test-enums-struct-stubs.threads = yes -test-enums-struct-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-enums-struct-stubs: PROJECT=test-enums-struct-stubs -test-enums-struct-stubs: $$(LIB_TARGETS) - -test-enums-stubs.dir = tests/test-enums/stubs -test-enums-stubs.threads = yes -test-enums-stubs.extra_mls = generated_struct_bindings.ml -test-enums-stubs.subproject_deps = ctypes \ - test-enums-struct-stubs \ - test-enums-struct-stubs-generator \ - ctypes-foreign tests-common -test-enums-stubs: PROJECT=test-enums-stubs -test-enums-stubs: $$(LIB_TARGETS) - -test-enums-stub-generator.dir = tests/test-enums/stub-generator -test-enums-stub-generator.threads = yes -test-enums-stub-generator.subproject_deps = ctypes cstubs \ - test-enums-struct-stubs \ - ctypes-foreign test-enums-stubs tests-common -test-enums-stub-generator.deps = str bigarray-compat integers -test-enums-stub-generator: PROJECT=test-enums-stub-generator -test-enums-stub-generator: $$(BEST_TARGET) - -test-enums-struct-stub-generator.dir = tests/test-enums/struct-stub-generator -test-enums-struct-stub-generator.threads = yes -test-enums-struct-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-enums-struct-stubs tests-common -test-enums-struct-stub-generator.deps = str bigarray-compat integers -test-enums-struct-stub-generator: PROJECT=test-enums-struct-stub-generator -test-enums-struct-stub-generator: $$(BEST_TARGET) - -test-enums.dir = tests/test-enums -test-enums.threads = yes -test-enums.deps = str bigarray-compat oUnit integers -test-enums.subproject_deps = ctypes ctypes-foreign \ - cstubs test-enums-struct-stubs test-enums-stubs tests-common -test-enums.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-enums: PROJECT=test-enums -test-enums: $$(BEST_TARGET) - -test-enums-structs-generated= \ - tests/test-enums/stubs/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-enums/generated_struct_stubs.c - -test-enums-structs-generated: $(test-enums-structs-generated) - -test-enums-generated= \ - tests/test-enums/generated_bindings.ml \ - tests/test-enums/generated_stubs.c \ - -test-enums-generated: $(test-enums-generated) - -tests/test-enums/generated_stubs.c: $(BUILDDIR)/test-enums-stub-generator.$(BEST) - $< --c-file $@ -tests/test-enums/generated_bindings.ml: $(BUILDDIR)/test-enums-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-enums/stubs/generated_struct_bindings.ml: $(BUILDDIR)/test-enums-ml-struct-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-enums-ml-struct-stub-generator.$(BEST): $(BUILDDIR)/tests/test-enums/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-enums/generated_struct_stubs.c: $(BUILDDIR)/test-enums-struct-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-structs-stubs.dir = tests/test-structs/stubs -test-structs-stubs.threads = yes -test-structs-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-structs-stubs: PROJECT=test-structs-stubs -test-structs-stubs: $$(LIB_TARGETS) - -test-structs-stub-generator.dir = tests/test-structs/stub-generator -test-structs-stub-generator.threads = yes -test-structs-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-structs-stubs tests-common -test-structs-stub-generator.deps = str bigarray-compat integers -test-structs-stub-generator: PROJECT=test-structs-stub-generator -test-structs-stub-generator: $$(BEST_TARGET) - -test-structs.dir = tests/test-structs -test-structs.threads = yes -test-structs.deps = str bigarray-compat oUnit integers -test-structs.subproject_deps = ctypes ctypes-foreign \ - cstubs test-structs-stubs tests-common -test-structs.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-structs: PROJECT=test-structs -test-structs: $$(BEST_TARGET) - -test-structs-generated= \ - tests/test-structs/generated_bindings.ml \ - tests/test-structs/generated_stubs.c \ - tests/test-structs/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-structs/generated_struct_stubs.c - -test-structs-generated: $(test-structs-generated) - -tests/test-structs/generated_stubs.c: $(BUILDDIR)/test-structs-stub-generator.$(BEST) - $< --c-file $@ -tests/test-structs/generated_bindings.ml: $(BUILDDIR)/test-structs-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-structs/generated_struct_bindings.ml: $(BUILDDIR)/test-structs-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-structs-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-structs/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-structs/generated_struct_stubs.c: $(BUILDDIR)/test-structs-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-constants-stubs.dir = tests/test-constants/stubs -test-constants-stubs.threads = yes -test-constants-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-constants-stubs: PROJECT=test-constants-stubs -test-constants-stubs: $$(LIB_TARGETS) - -test-constants-stub-generator.dir = tests/test-constants/stub-generator -test-constants-stub-generator.threads = yes -test-constants-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-constants-stubs tests-common -test-constants-stub-generator.deps = str bigarray-compat integers -test-constants-stub-generator: PROJECT=test-constants-stub-generator -test-constants-stub-generator: $$(BEST_TARGET) - -test-constants.dir = tests/test-constants -test-constants.threads = yes -test-constants.deps = str bigarray-compat oUnit integers -test-constants.subproject_deps = ctypes ctypes-foreign \ - cstubs test-constants-stubs tests-common -test-constants.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-constants: PROJECT=test-constants -test-constants: $$(BEST_TARGET) - -test-constants-generated= \ - tests/test-constants/generated_bindings.ml \ - tests/test-constants/generated_stubs.c \ - tests/test-constants/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-constants/generated_struct_stubs.c - -test-constants-generated: $(test-constants-generated) - -tests/test-constants/generated_stubs.c: $(BUILDDIR)/test-constants-stub-generator.$(BEST) - $< --c-file $@ -tests/test-constants/generated_bindings.ml: $(BUILDDIR)/test-constants-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-constants/generated_struct_bindings.ml: $(BUILDDIR)/test-constants-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-constants-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-constants/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-constants/generated_struct_stubs.c: $(BUILDDIR)/test-constants-stub-generator.$(BEST) - $< --c-struct-file $@ - - -test-finalisers.dir = tests/test-finalisers -test-finalisers.threads = yes -test-finalisers.deps = str bigarray-compat oUnit integers -test-finalisers.subproject_deps = ctypes ctypes-foreign -test-finalisers: PROJECT=test-finalisers -test-finalisers: $$(BEST_TARGET) - -test-cstdlib-stubs.dir = tests/test-cstdlib/stubs -test-cstdlib-stubs.threads = yes -test-cstdlib-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-cstdlib-stubs: PROJECT=test-cstdlib-stubs -test-cstdlib-stubs: $$(LIB_TARGETS) - -test-cstdlib-stub-generator.dir = tests/test-cstdlib/stub-generator -test-cstdlib-stub-generator.threads = yes -test-cstdlib-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-cstdlib-stubs tests-common -test-cstdlib-stub-generator.deps = str bigarray-compat integers -test-cstdlib-stub-generator: PROJECT=test-cstdlib-stub-generator -test-cstdlib-stub-generator: $$(BEST_TARGET) - -test-cstdlib.dir = tests/test-cstdlib -test-cstdlib.threads = yes -test-cstdlib.deps = str bigarray-compat oUnit integers -test-cstdlib.subproject_deps = ctypes ctypes-foreign \ - cstubs test-cstdlib-stubs tests-common -test-cstdlib.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-cstdlib: PROJECT=test-cstdlib -test-cstdlib: $$(BEST_TARGET) - -test-cstdlib-generated= \ - tests/test-cstdlib/generated_bindings.ml \ - tests/test-cstdlib/generated_stubs.c - -test-cstdlib-generated: $(test-cstdlib-generated) - -tests/test-cstdlib/generated_stubs.c: $(BUILDDIR)/test-cstdlib-stub-generator.$(BEST) - $< --c-file $@ -tests/test-cstdlib/generated_bindings.ml: $(BUILDDIR)/test-cstdlib-stub-generator.$(BEST) - $< --ml-file $@ - -test-sizeof.dir = tests/test-sizeof -test-sizeof.threads = yes -test-sizeof.deps = str bigarray-compat oUnit integers -test-sizeof.subproject_deps = ctypes ctypes-foreign -test-sizeof: PROJECT=test-sizeof -test-sizeof: $$(BEST_TARGET) - -test-foreign_values-stubs.dir = tests/test-foreign_values/stubs -test-foreign_values-stubs.threads = yes -test-foreign_values-stubs.deps = bigarray-compat -test-foreign_values-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-foreign_values-stubs: PROJECT=test-foreign_values-stubs -test-foreign_values-stubs: $$(LIB_TARGETS) - -test-foreign_values-stub-generator.dir = tests/test-foreign_values/stub-generator -test-foreign_values-stub-generator.threads = yes -test-foreign_values-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-foreign_values-stubs tests-common -test-foreign_values-stub-generator.deps = str bigarray-compat integers -test-foreign_values-stub-generator: PROJECT=test-foreign_values-stub-generator -test-foreign_values-stub-generator: $$(BEST_TARGET) - -test-foreign_values.dir = tests/test-foreign_values -test-foreign_values.threads = yes -test-foreign_values.deps = str bigarray-compat oUnit integers -test-foreign_values.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-foreign_values-stubs -test-foreign_values.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-foreign_values: PROJECT=test-foreign_values -test-foreign_values: $$(BEST_TARGET) - -test-foreign_values-generated= \ - tests/test-foreign_values/generated_bindings.ml \ - tests/test-foreign_values/generated_stubs.c - -test-foreign_values-generated: $(test-foreign_values-generated) - -tests/test-foreign_values/generated_stubs.c: $(BUILDDIR)/test-foreign_values-stub-generator.$(BEST) - $< --c-file $@ -tests/test-foreign_values/generated_bindings.ml: $(BUILDDIR)/test-foreign_values-stub-generator.$(BEST) - $< --ml-file $@ - -test-unions-stubs.dir = tests/test-unions/stubs -test-unions-stubs.threads = yes -test-unions-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-unions-stubs: PROJECT=test-unions-stubs -test-unions-stubs: $$(LIB_TARGETS) - -test-unions-stub-generator.dir = tests/test-unions/stub-generator -test-unions-stub-generator.threads = yes -test-unions-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-unions-stubs tests-common -test-unions-stub-generator.deps = str bigarray-compat integers -test-unions-stub-generator: PROJECT=test-unions-stub-generator -test-unions-stub-generator: $$(BEST_TARGET) - -test-unions.dir = tests/test-unions -test-unions.threads = yes -test-unions.deps = str bigarray-compat oUnit integers -test-unions.subproject_deps = ctypes ctypes-foreign \ - cstubs test-unions-stubs tests-common -test-unions.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-unions: PROJECT=test-unions -test-unions: $$(BEST_TARGET) - -test-unions-generated= \ - tests/test-unions/generated_bindings.ml \ - tests/test-unions/generated_stubs.c \ - tests/test-unions/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-unions/generated_struct_stubs.c - -test-unions-generated: $(test-unions-generated) - -tests/test-unions/generated_stubs.c: $(BUILDDIR)/test-unions-stub-generator.$(BEST) - $< --c-file $@ -tests/test-unions/generated_bindings.ml: $(BUILDDIR)/test-unions-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-unions/generated_struct_bindings.ml: $(BUILDDIR)/test-unions-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-unions-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-unions/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-unions/generated_struct_stubs.c: $(BUILDDIR)/test-unions-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-custom_ops.dir = tests/test-custom_ops -test-custom_ops.threads = yes -test-custom_ops.deps = str bigarray-compat oUnit integers -test-custom_ops.subproject_deps = ctypes ctypes-foreign -test-custom_ops: PROJECT=test-custom_ops -test-custom_ops: $$(BEST_TARGET) - -test-arrays-stubs.dir = tests/test-arrays/stubs -test-arrays-stubs.threads = yes -test-arrays-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-arrays-stubs: PROJECT=test-arrays-stubs -test-arrays-stubs: $$(LIB_TARGETS) - -test-arrays-stub-generator.dir = tests/test-arrays/stub-generator -test-arrays-stub-generator.threads = yes -test-arrays-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-arrays-stubs tests-common -test-arrays-stub-generator.deps = str bigarray-compat integers -test-arrays-stub-generator: PROJECT=test-arrays-stub-generator -test-arrays-stub-generator: $$(BEST_TARGET) - -test-arrays.dir = tests/test-arrays -test-arrays.threads = yes -test-arrays.deps = str bigarray-compat oUnit integers -test-arrays.subproject_deps = ctypes ctypes-foreign \ - cstubs test-arrays-stubs tests-common -test-arrays.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-arrays: PROJECT=test-arrays -test-arrays: $$(BEST_TARGET) - -test-arrays-generated= \ - tests/test-arrays/generated_bindings.ml \ - tests/test-arrays/generated_stubs.c - -test-arrays-generated: $(test-arrays-generated) - -tests/test-arrays/generated_stubs.c: $(BUILDDIR)/test-arrays-stub-generator.$(BEST) - $< --c-file $@ -tests/test-arrays/generated_bindings.ml: $(BUILDDIR)/test-arrays-stub-generator.$(BEST) - $< --ml-file $@ - -test-foreign-errno.dir = tests/test-foreign-errno -test-foreign-errno.threads = yes -test-foreign-errno.deps = str bigarray-compat oUnit integers -test-foreign-errno.subproject_deps = ctypes ctypes-foreign -test-foreign-errno: PROJECT=test-foreign-errno -test-foreign-errno: $$(BEST_TARGET) - -test-passable.dir = tests/test-passable -test-passable.threads = yes -test-passable.deps = str bigarray-compat oUnit integers -test-passable.subproject_deps = ctypes ctypes-foreign cstubs -test-passable: PROJECT=test-passable -test-passable: $$(BEST_TARGET) - -test-alignment.dir = tests/test-alignment -test-alignment.threads = yes -test-alignment.deps = str bigarray-compat oUnit integers -test-alignment.subproject_deps = ctypes ctypes-foreign -test-alignment: PROJECT=test-alignment -test-alignment: $$(BEST_TARGET) - -test-views-stubs.dir = tests/test-views/stubs -test-views-stubs.threads = yes -test-views-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-views-stubs: PROJECT=test-views-stubs -test-views-stubs: $$(LIB_TARGETS) - -test-views-stub-generator.dir = tests/test-views/stub-generator -test-views-stub-generator.threads = yes -test-views-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-views-stubs tests-common -test-views-stub-generator.deps = str bigarray-compat integers -test-views-stub-generator: PROJECT=test-views-stub-generator -test-views-stub-generator: $$(BEST_TARGET) - -test-views.dir = tests/test-views -test-views.threads = yes -test-views.deps = str bigarray-compat oUnit integers -test-views.subproject_deps = ctypes ctypes-foreign cstubs test-views-stubs tests-common -test-views.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-views: PROJECT=test-views -test-views: $$(BEST_TARGET) - -test-views-generated= \ - tests/test-views/generated_bindings.ml \ - tests/test-views/generated_stubs.c - -test-views-generated: $(test-views-generated) - -tests/test-views/generated_stubs.c: $(BUILDDIR)/test-views-stub-generator.$(BEST) - $< --c-file $@ -tests/test-views/generated_bindings.ml: $(BUILDDIR)/test-views-stub-generator.$(BEST) - $< --ml-file $@ - -test-oo_style-stubs.dir = tests/test-oo_style/stubs -test-oo_style-stubs.threads = yes -test-oo_style-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-oo_style-stubs: PROJECT=test-oo_style-stubs -test-oo_style-stubs: $$(LIB_TARGETS) - -test-oo_style-stub-generator.dir = tests/test-oo_style/stub-generator -test-oo_style-stub-generator.threads = yes -test-oo_style-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-oo_style-stubs tests-common -test-oo_style-stub-generator.deps = str bigarray-compat integers -test-oo_style-stub-generator: PROJECT=test-oo_style-stub-generator -test-oo_style-stub-generator: $$(BEST_TARGET) - -test-oo_style.dir = tests/test-oo_style -test-oo_style.threads = yes -test-oo_style.deps = str bigarray-compat oUnit integers -test-oo_style.subproject_deps = ctypes ctypes-foreign \ - cstubs test-oo_style-stubs tests-common -test-oo_style.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-oo_style: PROJECT=test-oo_style -test-oo_style: $$(BEST_TARGET) - -test-oo_style-generated= \ - tests/test-oo_style/generated_bindings.ml \ - tests/test-oo_style/generated_stubs.c - -test-oo_style-generated: $(test-oo_style-generated) - -tests/test-oo_style/generated_stubs.c: $(BUILDDIR)/test-oo_style-stub-generator.$(BEST) - $< --c-file $@ -tests/test-oo_style/generated_bindings.ml: $(BUILDDIR)/test-oo_style-stub-generator.$(BEST) - $< --ml-file $@ - -test-marshal.dir = tests/test-marshal -test-marshal.threads = yes -test-marshal.deps = str bigarray-compat oUnit integers -test-marshal.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common -test-marshal.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-marshal: PROJECT=test-marshal -test-marshal: $$(BEST_TARGET) - -test-type_printing.dir = tests/test-type_printing -test-type_printing.threads = yes -test-type_printing.deps = str bigarray-compat oUnit integers -test-type_printing.subproject_deps = ctypes ctypes-foreign \ - cstubs test-type_printing-stubs tests-common -test-type_printing.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-type_printing: PROJECT=test-type_printing -test-type_printing: $$(BEST_TARGET) - -test-type_printing-stubs.dir = tests/test-type_printing/stubs -test-type_printing-stubs.threads = yes -test-type_printing-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-type_printing-stubs: PROJECT=test-type_printing-stubs -test-type_printing-stubs: $$(LIB_TARGETS) - -test-type_printing-stub-generator.dir = tests/test-type_printing/stub-generator -test-type_printing-stub-generator.threads = yes -test-type_printing-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-type_printing-stubs tests-common -test-type_printing-stub-generator.deps = str bigarray-compat integers -test-type_printing-stub-generator: PROJECT=test-type_printing-stub-generator -test-type_printing-stub-generator: $$(BEST_TARGET) - -test-type_printing-generated= \ - tests/test-type_printing/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-type_printing/generated_struct_stubs.c - -test-type_printing-generated: $(test-type_printing-generated) - -tests/test-type_printing/generated_struct_bindings.ml: $(BUILDDIR)/test-type_printing-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-type_printing-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-type_printing/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-type_printing/generated_struct_stubs.c: $(BUILDDIR)/test-type_printing-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-value_printing-stubs.dir = tests/test-value_printing/stubs -test-value_printing-stubs.threads = yes -test-value_printing-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-value_printing-stubs: PROJECT=test-value_printing-stubs -test-value_printing-stubs: $$(LIB_TARGETS) - -test-value_printing-stub-generator.dir = tests/test-value_printing/stub-generator -test-value_printing-stub-generator.threads = yes -test-value_printing-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-value_printing-stubs tests-common -test-value_printing-stub-generator.deps = str bigarray-compat integers -test-value_printing-stub-generator: PROJECT=test-value_printing-stub-generator -test-value_printing-stub-generator: $$(BEST_TARGET) - -test-value_printing.dir = tests/test-value_printing -test-value_printing.threads = yes -test-value_printing.deps = str bigarray-compat oUnit integers -test-value_printing.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-value_printing-stubs -test-value_printing.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-value_printing: PROJECT=test-value_printing -test-value_printing: $$(BEST_TARGET) - -test-value_printing-generated= \ - tests/test-value_printing/generated_bindings.ml \ - tests/test-value_printing/generated_stubs.c - -test-value_printing-generated: $(test-value_printing-generated) - -tests/test-value_printing/generated_stubs.c: $(BUILDDIR)/test-value_printing-stub-generator.$(BEST) - $< --c-file $@ -tests/test-value_printing/generated_bindings.ml: $(BUILDDIR)/test-value_printing-stub-generator.$(BEST) - $< --ml-file $@ - -test-complex-stubs.dir = tests/test-complex/stubs -test-complex-stubs.threads = yes -test-complex-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-complex-stubs: PROJECT=test-complex-stubs -test-complex-stubs: $$(LIB_TARGETS) - -test-complex-stub-generator.dir = tests/test-complex/stub-generator -test-complex-stub-generator.threads = yes -test-complex-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-complex-stubs tests-common -test-complex-stub-generator.deps = str bigarray-compat integers -test-complex-stub-generator: PROJECT=test-complex-stub-generator -test-complex-stub-generator: $$(BEST_TARGET) - -test-complex.dir = tests/test-complex -test-complex.threads = yes -test-complex.deps = str bigarray-compat oUnit integers -test-complex.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-complex-stubs -test-complex.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-complex: PROJECT=test-complex -test-complex: $$(BEST_TARGET) - -test-complex-generated= \ - tests/test-complex/generated_bindings.ml \ - tests/test-complex/generated_stubs.c - -test-complex-generated: $(test-complex-generated) - -tests/test-complex/generated_stubs.c: $(BUILDDIR)/test-complex-stub-generator.$(BEST) - $< --c-file $@ -tests/test-complex/generated_bindings.ml: $(BUILDDIR)/test-complex-stub-generator.$(BEST) - $< --ml-file $@ - -test-bools-stubs.dir = tests/test-bools/stubs -test-bools-stubs.threads = yes -test-bools-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-bools-stubs: PROJECT=test-bools-stubs -test-bools-stubs: $$(LIB_TARGETS) - -test-bools-stub-generator.dir = tests/test-bools/stub-generator -test-bools-stub-generator.threads = yes -test-bools-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-bools-stubs tests-common -test-bools-stub-generator.deps = str bigarray-compat integers -test-bools-stub-generator: PROJECT=test-bools-stub-generator -test-bools-stub-generator: $$(BEST_TARGET) - -test-bools.dir = tests/test-bools -test-bools.threads = yes -test-bools.deps = str bigarray-compat oUnit integers -test-bools.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-bools-stubs -test-bools.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-bools: PROJECT=test-bools -test-bools: $$(BEST_TARGET) - -test-bools-generated= \ - tests/test-bools/generated_bindings.ml \ - tests/test-bools/generated_stubs.c - -test-bools-generated: $(test-bools-generated) - -tests/test-bools/generated_stubs.c: $(BUILDDIR)/test-bools-stub-generator.$(BEST) - $< --c-file $@ -tests/test-bools/generated_bindings.ml: $(BUILDDIR)/test-bools-stub-generator.$(BEST) - $< --ml-file $@ - -test-callback_lifetime-stubs.dir = tests/test-callback_lifetime/stubs -test-callback_lifetime-stubs.threads = yes -test-callback_lifetime-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-callback_lifetime-stubs: PROJECT=test-callback_lifetime-stubs -test-callback_lifetime-stubs: $$(LIB_TARGETS) - -test-callback_lifetime-stub-generator.dir = tests/test-callback_lifetime/stub-generator -test-callback_lifetime-stub-generator.threads = yes -test-callback_lifetime-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-callback_lifetime-stubs tests-common -test-callback_lifetime-stub-generator.deps = str bigarray-compat integers -test-callback_lifetime-stub-generator: PROJECT=test-callback_lifetime-stub-generator -test-callback_lifetime-stub-generator: $$(BEST_TARGET) - -test-callback_lifetime.dir = tests/test-callback_lifetime -test-callback_lifetime.threads = yes -test-callback_lifetime.deps = str bigarray-compat oUnit integers -test-callback_lifetime.subproject_deps = ctypes ctypes-foreign \ - cstubs test-callback_lifetime-stubs tests-common -test-callback_lifetime.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-callback_lifetime: PROJECT=test-callback_lifetime -test-callback_lifetime: $$(BEST_TARGET) - -test-callback_lifetime-generated= \ - tests/test-callback_lifetime/generated_bindings.ml \ - tests/test-callback_lifetime/generated_stubs.c - -test-callback_lifetime-generated: $(test-callback_lifetime-generated) - -tests/test-callback_lifetime/generated_stubs.c: $(BUILDDIR)/test-callback_lifetime-stub-generator.$(BEST) - $< --c-file $@ -tests/test-callback_lifetime/generated_bindings.ml: $(BUILDDIR)/test-callback_lifetime-stub-generator.$(BEST) - $< --ml-file $@ - -test-lifetime-stubs.dir = tests/test-lifetime/stubs -test-lifetime-stubs.threads = yes -test-lifetime-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-lifetime-stubs: PROJECT=test-lifetime-stubs -test-lifetime-stubs: $$(LIB_TARGETS) - -test-lifetime-stub-generator.dir = tests/test-lifetime/stub-generator -test-lifetime-stub-generator.threads = yes -test-lifetime-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-lifetime-stubs tests-common -test-lifetime-stub-generator.deps = str bigarray-compat integers -test-lifetime-stub-generator: PROJECT=test-lifetime-stub-generator -test-lifetime-stub-generator: $$(BEST_TARGET) - -test-lifetime.dir = tests/test-lifetime -test-lifetime.threads = yes -test-lifetime.deps = str bigarray-compat oUnit integers -test-lifetime.subproject_deps = ctypes ctypes-foreign \ - cstubs test-lifetime-stubs tests-common -test-lifetime.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-lifetime: PROJECT=test-lifetime -test-lifetime: $$(BEST_TARGET) - -test-lifetime-generated= \ - tests/test-lifetime/generated_bindings.ml \ - tests/test-lifetime/generated_stubs.c - -test-lifetime-generated: $(test-lifetime-generated) - -tests/test-lifetime/generated_stubs.c: $(BUILDDIR)/test-lifetime-stub-generator.$(BEST) - $< --c-file $@ -tests/test-lifetime/generated_bindings.ml: $(BUILDDIR)/test-lifetime-stub-generator.$(BEST) - $< --ml-file $@ - -test-stubs.dir = tests/test-stubs -test-stubs.threads = yes -test-stubs.deps = str bigarray-compat oUnit integers -test-stubs.subproject_deps = ctypes ctypes-foreign -test-stubs: PROJECT=test-stubs -test-stubs: $$(BEST_TARGET) - -test-bigarrays-stubs.dir = tests/test-bigarrays/stubs -test-bigarrays-stubs.threads = yes -test-bigarrays-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-bigarrays-stubs: PROJECT=test-bigarrays-stubs -test-bigarrays-stubs: $$(LIB_TARGETS) - -test-bigarrays-stub-generator.dir = tests/test-bigarrays/stub-generator -test-bigarrays-stub-generator.threads = yes -test-bigarrays-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-bigarrays-stubs tests-common -test-bigarrays-stub-generator.deps = str bigarray-compat integers -test-bigarrays-stub-generator: PROJECT=test-bigarrays-stub-generator -test-bigarrays-stub-generator: $$(BEST_TARGET) - -test-bigarrays.dir = tests/test-bigarrays -test-bigarrays.threads = yes -test-bigarrays.deps = str bigarray-compat oUnit integers -test-bigarrays.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-bigarrays-stubs -test-bigarrays.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-bigarrays: PROJECT=test-bigarrays -test-bigarrays: $$(BEST_TARGET) - -test-bigarrays-generated= \ - tests/test-bigarrays/generated_bindings.ml \ - tests/test-bigarrays/generated_stubs.c - -test-bigarrays-generated: $(test-bigarrays-generated) - -tests/test-bigarrays/generated_stubs.c: $(BUILDDIR)/test-bigarrays-stub-generator.$(BEST) - $< --c-file $@ -tests/test-bigarrays/generated_bindings.ml: $(BUILDDIR)/test-bigarrays-stub-generator.$(BEST) - $< --ml-file $@ - -test-coercions-stubs.dir = tests/test-coercions/stubs -test-coercions-stubs.threads = yes -test-coercions-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-coercions-stubs: PROJECT=test-coercions-stubs -test-coercions-stubs: $$(LIB_TARGETS) - -test-coercions-stub-generator.dir = tests/test-coercions/stub-generator -test-coercions-stub-generator.threads = yes -test-coercions-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-coercions-stubs tests-common -test-coercions-stub-generator.deps = str bigarray-compat integers -test-coercions-stub-generator: PROJECT=test-coercions-stub-generator -test-coercions-stub-generator: $$(BEST_TARGET) - -test-coercions.dir = tests/test-coercions -test-coercions.threads = yes -test-coercions.deps = str bigarray-compat oUnit integers -test-coercions.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-coercions-stubs -test-coercions.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-coercions: PROJECT=test-coercions -test-coercions: $$(BEST_TARGET) - -test-coercions-generated= \ - tests/test-coercions/generated_bindings.ml \ - tests/test-coercions/generated_stubs.c - -test-coercions-generated: $(test-coercions-generated) - -tests/test-coercions/generated_stubs.c: $(BUILDDIR)/test-coercions-stub-generator.$(BEST) - $< --c-file $@ -tests/test-coercions/generated_bindings.ml: $(BUILDDIR)/test-coercions-stub-generator.$(BEST) - $< --ml-file $@ - -test-roots.dir = tests/test-roots -test-roots.threads = yes -test-roots.deps = str bigarray-compat oUnit integers -test-roots.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common -test-roots.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-roots: PROJECT=test-roots -test-roots: $$(BEST_TARGET) - -test-passing-ocaml-values-stubs.dir = tests/test-passing-ocaml-values/stubs -test-passing-ocaml-values-stubs.threads = yes -test-passing-ocaml-values-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-passing-ocaml-values-stubs: PROJECT=test-passing-ocaml-values-stubs -test-passing-ocaml-values-stubs: $$(LIB_TARGETS) - -test-passing-ocaml-values-stub-generator.dir = tests/test-passing-ocaml-values/stub-generator -test-passing-ocaml-values-stub-generator.threads = yes -test-passing-ocaml-values-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-passing-ocaml-values-stubs tests-common -test-passing-ocaml-values-stub-generator.deps = str bigarray-compat integers -test-passing-ocaml-values-stub-generator: PROJECT=test-passing-ocaml-values-stub-generator -test-passing-ocaml-values-stub-generator: $$(BEST_TARGET) - -test-passing-ocaml-values.dir = tests/test-passing-ocaml-values -test-passing-ocaml-values.threads = yes -test-passing-ocaml-values.deps = str bigarray-compat oUnit integers -test-passing-ocaml-values.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-passing-ocaml-values-stubs -test-passing-ocaml-values.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-passing-ocaml-values: PROJECT=test-passing-ocaml-values -test-passing-ocaml-values: $$(BEST_TARGET) - -test-passing-ocaml-values-generated= \ - tests/test-passing-ocaml-values/generated_bindings.ml \ - tests/test-passing-ocaml-values/generated_stubs.c - -test-passing-ocaml-values-generated: $(test-passing-ocaml-values-generated) - -tests/test-passing-ocaml-values/generated_stubs.c: $(BUILDDIR)/test-passing-ocaml-values-stub-generator.$(BEST) - $< --c-file $@ -tests/test-passing-ocaml-values/generated_bindings.ml: $(BUILDDIR)/test-passing-ocaml-values-stub-generator.$(BEST) - $< --ml-file $@ - -test-funptrs-stubs.dir = tests/test-funptrs/stubs -test-funptrs-stubs.threads = yes -test-funptrs-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-funptrs-stubs: PROJECT=test-funptrs-stubs -test-funptrs-stubs: $$(LIB_TARGETS) - -test-funptrs-stub-generator.dir = tests/test-funptrs/stub-generator -test-funptrs-stub-generator.threads = yes -test-funptrs-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-funptrs-stubs tests-common -test-funptrs-stub-generator.deps = str bigarray-compat integers -test-funptrs-stub-generator: PROJECT=test-funptrs-stub-generator -test-funptrs-stub-generator: $$(BEST_TARGET) - -test-funptrs.dir = tests/test-funptrs -test-funptrs.threads = yes -test-funptrs.deps = str bigarray-compat oUnit integers -test-funptrs.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-funptrs-stubs -test-funptrs.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-funptrs: PROJECT=test-funptrs -test-funptrs: $$(BEST_TARGET) - -test-funptrs-generated= \ - tests/test-funptrs/generated_bindings.ml \ - tests/test-funptrs/generated_stubs.c - -test-funptrs-generated: $(test-funptrs-generated) - -tests/test-funptrs/generated_stubs.c: $(BUILDDIR)/test-funptrs-stub-generator.$(BEST) - $< --c-file $@ -tests/test-funptrs/generated_bindings.ml: $(BUILDDIR)/test-funptrs-stub-generator.$(BEST) - $< --ml-file $@ - -test-lwt-jobs-stubs.dir = tests/test-lwt-jobs/stubs -test-lwt-jobs-stubs.threads = yes -test-lwt-jobs-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-lwt-jobs-stubs: PROJECT=test-lwt-jobs-stubs -test-lwt-jobs-stubs: $$(LIB_TARGETS) - -test-lwt-jobs-stub-generator.dir = tests/test-lwt-jobs/stub-generator -test-lwt-jobs-stub-generator.threads = yes -test-lwt-jobs-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-lwt-jobs-stubs tests-common -test-lwt-jobs-stub-generator.deps = str bigarray-compat integers -test-lwt-jobs-stub-generator: PROJECT=test-lwt-jobs-stub-generator -test-lwt-jobs-stub-generator: $$(BEST_TARGET) - -test-lwt-jobs.dir = tests/test-lwt-jobs -test-lwt-jobs.threads = yes -test-lwt-jobs.deps = str bigarray-compat oUnit integers lwt.unix -test-lwt-jobs.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-lwt-jobs-stubs -test-lwt-jobs.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-lwt-jobs: PROJECT=test-lwt-jobs -test-lwt-jobs: $$(BEST_TARGET) - -test-lwt-jobs-generated= \ - tests/test-lwt-jobs/generated_bindings.ml \ - tests/test-lwt-jobs/generated_stubs.c \ - tests/test-lwt-jobs/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-lwt-jobs/generated_struct_stubs.c - -test-lwt-jobs-generated: $(test-lwt-jobs-generated) - -tests/test-lwt-jobs/generated_stubs.c: $(BUILDDIR)/test-lwt-jobs-stub-generator.$(BEST) - $< --c-file $@ -tests/test-lwt-jobs/generated_bindings.ml: $(BUILDDIR)/test-lwt-jobs-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-lwt-jobs/generated_struct_bindings.ml: $(BUILDDIR)/test-lwt-jobs-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-lwt-jobs-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-lwt-jobs/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-lwt-jobs/generated_struct_stubs.c: $(BUILDDIR)/test-lwt-jobs-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-lwt-preemptive-stubs.dir = tests/test-lwt-preemptive/stubs -test-lwt-preemptive-stubs.threads = yes -test-lwt-preemptive-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-lwt-preemptive-stubs: PROJECT=test-lwt-preemptive-stubs -test-lwt-preemptive-stubs: $$(LIB_TARGETS) - -test-lwt-preemptive-stub-generator.dir = tests/test-lwt-preemptive/stub-generator -test-lwt-preemptive-stub-generator.threads = yes -test-lwt-preemptive-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-lwt-preemptive-stubs tests-common -test-lwt-preemptive-stub-generator.deps = str bigarray-compat integers -test-lwt-preemptive-stub-generator: PROJECT=test-lwt-preemptive-stub-generator -test-lwt-preemptive-stub-generator: $$(BEST_TARGET) - -test-lwt-preemptive.dir = tests/test-lwt-preemptive -test-lwt-preemptive.threads = yes -test-lwt-preemptive.deps = str bigarray-compat oUnit integers lwt.unix -test-lwt-preemptive.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-lwt-preemptive-stubs -test-lwt-preemptive.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-lwt-preemptive: PROJECT=test-lwt-preemptive -test-lwt-preemptive: $$(BEST_TARGET) - -test-lwt-preemptive-generated= \ - tests/test-lwt-preemptive/generated_bindings.ml \ - tests/test-lwt-preemptive/generated_stubs.c \ - tests/test-lwt-preemptive/generated_struct_bindings.ml \ - $(BUILDDIR)/tests/test-lwt-preemptive/generated_struct_stubs.c - -test-lwt-preemptive-generated: $(test-lwt-preemptive-generated) - -tests/test-lwt-preemptive/generated_stubs.c: $(BUILDDIR)/test-lwt-preemptive-stub-generator.$(BEST) - $< --c-file $@ -tests/test-lwt-preemptive/generated_bindings.ml: $(BUILDDIR)/test-lwt-preemptive-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-lwt-preemptive/generated_struct_bindings.ml: $(BUILDDIR)/test-lwt-preemptive-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-lwt-preemptive-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-lwt-preemptive/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-lwt-preemptive/generated_struct_stubs.c: $(BUILDDIR)/test-lwt-preemptive-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-returning-errno-lwt-jobs-stubs.dir = tests/test-returning-errno-lwt-jobs/stubs -test-returning-errno-lwt-jobs-stubs.threads = yes -test-returning-errno-lwt-jobs-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-returning-errno-lwt-jobs-stubs: PROJECT=test-returning-errno-lwt-jobs-stubs -test-returning-errno-lwt-jobs-stubs: $$(LIB_TARGETS) - -test-returning-errno-lwt-jobs-stub-generator.dir = tests/test-returning-errno-lwt-jobs/stub-generator -test-returning-errno-lwt-jobs-stub-generator.threads = yes -test-returning-errno-lwt-jobs-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-returning-errno-lwt-jobs-stubs tests-common -test-returning-errno-lwt-jobs-stub-generator.deps = str bigarray-compat integers -test-returning-errno-lwt-jobs-stub-generator: PROJECT=test-returning-errno-lwt-jobs-stub-generator -test-returning-errno-lwt-jobs-stub-generator: $$(BEST_TARGET) - -test-returning-errno-lwt-jobs.dir = tests/test-returning-errno-lwt-jobs -test-returning-errno-lwt-jobs.threads = yes -test-returning-errno-lwt-jobs.deps = str bigarray-compat oUnit integers lwt.unix -test-returning-errno-lwt-jobs.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-returning-errno-lwt-jobs-stubs -test-returning-errno-lwt-jobs.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-returning-errno-lwt-jobs: PROJECT=test-returning-errno-lwt-jobs -test-returning-errno-lwt-jobs: $$(BEST_TARGET) - -test-returning-errno-lwt-jobs-generated= \ - tests/test-returning-errno-lwt-jobs/generated_bindings.ml \ - tests/test-returning-errno-lwt-jobs/generated_struct_bindings.ml \ - tests/test-returning-errno-lwt-jobs/generated_stubs.c - -test-returning-errno-lwt-jobs-generated: $(test-returning-errno-lwt-jobs-generated) - -tests/test-returning-errno-lwt-jobs/generated_stubs.c: $(BUILDDIR)/test-returning-errno-lwt-jobs-stub-generator.$(BEST) - $< --c-file $@ -tests/test-returning-errno-lwt-jobs/generated_bindings.ml: $(BUILDDIR)/test-returning-errno-lwt-jobs-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-returning-errno-lwt-jobs/generated_struct_bindings.ml: $(BUILDDIR)/test-returning-errno-lwt-jobs-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-returning-errno-lwt-jobs-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-returning-errno-lwt-jobs/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-returning-errno-lwt-jobs/generated_struct_stubs.c: $(BUILDDIR)/test-returning-errno-lwt-jobs-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-returning-errno-lwt-preemptive-stubs.dir = tests/test-returning-errno-lwt-preemptive/stubs -test-returning-errno-lwt-preemptive-stubs.threads = yes -test-returning-errno-lwt-preemptive-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-returning-errno-lwt-preemptive-stubs: PROJECT=test-returning-errno-lwt-preemptive-stubs -test-returning-errno-lwt-preemptive-stubs: $$(LIB_TARGETS) - -test-returning-errno-lwt-preemptive-stub-generator.dir = tests/test-returning-errno-lwt-preemptive/stub-generator -test-returning-errno-lwt-preemptive-stub-generator.threads = yes -test-returning-errno-lwt-preemptive-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-returning-errno-lwt-preemptive-stubs tests-common -test-returning-errno-lwt-preemptive-stub-generator.deps = str bigarray-compat integers -test-returning-errno-lwt-preemptive-stub-generator: PROJECT=test-returning-errno-lwt-preemptive-stub-generator -test-returning-errno-lwt-preemptive-stub-generator: $$(BEST_TARGET) - -test-returning-errno-lwt-preemptive.dir = tests/test-returning-errno-lwt-preemptive -test-returning-errno-lwt-preemptive.threads = yes -test-returning-errno-lwt-preemptive.deps = str bigarray-compat oUnit integers lwt.unix -test-returning-errno-lwt-preemptive.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-returning-errno-lwt-preemptive-stubs -test-returning-errno-lwt-preemptive.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-returning-errno-lwt-preemptive: PROJECT=test-returning-errno-lwt-preemptive -test-returning-errno-lwt-preemptive: $$(BEST_TARGET) - -test-returning-errno-lwt-preemptive-generated= \ - tests/test-returning-errno-lwt-preemptive/generated_bindings.ml \ - tests/test-returning-errno-lwt-preemptive/generated_struct_bindings.ml \ - tests/test-returning-errno-lwt-preemptive/generated_stubs.c - -test-returning-errno-lwt-preemptive-generated: $(test-returning-errno-lwt-preemptive-generated) - -tests/test-returning-errno-lwt-preemptive/generated_stubs.c: $(BUILDDIR)/test-returning-errno-lwt-preemptive-stub-generator.$(BEST) - $< --c-file $@ -tests/test-returning-errno-lwt-preemptive/generated_bindings.ml: $(BUILDDIR)/test-returning-errno-lwt-preemptive-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-returning-errno-lwt-preemptive/generated_struct_bindings.ml: $(BUILDDIR)/test-returning-errno-lwt-preemptive-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-returning-errno-lwt-preemptive-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-returning-errno-lwt-preemptive/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-returning-errno-lwt-preemptive/generated_struct_stubs.c: $(BUILDDIR)/test-returning-errno-lwt-preemptive-stub-generator.$(BEST) - $< --c-struct-file $@ - -test-returning-errno-stubs.dir = tests/test-returning-errno/stubs -test-returning-errno-stubs.threads = yes -test-returning-errno-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-returning-errno-stubs: PROJECT=test-returning-errno-stubs -test-returning-errno-stubs: $$(LIB_TARGETS) - -test-returning-errno-stub-generator.dir = tests/test-returning-errno/stub-generator -test-returning-errno-stub-generator.threads = yes -test-returning-errno-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-returning-errno-stubs tests-common -test-returning-errno-stub-generator.deps = str bigarray-compat integers -test-returning-errno-stub-generator: PROJECT=test-returning-errno-stub-generator -test-returning-errno-stub-generator: $$(BEST_TARGET) - -test-returning-errno.dir = tests/test-returning-errno -test-returning-errno.threads = yes -test-returning-errno.deps = str bigarray-compat oUnit integers -test-returning-errno.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-returning-errno-stubs -test-returning-errno.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-returning-errno: PROJECT=test-returning-errno -test-returning-errno: $$(BEST_TARGET) - -test-returning-errno-generated= \ - tests/test-returning-errno/generated_bindings.ml \ - tests/test-returning-errno/generated_struct_bindings.ml \ - tests/test-returning-errno/generated_stubs.c - -test-returning-errno-generated: $(test-returning-errno-generated) - -tests/test-returning-errno/generated_stubs.c: $(BUILDDIR)/test-returning-errno-stub-generator.$(BEST) - $< --c-file $@ -tests/test-returning-errno/generated_bindings.ml: $(BUILDDIR)/test-returning-errno-stub-generator.$(BEST) - $< --ml-file $@ -tests/test-returning-errno/generated_struct_bindings.ml: $(BUILDDIR)/test-returning-errno-ml-stub-generator.$(BEST) - $< > $@ -$(BUILDDIR)/test-returning-errno-ml-stub-generator.$(BEST): $(BUILDDIR)/tests/test-returning-errno/generated_struct_stubs.c - $(CC) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` $(CFLAGS) $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -$(BUILDDIR)/tests/test-returning-errno/generated_struct_stubs.c: $(BUILDDIR)/test-returning-errno-stub-generator.$(BEST) - $< --c-struct-file $@ - - -test-threads-stubs.dir = tests/test-threads/stubs -test-threads-stubs.threads = yes -test-threads-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-threads-stubs: PROJECT=test-threads-stubs -test-threads-stubs: $$(LIB_TARGETS) - -test-threads-stub-generator.dir = tests/test-threads/stub-generator -test-threads-stub-generator.threads = yes -test-threads-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-threads-stubs tests-common -test-threads-stub-generator.deps = str bigarray-compat integers -test-threads-stub-generator: PROJECT=test-threads-stub-generator -test-threads-stub-generator: $$(BEST_TARGET) - -test-threads.dir = tests/test-threads -test-threads.threads = yes -test-threads.deps = str bigarray-compat oUnit integers -test-threads.subproject_deps = ctypes ctypes-foreign \ - cstubs tests-common test-threads-stubs -test-threads.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-threads: PROJECT=test-threads -test-threads: $$(BEST_TARGET) - -test-threads-generated= \ - tests/test-threads/generated_bindings.ml \ - tests/test-threads/generated_stubs.c - -test-threads-generated: $(test-threads-generated) - -tests/test-threads/generated_stubs.c: $(BUILDDIR)/test-threads-stub-generator.$(BEST) - $< --c-file $@ -tests/test-threads/generated_bindings.ml: $(BUILDDIR)/test-threads-stub-generator.$(BEST) - $< --ml-file $@ - -test-closure-type-promotion-stubs.dir = tests/test-closure-type-promotion/stubs -test-closure-type-promotion-stubs.threads = yes -test-closure-type-promotion-stubs.subproject_deps = ctypes \ - ctypes-foreign tests-common -test-closure-type-promotion-stubs: PROJECT=test-closure-type-promotion-stubs -test-closure-type-promotion-stubs: $$(LIB_TARGETS) - -test-closure-type-promotion-stub-generator.dir = tests/test-closure-type-promotion/stub-generator -test-closure-type-promotion-stub-generator.threads = yes -test-closure-type-promotion-stub-generator.subproject_deps = ctypes cstubs \ - ctypes-foreign test-closure-type-promotion-stubs tests-common -test-closure-type-promotion-stub-generator.deps = str bigarray-compat integers -test-closure-type-promotion-stub-generator: PROJECT=test-closure-type-promotion-stub-generator -test-closure-type-promotion-stub-generator: $$(BEST_TARGET) - -test-closure-type-promotion.dir = tests/test-closure-type-promotion -test-closure-type-promotion.threads = yes -test-closure-type-promotion.deps = str bigarray-compat oUnit integers -test-closure-type-promotion.subproject_deps = ctypes ctypes-foreign \ - cstubs test-closure-type-promotion-stubs tests-common -test-closure-type-promotion.link_flags = -L$(BUILDDIR)/clib -ltest_functions -test-closure-type-promotion: PROJECT=test-closure-type-promotion -test-closure-type-promotion: $$(BEST_TARGET) - -test-closure-type-promotion-generated= \ - tests/test-closure-type-promotion/generated_bindings.ml \ - tests/test-closure-type-promotion/generated_stubs.c - -test-closure-type-promotion-generated: $(test-closure-type-promotion-generated) - -tests/test-closure-type-promotion/generated_stubs.c: $(BUILDDIR)/test-closure-type-promotion-stub-generator.$(BEST) - $< --c-file $@ -tests/test-closure-type-promotion/generated_bindings.ml: $(BUILDDIR)/test-closure-type-promotion-stub-generator.$(BEST) - $< --ml-file $@ - -test-ldouble.dir = tests/test-ldouble -test-ldouble.threads = yes -test-ldouble.deps = str bigarray-compat oUnit integers -test-ldouble.subproject_deps = ctypes -test-ldouble: PROJECT=test-ldouble -test-ldouble: $$(BEST_TARGET) - -TESTS = -TESTS += test-raw -TESTS += test-pointers-stubs test-pointers-stub-generator test-pointers-generated test-pointers -TESTS += test-integers-stubs test-integers-stub-generator test-integers-generated test-integers -TESTS += test-variadic-stubs test-variadic-stub-generator test-variadic-generated test-variadic -TESTS += test-builtins-stubs test-builtins-stub-generator test-builtins-generated test-builtins -TESTS += test-macros-stubs test-macros-stub-generator test-macros-generated test-macros -TESTS += test-higher_order-stubs test-higher_order-stub-generator test-higher_order-generated test-higher_order -TESTS += test-enums-struct-stubs test-enums-struct-stub-generator test-enums-structs-generated test-enums-stubs test-enums-stub-generator test-enums-generated test-enums -TESTS += test-structs-stubs test-structs-stub-generator test-structs-generated test-structs -TESTS += test-constants-stubs test-constants-stub-generator test-constants-generated test-constants -TESTS += test-finalisers -TESTS += test-cstdlib-stubs test-cstdlib-stub-generator test-cstdlib-generated test-cstdlib -TESTS += test-sizeof -TESTS += test-foreign_values-stubs test-foreign_values-stub-generator test-foreign_values-generated test-foreign_values -TESTS += test-unions-stubs test-unions-stub-generator test-unions-generated test-unions -TESTS += test-custom_ops -TESTS += test-arrays-stubs test-arrays-stub-generator test-arrays-generated test-arrays -TESTS += test-foreign-errno -TESTS += test-passable -TESTS += test-alignment -TESTS += test-views-stubs test-views-stub-generator test-views-generated test-views -TESTS += test-oo_style-stubs test-oo_style-stub-generator test-oo_style-generated test-oo_style -TESTS += test-marshal -TESTS += test-type_printing-stubs test-type_printing-stub-generator test-type_printing-generated test-type_printing -TESTS += test-value_printing-stubs test-value_printing-stub-generator test-value_printing-generated test-value_printing -TESTS += test-complex-stubs test-complex-stub-generator test-complex-generated test-complex -TESTS += test-bools-stubs test-bools-stub-generator test-bools-generated test-bools -TESTS += test-callback_lifetime-stubs test-callback_lifetime-stub-generator test-callback_lifetime-generated test-callback_lifetime -TESTS += test-lifetime-stubs test-lifetime-stub-generator test-lifetime-generated test-lifetime -TESTS += test-stubs -TESTS += test-bigarrays-stubs test-bigarrays-stub-generator test-bigarrays-generated test-bigarrays -TESTS += test-coercions-stubs test-coercions-stub-generator test-coercions-generated test-coercions -TESTS += test-roots -TESTS += test-passing-ocaml-values-stubs test-passing-ocaml-values-stub-generator test-passing-ocaml-values-generated test-passing-ocaml-values -TESTS += test-funptrs-stubs test-funptrs-stub-generator test-funptrs-generated test-funptrs -TESTS += test-lwt-jobs-stubs test-lwt-jobs-stub-generator test-lwt-jobs-generated test-lwt-jobs -TESTS += test-lwt-preemptive-stubs test-lwt-preemptive-stub-generator test-lwt-preemptive-generated test-lwt-preemptive -TESTS += test-returning-errno-lwt-jobs-stubs test-returning-errno-lwt-jobs-stub-generator test-returning-errno-lwt-jobs-generated test-returning-errno-lwt-jobs -TESTS += test-returning-errno-lwt-preemptive-stubs test-returning-errno-lwt-preemptive-stub-generator test-returning-errno-lwt-preemptive-generated test-returning-errno-lwt-preemptive -TESTS += test-returning-errno-stubs test-returning-errno-stub-generator test-returning-errno-generated test-returning-errno -TESTS += test-closure-type-promotion-stubs test-closure-type-promotion-stub-generator test-closure-type-promotion-generated test-closure-type-promotion -TESTS += test-threads-stubs test-threads-stub-generator test-threads-generated test-threads -TESTS += test-ldouble - -ifneq (,$(filter mingw%,$(OSYSTEM))) -WINLDFLAGS=-Wl,--out-implib,libtest_functions.dll.a -LDFLAGS+=-static-libgcc -endif - -testlib: $(BUILDDIR)/clib/libtest_functions$(EXTDLL) -$(BUILDDIR)/clib/libtest_functions$(EXTDLL): $(BUILDDIR)/clib/test_functions.o - $(CC) -shared $(LDFLAGS) $(WINLDFLAGS) -o $@ $^ -lm -ifneq (,$(filter mingw%,$(OSYSTEM))) - cp $@ libtest_functions.dll.a $(BUILDDIR) -endif - -$(BUILDDIR)/clib/test_functions.o: tests/clib/test_functions.c - @mkdir -p $(@D) - $(CC) -c $(CFLAGS) -I `$(OCAMLFIND) ocamlc -where | sed 's|\r$$||'` -o $@ $^ -tests/clib/test_functions.c: tests/clib/test_functions.h - -.PHONY: test testlib $(TESTS) tests-common clean-tests -test: build testlib tests-common $(TESTS) \ - $(filter-out %-stubs,\ - $(filter-out %-stub-generator,\ - $(filter-out %-generated,\ - $(TESTS:%=run-%)))) - -TESTS_GENERATED=$(foreach test,$(filter %-generated,$(TESTS)),$($(test))) - -clean-tests: - rm -f $(TESTS_GENERATED) - -run-%: $* - @echo running $* - @cd $(BUILDDIR) && CAML_LD_LIBRARY_PATH=. LD_LIBRARY_PATH=clib DYLD_LIBRARY_PATH=clib ./$*.$(BEST) -runner sequential - diff --git a/ctypes-foreign.opam b/ctypes-foreign.opam index 3b1c84e37..0c438d3e9 100644 --- a/ctypes-foreign.opam +++ b/ctypes-foreign.opam @@ -1,47 +1,46 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "dev" -maintainer: "yallop@gmail.com" +synopsis: "Dynamic access to foreign C libraries using Ctypes" +description: """ + +This installs the `ctypes-foreign` interface which +uses `libffi` to provide dynamic access to foreign libraries.""" +maintainer: ["Jeremy Yallop "] +authors: ["Jeremy Yallop"] +license: "MIT" +tags: ["org:mirage" "org:ocamllabs"] homepage: "https://github.com/ocamllabs/ocaml-ctypes" -dev-repo: "git+http://github.com/ocamllabs/ocaml-ctypes.git" -bug-reports: "http://github.com/ocamllabs/ocaml-ctypes/issues" -depexts: [ - ["libffi-dev"] {os-family = "debian"} - ["libffi"] {os = "macos" & os-distribution = "homebrew"} - ["libffi"] {os = "macos" & os-distribution = "macports"} - ["libffi-devel"] {os-distribution = "centos"} - ["libffi-devel"] {os-distribution = "ol"} - ["libffi"] {os = "win32" & os-distribution = "cygwinports"} - ["libffi-devel"] {os-distribution = "fedora"} - ["libffi-dev"] {os-distribution = "alpine"} - ["libffi-devel"] {os-family = "suse"} -] +doc: "https://ocamllabs.github.io/ocaml-ctypes/" +bug-reports: "https://github.com/ocamllabs/ocaml-ctypes/issues" depends: [ - "conf-pkg-config" {build} + "dune" {>= "2.9"} + "ocaml" {>= "4.03.0"} + "integers" {with-test & >= "0.2.2"} + "ctypes" {= version} + "dune-configurator" + "conf-pkg-config" + "lwt" {with-test & >= "2.4.7"} + "ounit2" {with-test} + "conf-ncurses" {with-test} + "stdlib-shims" {with-test} + "conf-fts" {with-test & os != "win32"} + "conf-libffi" {>= "2.0.0"} + "odoc" {with-doc} ] -tags: ["org:ocamllabs" "org:mirage"] -post-messages: [ - "This package requires libffi on your system" {failure} +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "--promote-install-files=false" + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ["dune" "install" "-p" name "--create-install-files" name] ] -synopsis: "Virtual package for enabling the ctypes.foreign subpackage" -description: """ -`ctypes-foreign` is just a virtual OPAM package that determines -whether the foreign subpackage should built as part of ctypes. -In order to actually get the ctypes package, you should also: - - opam install ctypes ctypes-foreign - -You can verify the existence of the ocamlfind subpackage by: - - ocamlfind list | grep ctypes - -Which should output something like: - - ctypes (version: 0.4.1) - ctypes.foreign (version: 0.4.1) - ctypes.foreign.base (version: 0.4.1) - ctypes.foreign.threaded (version: 0.4.1) - ctypes.foreign.unthreaded (version: 0.4.1) - ctypes.stubs (version: 0.4.1) - ctypes.top (version: 0.4.1)""" -authors: "yallop@gmail.com" - +dev-repo: "git+https://github.com/ocamllabs/ocaml-ctypes.git" diff --git a/ctypes.opam b/ctypes.opam index 31617e76c..45c8a911e 100644 --- a/ctypes.opam +++ b/ctypes.opam @@ -1,47 +1,55 @@ +# This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "dev" -maintainer: "yallop@gmail.com" -author: "yallop@gmail.com" -homepage: "https://github.com/ocamllabs/ocaml-ctypes" -doc: "http://ocamllabs.github.io/ocaml-ctypes" -dev-repo: "git+http://github.com/ocamllabs/ocaml-ctypes.git" -bug-reports: "http://github.com/ocamllabs/ocaml-ctypes/issues" +synopsis: "Combinators for binding to C libraries without writing any C" +description: """ + +ctypes is a library for binding to C libraries using pure OCaml. The primary +aim is to make writing C extensions as straightforward as possible. +The core of ctypes is a set of combinators for describing the structure of C +types -- numeric types, arrays, pointers, structs, unions and functions. You +can use these combinators to describe the types of the functions that you want +to call, then bind directly to those functions -- all without writing or +generating any C! + +To install the optional `ctypes-foreign` interface (which uses `libffi` to +provide dynamic access to foreign libraries), you will need to also install +the `ctypes-foreign` package. + + opam install ctypes-foreign + +This will make the `ctypes-foreign` ocamlfind subpackage available.""" +maintainer: ["Jeremy Yallop "] +authors: ["Jeremy Yallop"] license: "MIT" -build: [ - [make - "XEN=%{mirage-xen:enable}%" - "COVERAGE=true" {bisect_ppx:installed} - "libffi.config" - "ctypes-base" - "ctypes-stubs"] - [make "XEN=%{mirage-xen:enable}%" "ctypes-foreign"] {ctypes-foreign:installed} -] -install: [ - [make "install" "XEN=%{mirage-xen:enable}%"] -] +tags: ["org:mirage" "org:ocamllabs"] +homepage: "https://github.com/ocamllabs/ocaml-ctypes" +doc: "https://ocamllabs.github.io/ocaml-ctypes/" +bug-reports: "https://github.com/ocamllabs/ocaml-ctypes/issues" depends: [ - "ocaml" {>= "4.03.0"} - "integers" { >= "0.3.0" } - "ocamlfind" {build} - "lwt" {with-test & >= "3.2.0"} - "ctypes-foreign" {with-test} - "ounit" {with-test} - "conf-ncurses" {with-test} - "bigarray-compat" -] -depopts: [ - "ctypes-foreign" - "mirage-xen" - "bisect_ppx" {with-test} - "ocveralls" {with-test} + "dune" {>= "2.9"} + "ocaml" {>= "4.03.0"} + "integers" + "dune-configurator" + "bigarray-compat" + "ounit2" {with-test} + "conf-fts" {with-test & os != "win32"} + "conf-pkg-config" {with-test} + "odoc" {with-doc} ] -build-test: [ - [make "COVERAGE=true" {bisect_ppx:installed} "test"] - [make "COVERAGE=true" {bisect_ppx:installed} "run-examples" ] {os != "win32"} - [make "date" "date-stubs" "date-stub-generator" "date-cmd-build" "date-cmd" ] {os = "win32"} - ["sh" "-c" "_build/date-cmd.native ; _build/date.native" ] {os = "win32"} - ["sh" "-c" "ocveralls" "--send bisect*.out" "_build/bisect*.out" ">" "coveralls.json"] {bisect_ppx:installed} +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "--promote-install-files=false" + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ["dune" "install" "-p" name "--create-install-files" name] ] -tags: ["org:ocamllabs" "org:mirage"] -synopsis: "Combinators for binding to C libraries without writing any C" - +dev-repo: "git+https://github.com/ocamllabs/ocaml-ctypes.git" diff --git a/dune b/dune new file mode 100644 index 000000000..6e4314156 --- /dev/null +++ b/dune @@ -0,0 +1,8 @@ +(env + (dev + (flags + (:standard -principal)))) + +(deprecated_library_name + (old_public_name "ctypes.foreign") + (new_public_name "ctypes-foreign")) diff --git a/dune-project b/dune-project new file mode 100644 index 000000000..c376d7c06 --- /dev/null +++ b/dune-project @@ -0,0 +1,61 @@ +(lang dune 2.9) +(name ctypes) +(formatting (enabled_for dune)) +(use_standard_c_and_cxx_flags true) + +(generate_opam_files true) + +(license MIT) +(maintainers "Jeremy Yallop ") +(authors "Jeremy Yallop") +(source (github ocamllabs/ocaml-ctypes)) +(documentation "https://ocamllabs.github.io/ocaml-ctypes/") + +(package + (name ctypes) + (tags (org:mirage org:ocamllabs)) + (depends + (ocaml (>= 4.03.0)) + integers + dune-configurator + bigarray-compat + (ounit2 :with-test) + (conf-fts (and :with-test (<> :os win32))) + (conf-pkg-config :with-test)) + (synopsis "Combinators for binding to C libraries without writing any C") + (description " +ctypes is a library for binding to C libraries using pure OCaml. The primary +aim is to make writing C extensions as straightforward as possible. +The core of ctypes is a set of combinators for describing the structure of C +types -- numeric types, arrays, pointers, structs, unions and functions. You +can use these combinators to describe the types of the functions that you want +to call, then bind directly to those functions -- all without writing or +generating any C! + +To install the optional `ctypes-foreign` interface (which uses `libffi` to +provide dynamic access to foreign libraries), you will need to also install +the `ctypes-foreign` package. + + opam install ctypes-foreign + +This will make the `ctypes-foreign` ocamlfind subpackage available.")) + +(package + (name ctypes-foreign) + (tags (org:mirage org:ocamllabs)) + (depends + (ocaml (>= 4.03.0)) + (integers (and :with-test (>= 0.2.2))) + (ctypes (= :version)) + dune-configurator + conf-pkg-config + (lwt (and :with-test (>= 2.4.7))) + (ounit2 :with-test) + (conf-ncurses :with-test) + (stdlib-shims :with-test) + (conf-fts (and :with-test (<> :os win32))) + (conf-libffi (>= 2.0.0))) + (synopsis "Dynamic access to foreign C libraries using Ctypes") + (description " +This installs the `ctypes-foreign` interface which +uses `libffi` to provide dynamic access to foreign libraries.")) diff --git a/examples/date/foreign/dune b/examples/date/foreign/dune new file mode 100644 index 000000000..80e4aa6da --- /dev/null +++ b/examples/date/foreign/dune @@ -0,0 +1,3 @@ +(executables + (names date) + (libraries ctypes-foreign)) diff --git a/examples/date/stub-generation/bindings/dune b/examples/date/stub-generation/bindings/dune new file mode 100644 index 000000000..1690dff74 --- /dev/null +++ b/examples/date/stub-generation/bindings/dune @@ -0,0 +1,3 @@ +(library + (name date_stubs) + (libraries ctypes)) diff --git a/examples/date/stub-generation/dune b/examples/date/stub-generation/dune new file mode 100644 index 000000000..80cb3e18b --- /dev/null +++ b/examples/date/stub-generation/dune @@ -0,0 +1,3 @@ +(executable + (name date_cmd) + (libraries date_stubs date_generated)) diff --git a/examples/date/stub-generation/stub-generator/date_stub_generator.ml b/examples/date/stub-generation/stub-generator/date_stub_generator.ml index 3cdc33d87..0e52eb693 100644 --- a/examples/date/stub-generation/stub-generator/date_stub_generator.ml +++ b/examples/date/stub-generation/stub-generator/date_stub_generator.ml @@ -8,8 +8,8 @@ let c_headers = "#include " let main () = - let ml_out = open_out "examples/date/stub-generation/date_generated.ml" - and c_out = open_out "examples/date/stub-generation/date_stubs.c" in + let ml_out = open_out "date_generated.ml" + and c_out = open_out "date_stubs.c" in let ml_fmt = Format.formatter_of_out_channel ml_out and c_fmt = Format.formatter_of_out_channel c_out in Format.fprintf c_fmt "%s@\n" c_headers; diff --git a/examples/date/stub-generation/stub-generator/dune b/examples/date/stub-generation/stub-generator/dune new file mode 100644 index 000000000..97ad9b1e1 --- /dev/null +++ b/examples/date/stub-generation/stub-generator/dune @@ -0,0 +1,18 @@ +(executable + (name date_stub_generator) + (modules date_stub_generator) + (libraries date_stubs ctypes.stubs ctypes)) + +(rule + (targets date_stubs.c date_generated.ml) + (deps date_stub_generator.exe) + (action + (run %{deps}))) + +(library + (name date_generated) + (modules date_generated) + (foreign_stubs + (language c) + (names date_stubs)) + (libraries ctypes.stubs)) diff --git a/examples/fts/foreign/dune b/examples/fts/foreign/dune new file mode 100644 index 000000000..e80dee4f7 --- /dev/null +++ b/examples/fts/foreign/dune @@ -0,0 +1,7 @@ +(test + (name fts_cmd) + (enabled_if + (= %{os_type} Unix)) + (libraries ctypes-foreign) + (package ctypes-foreign) + (action (progn))) diff --git a/examples/fts/foreign/fts.ml b/examples/fts/foreign/fts.ml index 8540a1cab..051d7426e 100644 --- a/examples/fts/foreign/fts.ml +++ b/examples/fts/foreign/fts.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9-32"] + open Ctypes type fts_info = @@ -35,7 +37,7 @@ let fts_info_of_int = function | 11 -> FTS_NSOK | 12 -> FTS_SL | 13 -> FTS_SLNONE - | _ -> invalid_arg "fts_info" + | n -> invalid_arg ("fts_info: " ^ (string_of_int n)) type fts_open_option = FTS_COMFOLLOW @@ -241,7 +243,7 @@ let null_terminated_array_of_ptr_list typ list = (castp (ptr void) (CArray.start arr +@ nitems)) <-@ null; arr -let fts_open ~path_argv ?compar ~options = +let fts_open ~path_argv ?compar ~options () = let paths = null_terminated_array_of_ptr_list string path_argv in let options = crush_options fts_open_option_value options in { ptr = _fts_open (CArray.start paths) options compar; compar } diff --git a/examples/fts/foreign/fts.mli b/examples/fts/foreign/fts.mli index 9656f337a..521049b98 100644 --- a/examples/fts/foreign/fts.mli +++ b/examples/fts/foreign/fts.mli @@ -220,7 +220,7 @@ val fts_open : path_argv:string list -> ?compar:(FTSENT.t ptr -> FTSENT.t ptr -> int) -> options:fts_open_option list -> - FTS.t + unit -> FTS.t (* The fts_children() function returns a pointer to an FTSENT structure describing the first entry in a NULL-terminated linked list of the diff --git a/examples/fts/foreign/fts_cmd.ml b/examples/fts/foreign/fts_cmd.ml index 07df52f19..d359aded3 100644 --- a/examples/fts/foreign/fts_cmd.ml +++ b/examples/fts/foreign/fts_cmd.ml @@ -14,17 +14,26 @@ let sort_by_name lp rp = let open FTSENT in String.compare (name !@lp) (name !@rp) +let rec iter ~gen ~f = + match gen () with + | None -> () + | Some x -> + begin + f x; + iter ~gen ~f + end + let ents ?compar path_argv = - let fts : FTS.t = fts_open ~path_argv ?compar ~options:[] in - Stream.from (fun _ -> fts_read fts) + let fts : FTS.t = fts_open ~path_argv ?compar ~options:[] () in + (fun _ -> fts_read fts) let main paths = let indent = ref 0 in let show_path ent = Printf.printf "%*s%s\n" !indent "" (FTSENT.path ent); in - Stream.iter - FTSENT.(fun ent -> + iter + ~f:FTSENT.(fun ent -> match info ent with | FTS_D -> begin show_path ent; @@ -35,7 +44,7 @@ let main paths = | FTS_SLNONE -> show_path ent | FTS_DP -> decr indent | _ -> ()) - (ents ~compar:sort_by_name paths) + ~gen:(ents ~compar:sort_by_name paths) let () = match List.tl (Array.to_list Sys.argv) with diff --git a/examples/fts/stub-generation/bindings/dune b/examples/fts/stub-generation/bindings/dune new file mode 100644 index 000000000..c36e1ce62 --- /dev/null +++ b/examples/fts/stub-generation/bindings/dune @@ -0,0 +1,5 @@ +(library + (name fts_stubs) + (wrapped false) + (modules_without_implementation fts) + (libraries ctypes ctypes-foreign)) diff --git a/examples/fts/stub-generation/bindings/fts_types.ml b/examples/fts/stub-generation/bindings/fts_types.ml index 02f65345f..ee54acc78 100644 --- a/examples/fts/stub-generation/bindings/fts_types.ml +++ b/examples/fts/stub-generation/bindings/fts_types.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9"] + open Ctypes type fts_info = diff --git a/examples/fts/stub-generation/config/discover.ml b/examples/fts/stub-generation/config/discover.ml new file mode 100644 index 000000000..ac3e0e834 --- /dev/null +++ b/examples/fts/stub-generation/config/discover.ml @@ -0,0 +1,25 @@ +module C = Configurator.V1 + +let prepend opt flags = + if flags = [] then + [] + else + opt :: flags + +let () = + C.main ~name:"fts_example" (fun c -> + let default : C.Pkg_config.package_conf = { + libs = []; + cflags = [] + } in + let conf = + match C.Pkg_config.get c with + | None -> default + | Some pc -> + (match C.Pkg_config.query pc ~package:"libfts" with + | None -> default + | Some v -> v) + in + C.Flags.write_sexp "c_flags.sexp" (prepend "-ccopt" conf.cflags); + C.Flags.write_sexp "c_library_flags.sexp" (prepend "-cclib" conf.libs) + ) diff --git a/examples/fts/stub-generation/config/discover.mli b/examples/fts/stub-generation/config/discover.mli new file mode 100644 index 000000000..e790aeb70 --- /dev/null +++ b/examples/fts/stub-generation/config/discover.mli @@ -0,0 +1 @@ +(* empty *) diff --git a/examples/fts/stub-generation/config/dune b/examples/fts/stub-generation/config/dune new file mode 100644 index 000000000..d38eb14bf --- /dev/null +++ b/examples/fts/stub-generation/config/dune @@ -0,0 +1,8 @@ +(executable + (name discover) + (libraries dune-configurator)) + +(rule + (targets c_flags.sexp c_library_flags.sexp) + (action + (run ./discover.exe))) diff --git a/examples/fts/stub-generation/dune b/examples/fts/stub-generation/dune new file mode 100644 index 000000000..f193b3816 --- /dev/null +++ b/examples/fts/stub-generation/dune @@ -0,0 +1,18 @@ +(* -*- tuareg -*- *) + +(* This can be ported to build_if once available, ocaml/dune#7899 *) + +let unix = List.mem ("os_type", "Unix") Jbuild_plugin.V1.ocamlc_config + +let () = Jbuild_plugin.V1.send @@ if not unix then "" else {| +(test + (name fts_cmd) + (enabled_if + (= %{os_type} Unix)) + (libraries fts_stubs fts_generated) + (package ctypes) + (action (progn)) + (link_flags + :standard + (:include config/c_library_flags.sexp))) +|} diff --git a/examples/fts/stub-generation/fts_cmd.ml b/examples/fts/stub-generation/fts_cmd.ml index 87e8273f7..658c892c2 100644 --- a/examples/fts/stub-generation/fts_cmd.ml +++ b/examples/fts/stub-generation/fts_cmd.ml @@ -15,17 +15,26 @@ let sort_by_name lp rp = let open FTSENT in String.compare (name !@lp) (name !@rp) +let rec iter ~gen ~f = + match gen () with + | None -> () + | Some x -> + begin + f x; + iter ~gen ~f + end + let ents ?compar path_argv = - let fts : FTS.t = fts_open ~path_argv ?compar ~options:[] in - Stream.from (fun _ -> fts_read fts) + let fts : FTS.t = fts_open ~path_argv ?compar ~options:[] () in + (fun _ -> fts_read fts) let main paths = let indent = ref 0 in let show_path ent = Printf.printf "%*s%s\n" !indent "" (FTSENT.path ent); in - Stream.iter - FTSENT.(fun ent -> + iter + ~f:FTSENT.(fun ent -> match info ent with | FTS_D -> begin show_path ent; @@ -36,7 +45,7 @@ let main paths = | FTS_SLNONE -> show_path ent | FTS_DP -> decr indent | _ -> ()) - (ents ~compar:sort_by_name paths) + ~gen:(ents ~compar:sort_by_name paths) let () = match List.tl (Array.to_list Sys.argv) with diff --git a/examples/fts/stub-generation/fts_if.ml b/examples/fts/stub-generation/fts_if.ml index 7ff3fd1a4..a82e01d20 100644 --- a/examples/fts/stub-generation/fts_if.ml +++ b/examples/fts/stub-generation/fts_if.ml @@ -8,7 +8,6 @@ open Ctypes open Fts_types open FTS -open FTSENT module N = Fts_bindings.Bindings(Fts_generated) open N @@ -36,7 +35,7 @@ let null_terminated_array_of_ptr_list typ list = (coerce (ptr typ) (ptr (ptr void)) (CArray.start arr +@ nitems)) <-@ null; arr -let fts_open ~path_argv ?compar ~options = +let fts_open ~path_argv ?compar ~options () = let path_argv_cpointers = List.map _strdup path_argv in let paths = null_terminated_array_of_ptr_list (ptr char) path_argv_cpointers in let options = crush_options fts_open_option_value options in diff --git a/examples/fts/stub-generation/stub-generator/dune b/examples/fts/stub-generation/stub-generator/dune new file mode 100644 index 000000000..297aafde5 --- /dev/null +++ b/examples/fts/stub-generation/stub-generator/dune @@ -0,0 +1,27 @@ +(executable + (name fts_stub_generator) + (enabled_if + (= %{os_type} "Unix")) + (modules fts_stub_generator) + (libraries fts_stubs ctypes.stubs ctypes)) + +(rule + (targets fts_stubs.c fts_generated.ml) + (deps fts_stub_generator.exe) + (enabled_if + (= %{os_type} "Unix")) + (action + (run %{deps}))) + +(library + (name fts_generated) + (enabled_if + (= %{os_type} "Unix")) + (modules fts_generated) + (foreign_stubs + (language c) + (names fts_stubs) + (flags + :standard + (:include ../config/c_flags.sexp))) + (libraries ctypes.stubs)) diff --git a/examples/fts/stub-generation/stub-generator/fts_stub_generator.ml b/examples/fts/stub-generation/stub-generator/fts_stub_generator.ml index 042fa071e..28c131aa3 100644 --- a/examples/fts/stub-generation/stub-generator/fts_stub_generator.ml +++ b/examples/fts/stub-generation/stub-generator/fts_stub_generator.ml @@ -13,8 +13,8 @@ let c_headers = " " let main () = - let ml_out = open_out "examples/fts/stub-generation/fts_generated.ml" - and c_out = open_out "examples/fts/stub-generation/fts_stubs.c" in + let ml_out = open_out "fts_generated.ml" + and c_out = open_out "fts_stubs.c" in let ml_fmt = Format.formatter_of_out_channel ml_out and c_fmt = Format.formatter_of_out_channel c_out in Format.fprintf c_fmt "%s@\n" c_headers; diff --git a/examples/ncurses/foreign/dune b/examples/ncurses/foreign/dune new file mode 100644 index 000000000..f64b0b7e4 --- /dev/null +++ b/examples/ncurses/foreign/dune @@ -0,0 +1,11 @@ +(library + (name ncurses) + (modules ncurses) + (libraries ctypes-foreign)) + +(executables + (names ncurses_cmd) + (modules ncurses_cmd) + (link_flags + (:standard -cclib -lncurses)) + (libraries ncurses)) diff --git a/examples/ncurses/stub-generation/bindings/dune b/examples/ncurses/stub-generation/bindings/dune new file mode 100644 index 000000000..4d7a6c005 --- /dev/null +++ b/examples/ncurses/stub-generation/bindings/dune @@ -0,0 +1,3 @@ +(library + (name ncurses_bindings) + (libraries ctypes)) diff --git a/examples/ncurses/stub-generation/dune b/examples/ncurses/stub-generation/dune new file mode 100644 index 000000000..62a5c63f4 --- /dev/null +++ b/examples/ncurses/stub-generation/dune @@ -0,0 +1,3 @@ +(executable + (name ncurses_stub_cmd) + (libraries ncurses_bindings ncurses_generated unix)) diff --git a/examples/ncurses/stub-generation/stub-generator/dune b/examples/ncurses/stub-generation/stub-generator/dune new file mode 100644 index 000000000..40906bc98 --- /dev/null +++ b/examples/ncurses/stub-generation/stub-generator/dune @@ -0,0 +1,19 @@ +(executable + (name ncurses_stub_generator) + (modules ncurses_stub_generator) + (libraries ncurses_bindings ctypes.stubs ctypes)) + +(rule + (targets ncurses_stubs.c ncurses_generated.ml) + (deps ncurses_stub_generator.exe) + (action + (run %{deps}))) + +(library + (name ncurses_generated) + (modules ncurses_generated) + (c_library_flags -lncurses) + (foreign_stubs + (language c) + (names ncurses_stubs)) + (libraries ctypes.stubs)) diff --git a/examples/ncurses/stub-generation/stub-generator/ncurses_stub_generator.ml b/examples/ncurses/stub-generation/stub-generator/ncurses_stub_generator.ml index 3326807fe..b376980c8 100644 --- a/examples/ncurses/stub-generation/stub-generator/ncurses_stub_generator.ml +++ b/examples/ncurses/stub-generation/stub-generator/ncurses_stub_generator.ml @@ -8,8 +8,8 @@ let c_headers = "#include " let main () = - let ml_out = open_out "examples/ncurses/stub-generation/ncurses_generated.ml" in - let c_out = open_out "examples/ncurses/stub-generation/ncurses_stubs.c" in + let ml_out = open_out "ncurses_generated.ml" in + let c_out = open_out "ncurses_stubs.c" in let c_fmt = Format.formatter_of_out_channel c_out in let ml_fmt = Format.formatter_of_out_channel ml_out in Format.fprintf c_fmt "%s@\n" c_headers; diff --git a/src/configure/dune b/src/configure/dune new file mode 100644 index 000000000..5671b9573 --- /dev/null +++ b/src/configure/dune @@ -0,0 +1,4 @@ +(executable + (name gen_c_primitives) + (libraries dune-configurator) + (modules gen_c_primitives)) diff --git a/src/configure/extract_from_c.ml b/src/configure/extract_from_c.ml deleted file mode 100644 index f8c28204d..000000000 --- a/src/configure/extract_from_c.ml +++ /dev/null @@ -1,104 +0,0 @@ -(* - * Copyright (c) 2016 whitequark. - * - * This file is distributed under the terms of the MIT License. - * See the file LICENSE for details. - *) - -let getenv ~default name = - try Sys.getenv name - with Not_found -> default - -let nsplit sep str = Str.(split (regexp_string sep)) str - -let read_output program = - let input_filename = Filename.temp_file "ctypes_libffi_config" ".c" in - let channel = open_out input_filename in - output_string channel program; - close_out channel; - let output_filename = (Filename.chop_suffix input_filename ".c") ^ ".o" in - let cwd = Sys.getcwd () in - let cmd = - Printf.sprintf "%s ocamlc -verbose %s %s -c 1>&2" - (getenv ~default:"ocamlfind" "OCAMLFIND") - ((getenv ~default:"" "CFLAGS") |> - (nsplit " ") |> - (List.map (fun s -> "-ccopt " ^ Filename.quote s)) |> - (String.concat " ")) - (Filename.quote input_filename) - in - prerr_endline cmd; - Sys.chdir (Filename.dirname input_filename); - ignore (Sys.command cmd); - Sys.chdir cwd; - Sys.remove input_filename; - if not (Sys.file_exists output_filename) then - raise Not_found; - let channel = open_in_bin output_filename in - let length = in_channel_length channel in - let result = Bytes.create length in - really_input channel result 0 length; - close_in channel; - Sys.remove output_filename; - Bytes.to_string result - -let find_from haystack pos needle = Str.(search_forward (regexp_string needle) haystack pos) - -let prefix = "BEGIN-" -let suffix = "-END" -let extract s = - let begin_pos = find_from s 0 prefix + String.length prefix in - let end_pos = find_from s 0 suffix in - String.sub s begin_pos (end_pos - begin_pos) - -let headers = "\ -#if defined(__MINGW32__) || defined(__MINGW64__) -#define __USE_MINGW_ANSI_STDIO 1 -#include /* see: https://sourceforge.net/p/mingw-w64/bugs/627/ */ -#endif -#include -#include -#include -#include -" - -let integer ?(extra_headers="") expression = - let code = Printf.sprintf "%s -%s - -#define alignof(T) (offsetof(struct { char c; T t; }, t)) - -#define D0(x) ('0'+(x/1 )%%10) -#define D1(x) ('0'+(x/10 )%%10), D0(x) -#define D2(x) ('0'+(x/100 )%%10), D1(x) -#define D3(x) ('0'+(x/1000 )%%10), D2(x) -#define D4(x) ('0'+(x/10000 )%%10), D3(x) -#define D5(x) ('0'+(x/100000 )%%10), D4(x) -#define D6(x) ('0'+(x/1000000 )%%10), D5(x) -#define D7(x) ('0'+(x/10000000 )%%10), D6(x) -#define D8(x) ('0'+(x/100000000 )%%10), D7(x) -#define D9(x) ('0'+(x/1000000000)%%10), D8(x) -const char s[] = { - 'B', 'E', 'G', 'I', 'N', '-', - D9((%s)), - '-', 'E', 'N', 'D' -}; -" headers extra_headers expression in - int_of_string (extract (read_output code)) - -let string ?(extra_headers="") expression = - let code = Printf.sprintf "%s -%s - -#define STRINGIFY1(x) #x -#define STRINGIFY(x) STRINGIFY1(x) - -#if __USE_MINGW_ANSI_STDIO && defined(__MINGW64__) -#define REAL_ARCH_INTNAT_PRINTF_FORMAT \"ll\" -#else -#define REAL_ARCH_INTNAT_PRINTF_FORMAT ARCH_INTNAT_PRINTF_FORMAT -#endif - -const char *s = \"BEGIN-\" %s \"-END\"; -" headers extra_headers expression in - extract (read_output code) diff --git a/src/configure/gen_c_primitives.ml b/src/configure/gen_c_primitives.ml index 84ea73301..f768601f9 100644 --- a/src/configure/gen_c_primitives.ml +++ b/src/configure/gen_c_primitives.ml @@ -1,3 +1,7 @@ +[@@@warning "-9"] + +module C = Configurator.V1 + let header ="\ (* * Copyright (c) 2016 whitequark @@ -64,7 +68,7 @@ let c_primitives = [ alignment = "alignof(intnat)" }; ] -let printf = Printf.printf +open Printf let generate name typ f = printf "let %s : type a. a prim -> %s = function\n" name typ; @@ -77,23 +81,54 @@ let generate name typ f = end; printf "\n") c_primitives +let prelude = "\ +#if defined(__MINGW32__) || defined(__MINGW64__) +#define __USE_MINGW_ANSI_STDIO 1 +#include /* see: https://sourceforge.net/p/mingw-w64/bugs/627/ */ +#endif + +#include +#include +#include +#include + +#define alignof(T) (offsetof(struct { char c; T t; }, t)) +#define STRINGIFY1(x) #x +#define STRINGIFY(x) STRINGIFY1(x) + +#if __USE_MINGW_ANSI_STDIO && defined(__MINGW64__) +#define REAL_ARCH_INTNAT_PRINTF_FORMAT \"ll\" +#else +#define REAL_ARCH_INTNAT_PRINTF_FORMAT ARCH_INTNAT_PRINTF_FORMAT +#endif +" +let includes = [] + let () = - begin + C.main ~name:"ctypes" (fun c -> + let import_int l = + match C.C_define.(import c ~prelude ~includes [l,Type.Int]) with + |[_,C.C_define.Value.Int i] -> i + |_ -> failwith ("unable to find integer definition for " ^ l) in + let import_string l = + match C.C_define.(import c ~prelude ~includes [l,Type.String]) with + |[_,C.C_define.Value.String s] -> s + |_ -> failwith ("unable to find string definition for " ^ l) in print_string header; generate "sizeof" "int" (fun { size } -> - printf "%d" (Extract_from_c.integer size)); + printf "%d" (import_int size)); generate "alignment" "int" (fun { alignment } -> - printf "%d" (Extract_from_c.integer alignment)); + printf "%d" (import_int alignment)); generate "name" "string" (fun { typ } -> - printf "%S" (Extract_from_c.string ("STRINGIFY("^typ^")"))); + printf "%S" (import_string ("STRINGIFY("^typ^")"))); generate "format_string" "string option" (fun { format } -> match format with | Known_format str -> printf "Some %S" ("%"^str) | Defined_format str -> - printf "Some %S" ("%"^Extract_from_c.string str) + printf "Some %S" ("%"^(import_string str)) | No_format -> printf "None"); - printf "let pointer_size = %d\n" (Extract_from_c.integer "sizeof(void*)"); - printf "let pointer_alignment = %d\n" (Extract_from_c.integer "alignof(void*)"); - end + printf "let pointer_size = %d\n" (import_int "sizeof(void*)"); + printf "let pointer_alignment = %d\n" (import_int "alignof(void*)"); + ) diff --git a/src/cstubs/cstubs.ml b/src/cstubs/cstubs.ml index 19595fdfe..a033c0546 100644 --- a/src/cstubs/cstubs.ml +++ b/src/cstubs/cstubs.ml @@ -7,6 +7,8 @@ (* Cstubs public interface. *) +[@@@warning "-27-32"] + module type FOREIGN = Ctypes.FOREIGN module type FOREIGN' = FOREIGN with type 'a result = unit diff --git a/src/cstubs/cstubs_c_language.ml b/src/cstubs/cstubs_c_language.ml index 5132e6782..87df2603a 100644 --- a/src/cstubs/cstubs_c_language.ml +++ b/src/cstubs/cstubs_c_language.ml @@ -7,6 +7,8 @@ (* C code representation. *) +[@@@warning "-9"] + open Ctypes_static let fresh_var = diff --git a/src/cstubs/cstubs_emit_c.ml b/src/cstubs/cstubs_emit_c.ml index 2b25b7fe4..7b4fc9a9f 100644 --- a/src/cstubs/cstubs_emit_c.ml +++ b/src/cstubs/cstubs_emit_c.ml @@ -7,6 +7,8 @@ (* C pretty printing. *) +[@@@warning "-9-27"] + open Ctypes_static open Cstubs_c_language open Format diff --git a/src/cstubs/cstubs_generate_c.ml b/src/cstubs/cstubs_generate_c.ml index d24fa1025..37bb39fe1 100644 --- a/src/cstubs/cstubs_generate_c.ml +++ b/src/cstubs/cstubs_generate_c.ml @@ -7,6 +7,8 @@ (* C stub generation *) +[@@@warning "-9-27"] + open Ctypes_static open Cstubs_c_language open Unchecked_function_types diff --git a/src/cstubs/cstubs_generate_ml.ml b/src/cstubs/cstubs_generate_ml.ml index 46f9cdaee..4f907bbd3 100644 --- a/src/cstubs/cstubs_generate_ml.ml +++ b/src/cstubs/cstubs_generate_ml.ml @@ -7,6 +7,8 @@ (* ML stub generation *) +[@@@warning "-9-27"] + open Ctypes_static open Ctypes_path open Cstubs_errors diff --git a/src/cstubs/cstubs_inverted.ml b/src/cstubs/cstubs_inverted.ml index 10b9e64ea..e4220cf76 100644 --- a/src/cstubs/cstubs_inverted.ml +++ b/src/cstubs/cstubs_inverted.ml @@ -7,6 +7,8 @@ (* Cstubs_inverted public interface. *) +[@@@warning "-9-27"] + module type INTERNAL = sig val enum : (string * int64) list -> 'a Ctypes.typ -> unit diff --git a/src/cstubs/cstubs_structs.ml b/src/cstubs/cstubs_structs.ml index 11b86c867..538ee728f 100644 --- a/src/cstubs/cstubs_structs.ml +++ b/src/cstubs/cstubs_structs.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9-27"] + open Ctypes module type TYPE = @@ -40,6 +42,7 @@ let cepilogue = [ "}"; ] let mlprologue = [ + "[@@@warning \"-9-27\"]"; "include Ctypes"; "let lift x = x"; "open Ctypes_static"; @@ -133,7 +136,7 @@ let primitive_format_string : type a. a Ctypes_primitive_types.prim -> string = let open Ctypes_primitive_types in let sprintf = Printf.sprintf in let fail () = - Printf.kprintf failwith "Cannot retrieve constants of type %s" + Printf.ksprintf failwith "Cannot retrieve constants of type %s" (Ctypes_primitives.name p) in match p, Ctypes_primitives.format_string p with diff --git a/src/cstubs/dune b/src/cstubs/dune new file mode 100644 index 000000000..3e14b9640 --- /dev/null +++ b/src/cstubs/dune @@ -0,0 +1,9 @@ +(library + (name ctypes_stubs) + (public_name ctypes.stubs) + (instrumentation + (backend bisect_ppx)) + (wrapped false) + (libraries + (re_export ctypes) + str)) diff --git a/src/ctypes-foreign/config/discover.ml b/src/ctypes-foreign/config/discover.ml new file mode 100644 index 000000000..7be7ae3c9 --- /dev/null +++ b/src/ctypes-foreign/config/discover.ml @@ -0,0 +1,37 @@ +module C = Configurator.V1 + +let () = + C.main ~name:"ffi" (fun c -> + let default : C.Pkg_config.package_conf = { + libs = ["-lffi"]; + cflags = [] + } in + let conf = + match C.Pkg_config.get c with + | None -> default + | Some pc -> + (match C.Pkg_config.query pc ~package:"libffi" with + | None -> default + | Some v -> v) + in + let backend = + match Sys.os_type with + | "Win32" | "Cygwin" -> "win" + | _ -> "unix" in + + let f = "as_needed_test" in + let ml = f ^ ".ml" in + open_out ml |> close_out; + let extra_ldflags = + match backend with + |"win" -> ["-lpsapi"] + |_ -> + let res = C.Process.run_ok c "ocamlopt" + ["-shared"; "-cclib"; "-Wl,--no-as-needed"; ml; "-o"; f^".cmxs"] in + if res then ["-Wl,--no-as-needed"] else [] + in + C.Flags.write_sexp "c_flags.sexp" conf.cflags; + C.Flags.write_lines "c_flags" conf.cflags; + C.Flags.write_sexp "c_library_flags.sexp" (conf.libs @ extra_ldflags); + C.Flags.write_lines "backend.sexp" [backend] + ) diff --git a/src/ctypes-foreign/config/dune b/src/ctypes-foreign/config/dune new file mode 100644 index 000000000..cd319cd9b --- /dev/null +++ b/src/ctypes-foreign/config/dune @@ -0,0 +1,9 @@ +(executable + (name discover) + (modules discover) + (libraries dune-configurator)) + +(executable + (name gen_libffi_abi) + (modules gen_libffi_abi) + (libraries dune-configurator)) diff --git a/src/configure/gen_libffi_abi.ml b/src/ctypes-foreign/config/gen_libffi_abi.ml similarity index 58% rename from src/configure/gen_libffi_abi.ml rename to src/ctypes-foreign/config/gen_libffi_abi.ml index ad59cb7b3..e570169c3 100644 --- a/src/configure/gen_libffi_abi.ml +++ b/src/ctypes-foreign/config/gen_libffi_abi.ml @@ -5,7 +5,9 @@ * See the file LICENSE for details. *) -let header ="\ +module C = Configurator.V1 + +let header = "\ (* * Copyright (c) 2014 Jeremy Yallop. * @@ -15,6 +17,8 @@ let header ="\ (* Support for various ABIs *) +[@@@warning \"-37\"] + type abi = Code of int | Unsupported of string let abi_code = function @@ -23,6 +27,14 @@ let abi_code = function " +let ffi_is_defined = Printf.sprintf "\ +#include +int main(int argc, char **argv) { + int s = %s; + return 0; +} +" + let symbols = [ ("aix" , "FFI_AIX"); ("darwin" , "FFI_DARWIN"); @@ -53,17 +65,34 @@ let symbols = [ ("default_abi" , "FFI_DEFAULT_ABI"); ] -let extra_headers = "#include " +let includes = ["ffi.h"] +module CD = C.C_define + +let find_defined_symbols c c_flags = + List.fold_left (fun acc (_,sym) -> + if C.c_test c ~c_flags (ffi_is_defined sym) then + sym :: acc + else acc) [] symbols + +let get_symbol c c_flags symbol = + match CD.(import c ~includes ~c_flags [symbol,Type.Int]) with + |[_,CD.Value.Int i] -> i + |_ -> failwith (Printf.sprintf "unexpected error parsing ffi.h: is %s not an integer?" symbol) -let write_line name symbol = - try - Printf.printf "let %s = Code %d\n" name (Extract_from_c.integer ~extra_headers symbol) - with Not_found -> +let write_line c ~c_flags ~defined_symbols ~name ~symbol = + if List.mem symbol defined_symbols then + get_symbol c c_flags symbol |> + Printf.printf "let %s = Code %d\n" name + else Printf.printf "let %s = Unsupported \"%s\"\n" name symbol let () = - begin + let c_flags = ref "" in + let args = ["-cflags", Arg.Set_string c_flags, "CFLAGS for libffi"] in + C.main ~args ~name:"ctypes-ffi" (fun c -> + let c_flags = match !c_flags with "" -> [] | c -> [c] in + let defined_symbols = find_defined_symbols c c_flags in print_string header; - List.iter (fun (name, symbol) -> write_line name symbol) symbols - end + List.iter (fun (name, symbol) -> write_line c ~c_flags ~defined_symbols ~name ~symbol) symbols + ) diff --git a/src/ctypes-foreign/ctypes_ffi.ml b/src/ctypes-foreign/ctypes_ffi.ml index 23d05f00f..f7840873f 100644 --- a/src/ctypes-foreign/ctypes_ffi.ml +++ b/src/ctypes-foreign/ctypes_ffi.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9-27"] + module type CLOSURE_PROPERTIES = sig val record : Obj.t -> Obj.t -> int diff --git a/src/ctypes-foreign/dl.ml.unix b/src/ctypes-foreign/dl.ml.unix index 9a9add321..4a10985ed 100644 --- a/src/ctypes-foreign/dl.ml.unix +++ b/src/ctypes-foreign/dl.ml.unix @@ -50,6 +50,7 @@ let _report_dl_error noload = let crush_flags f : 'a list -> int = List.fold_left (fun i o -> i lor (f o)) 0 +[@@@warning "-16"] let dlopen ?filename ~flags = match _dlopen ?filename ~flags:(crush_flags resolve_flag flags) with | Some library -> library diff --git a/src/ctypes-foreign/dl.ml.win b/src/ctypes-foreign/dl.ml.win index 0b747286f..ab21d7790 100644 --- a/src/ctypes-foreign/dl.ml.win +++ b/src/ctypes-foreign/dl.ml.win @@ -3,7 +3,7 @@ * See the file LICENSE for details. *) -[@@@ocaml.warning "-16"] +[@@@ocaml.warning "-16-37"] type library @@ -84,7 +84,7 @@ let dlopen ?filename ~flags = else x in - let ls = String.lowercase s in + let ls = String.lowercase_ascii s in let s' = if Filename.check_suffix ls ".so" || Filename.check_suffix ls ".dylib" diff --git a/src/ctypes-foreign/dune b/src/ctypes-foreign/dune new file mode 100644 index 000000000..0b5938e84 --- /dev/null +++ b/src/ctypes-foreign/dune @@ -0,0 +1,33 @@ +(rule + (copy# "dl_stubs.c.%{read-lines:backend.sexp}" dl_stubs.c)) + +(rule + (copy# "dl.ml.%{read-lines:backend.sexp}" dl.ml)) + +(rule + (with-stdout-to + libffi_abi.ml + (run ./config/gen_libffi_abi.exe -cflags "%{read-lines:c_flags}"))) + +(library + (name ctypes_foreign) + (public_name ctypes-foreign) + (instrumentation + (backend bisect_ppx)) + (wrapped false) + (private_modules ctypes_foreign_threaded_stubs) + (libraries ctypes threads) + (c_library_flags + :standard + (:include c_library_flags.sexp)) + (foreign_stubs + (language c) + (names dl_stubs ffi_call_stubs ffi_type_stubs foreign_threaded_stubs) + (flags + :standard + (:include c_flags.sexp)))) + +(rule + (targets c_flags c_flags.sexp c_library_flags.sexp backend.sexp) + (action + (run ./config/discover.exe))) diff --git a/src/ctypes-top/dune b/src/ctypes-top/dune new file mode 100644 index 000000000..5c85dce6f --- /dev/null +++ b/src/ctypes-top/dune @@ -0,0 +1,6 @@ +;; see https://github.com/ocaml/dune/issues/688 + +(library + (name ctypes_top) + (public_name ctypes.top) + (libraries ctypes compiler-libs)) diff --git a/src/ctypes/ctypes.mli b/src/ctypes/ctypes.mli index a291c0cc3..9d9b4e6a2 100644 --- a/src/ctypes/ctypes.mli +++ b/src/ctypes/ctypes.mli @@ -477,10 +477,9 @@ val coerce_fn : 'a fn -> 'b fn -> 'a -> 'b coercions. *) -(** {2 binding interfaces}. -*) +(** {2 binding interfaces} -(** Foreign function binding interface. + Foreign function binding interface. The {!Foreign} and {!Cstubs} modules provide concrete implementations. *) module type FOREIGN = diff --git a/src/ctypes/ctypes_coerce.ml b/src/ctypes/ctypes_coerce.ml index a0709bc5b..eccd47422 100644 --- a/src/ctypes/ctypes_coerce.ml +++ b/src/ctypes/ctypes_coerce.ml @@ -7,6 +7,8 @@ (* Coercions *) +[@@@warning "-27"] + open Ctypes_static type uncoercible_info = diff --git a/src/ctypes/ctypes_memory.ml b/src/ctypes/ctypes_memory.ml index 93547097b..5fbd299da 100644 --- a/src/ctypes/ctypes_memory.ml +++ b/src/ctypes/ctypes_memory.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9-27"] + open Ctypes_static module Stubs = Ctypes_memory_stubs diff --git a/src/ctypes/ctypes_ptr.ml b/src/ctypes/ctypes_ptr.ml index cbf021915..c0d8de382 100644 --- a/src/ctypes/ctypes_ptr.ml +++ b/src/ctypes/ctypes_ptr.ml @@ -7,6 +7,8 @@ (* Boxed pointers to C memory locations . *) +[@@@warning "-9"] + module Raw = struct include Nativeint diff --git a/src/ctypes/ctypes_static.ml b/src/ctypes/ctypes_static.ml index f54da467c..53d254d16 100644 --- a/src/ctypes/ctypes_static.ml +++ b/src/ctypes/ctypes_static.ml @@ -7,6 +7,8 @@ (* C type construction *) +[@@@warning "-9"] + exception IncompleteType exception ModifyingSealedType of string exception Unsupported of string diff --git a/src/ctypes/ctypes_std_views.ml b/src/ctypes/ctypes_std_views.ml index d57a5715d..8a7a8f1ae 100644 --- a/src/ctypes/ctypes_std_views.ml +++ b/src/ctypes/ctypes_std_views.ml @@ -74,7 +74,7 @@ let signed_typedef name ~size : (module Signed_type) = let t = Ctypes_static.(typedef int32_t name) end) | 8 -> (module struct include Signed.Int64 let t = Ctypes_static.(typedef int64_t name) end) - | n -> Printf.kprintf failwith "size %d not supported for %s\n" n name + | n -> Printf.ksprintf failwith "size %d not supported for %s\n" n name let unsigned_typedef name ~size : (module Unsigned_type) = match size with @@ -86,7 +86,7 @@ let unsigned_typedef name ~size : (module Unsigned_type) = let t = Ctypes_static.(typedef uint32_t name) end) | 8 -> (module struct include Unsigned.UInt64 let t = Ctypes_static.(typedef uint64_t name) end) - | n -> Printf.kprintf failwith "size %d not supported for %s\n" n name + | n -> Printf.ksprintf failwith "size %d not supported for %s\n" n name module Intptr = (val signed_typedef "intptr_t" ~size:(Ctypes_std_view_stubs.intptr_t_size ())) diff --git a/src/ctypes/ctypes_structs_computed.ml b/src/ctypes/ctypes_structs_computed.ml index b2f13f1d1..aa37fea31 100644 --- a/src/ctypes/ctypes_structs_computed.ml +++ b/src/ctypes/ctypes_structs_computed.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9"] + open Ctypes_static let max_field_alignment fields = diff --git a/src/ctypes/ctypes_type_printing.ml b/src/ctypes/ctypes_type_printing.ml index 48820d809..b21c08863 100644 --- a/src/ctypes/ctypes_type_printing.ml +++ b/src/ctypes/ctypes_type_printing.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9-27"] + open Ctypes_static (* See type_printing.mli for the documentation of [format context]. *) diff --git a/src/ctypes/ctypes_value_printing.ml b/src/ctypes/ctypes_value_printing.ml index 9084c2c43..550814c66 100644 --- a/src/ctypes/ctypes_value_printing.ml +++ b/src/ctypes/ctypes_value_printing.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-9-27"] + open Ctypes_static open Ctypes_memory diff --git a/src/ctypes/dune b/src/ctypes/dune new file mode 100644 index 000000000..2ff9eae89 --- /dev/null +++ b/src/ctypes/dune @@ -0,0 +1,42 @@ +(rule + (with-stdout-to + ctypes_primitives.ml + (run ../configure/gen_c_primitives.exe))) + +(rule + (deps + (:header %{lib:integers:ocaml_integers.h})) + (target ocaml_integers.h) + (action + (copy %{header} %{target}))) + +(library + (name ctypes) + (public_name ctypes) + (wrapped false) + (libraries integers bigarray-compat) + (modules_without_implementation ctypes_types) + (instrumentation + (backend bisect_ppx)) + (install_c_headers + ctypes_raw_pointer + ctypes_primitives + ctypes_cstubs_internals + ctypes_managed_buffer_stubs + ctypes_complex_compatibility + cstubs_internals + ctypes_ldouble_stubs + ctypes_complex_stubs + ctypes_type_info_stubs + ocaml_integers) + (foreign_stubs + (language c) + (names + complex_stubs + ctypes_bigarrays + ctypes_roots + ldouble_stubs + managed_buffer_stubs + posix_types_stubs + raw_pointer_stubs + type_info_stubs))) diff --git a/src/ctypes/lDouble.ml b/src/ctypes/lDouble.ml index ff0520c7d..521b7fe78 100644 --- a/src/ctypes/lDouble.ml +++ b/src/ctypes/lDouble.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-3"] + external init : unit -> unit = "ldouble_init" let () = init () diff --git a/src/discover/commands.ml b/src/discover/commands.ml deleted file mode 100644 index aab4a8089..000000000 --- a/src/discover/commands.ml +++ /dev/null @@ -1,81 +0,0 @@ -(* - * Copyright (c) 2014 Jeremy Yallop. - * - * This file is distributed under the terms of the MIT License. - * See the file LICENSE for details. - *) - -let unwind_protect ~cleanup f x = - let rv = try f x - with exn -> - begin - cleanup x; - raise exn - end - in - begin - cleanup x; - rv - end - -let with_open_output_file ~filename f = - unwind_protect ~cleanup:close_out f (open_out filename) - -let with_open_input_file ~filename f = - unwind_protect ~cleanup:close_in f (open_in filename) - -let file_contents ~filename : string = - Bytes.to_string - (with_open_input_file ~filename - (fun file -> - let () = set_binary_mode_in file true in - let size = in_channel_length file in - let buf = Bytes.create size in - let () = really_input file buf 0 size in - buf)) - -type command_output = { - status: int; - stdout: string; - stderr: string; -} - -let temp_dir = "." - -(* The use of [unixify] below is not ideal: it's a workaround for the Windows - build, which uses a mixture of Windows- and Unix-style paths due to using MinGW - to compile OCaml and Bash for the shell. -*) -let unixify = Str.(global_replace (regexp "\\\\") "/") - -let shell_command_results command = - let stdout_filename = Filename.temp_file ~temp_dir "ctypes_config" ".stdout" in - let stderr_filename = Filename.temp_file ~temp_dir "ctypes_config" ".stderr" in - unwind_protect - (fun () -> - let full_command = - Printf.sprintf "(%s) > %s 2> %s" command - (unixify stdout_filename) - (unixify stderr_filename) - in - let status = Sys.command full_command in - let stdout = file_contents ~filename:stdout_filename in - let stderr = file_contents ~filename:stderr_filename in - { status; stdout; stderr } - ) () - ~cleanup:begin fun () -> - Sys.remove stdout_filename; - Sys.remove stderr_filename; - end - - -let command fmt = - Printf.ksprintf shell_command_results fmt - -let command_output' command = - (shell_command_results command).stdout - -let command_succeeds' command = (shell_command_results command).status = 0 - -let command_succeeds fmt = - Printf.ksprintf command_succeeds' fmt diff --git a/src/discover/commands.mli b/src/discover/commands.mli deleted file mode 100644 index ba25c69d7..000000000 --- a/src/discover/commands.mli +++ /dev/null @@ -1,21 +0,0 @@ -(* - * Copyright (c) 2014 Jeremy Yallop. - * - * This file is distributed under the terms of the MIT License. - * See the file LICENSE for details. - *) - -val unwind_protect : cleanup:('a -> unit) -> ('a -> 'b) -> 'a -> 'b -val with_open_output_file : filename:string -> (out_channel -> 'a) -> 'a - -val file_contents : filename:string -> string - -type command_output = { - status: int; - stdout: string; - stderr: string; -} - -val command : ('a, unit, string, command_output) format4 -> 'a - -val command_succeeds : ('a, unit, string, bool) format4 -> 'a diff --git a/src/discover/determine_as_needed_flags.sh b/src/discover/determine_as_needed_flags.sh deleted file mode 100755 index f10346a21..000000000 --- a/src/discover/determine_as_needed_flags.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -touch as_needed_test.ml -if ocamlopt -shared -cclib -Wl,--no-as-needed as_needed_test.ml -o as_needed_test.cmxs 2>/dev/null -then - echo 'as_needed_flags=-Wl,--no-as-needed' -else - echo 'as_needed_flags=' -fi -rm as_needed_test.* diff --git a/src/discover/discover.ml b/src/discover/discover.ml deleted file mode 100644 index 35c542443..000000000 --- a/src/discover/discover.ml +++ /dev/null @@ -1,284 +0,0 @@ -(* Copyright (C) 2015 Jeremy Yallop - * Copyright (C) 2012 Anil Madhavapeddy - * Copyright (C) 2010 Jérémie Dimino - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, with linking exceptions; - * either version 2.1 of the License, or (at your option) any later - * version. See COPYING file for details. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - *) - -(* Discover available features *) - -open Printf - -(* +-----------------------------------------------------------------+ - | Search path | - +-----------------------------------------------------------------+ *) - -(* List of search paths for header files, mostly for MacOS - users. libffi is installed by port systems into non-standard - locations by default on MacOS. - - We use a hardcorded list of path + the ones from C_INCLUDE_PATH and - LIBRARY_PATH. -*) - -let search_paths = - List.map (fun dir -> (dir ^ "/include", dir ^ "/lib")) [ - "/usr"; - "/usr/local"; - "/opt"; - "/opt/local"; - "/sw"; - "/mingw"; - ] - -let is_win = Sys.os_type = "Win32" - -let path_sep = if is_win then ";" else ":" - -let split_path = Str.(split (regexp (path_sep ^ "+"))) - -let ( // ) = Filename.concat - -(** See the comment in commands.ml *) -let unixify = Str.(global_replace (regexp "\\") "/") - -(* +-----------------------------------------------------------------+ - | Test codes | - +-----------------------------------------------------------------+ *) - -let libffi_caml_code = " -external test : unit -> unit = \"ffi_test\" -let () = test () -" - -let libffi_stub_code = " -#include -#include - -CAMLprim value ffi_test() -{ - ffi_prep_closure(NULL, NULL, NULL, NULL); - return Val_unit; -} -" - -(* +-----------------------------------------------------------------+ - | Compilation | - +-----------------------------------------------------------------+ *) - -let ocamlc = ref "ocamlc" -let ext_obj = ref ".o" -let exec_name = ref "a.out" -let os_type = ref "Unix" -let ccomp_type = ref "cc" -let ffi_dir = ref "" -let is_homebrew = ref false -let is_macports = ref false -let homebrew_prefix = ref "/usr/local" -let macports_prefix = ref "/opt/local" - -(* Search for a header file in standard directories. *) -let search_header header = - let rec loop = function - | [] -> - None - | (dir_include, dir_lib) :: dirs -> - if Sys.file_exists (dir_include // header) then - Some (dir_include, dir_lib) - else - loop dirs - in - loop search_paths - -let silent_remove filename = - try Sys.remove filename - with exn -> () - -let test_code opt lib stub_code caml_code = - let open Commands in - let stem f = Filename.(chop_extension (basename f)) in - let stub_filename = unixify (Filename.temp_file "ctypes_libffi" ".c") in - let caml_filename = unixify (Filename.temp_file "ctypes_libffi" ".ml") in - with_open_output_file ~filename:stub_filename begin fun stubfd -> - with_open_output_file ~filename:caml_filename begin fun camlfd -> - unwind_protect (fun () -> - output_string stubfd stub_code; - output_string camlfd caml_code; - Commands.command_succeeds - "%s -custom %s %s %s %s 1>&2" - !ocamlc - (String.concat " " (List.map (sprintf "-ccopt %s") opt)) - (unixify (Filename.quote stub_filename)) - (unixify (Filename.quote caml_filename)) - (String.concat " " (List.map (sprintf "-cclib %s") lib))) () - ~cleanup:begin fun () -> - let caml_stem = unixify (stem caml_filename) in - silent_remove (unixify (stem stub_filename ^ !ext_obj)); - silent_remove !exec_name; - silent_remove (caml_stem ^ ".cmi"); - silent_remove (caml_stem ^ ".cmo"); - end - end - end - -let test_feature name test = - begin - fprintf stderr "testing for %s:%!" name; - if test () then begin - fprintf stderr " %s available\n%!" (String.make (34 - String.length name) '.'); - true - end else begin - fprintf stderr " %s unavailable\n%!" (String.make (34 - String.length name) '.'); - false - end - end - -(* +-----------------------------------------------------------------+ - | pkg-config | - +-----------------------------------------------------------------+ *) - -let split = Str.(split (regexp " +")) - -let brew_libffi_version flags = - match Commands.command "brew ls libffi --versions | awk '{print $NF}'" with - { Commands.status; stderr } when status <> 0 -> - ksprintf failwith "brew ls libffi failed: %s" stderr - | { Commands.stdout = "" } -> - failwith "You need to 'brew install libffi' to get a suitably up-to-date version" - | { Commands.stdout } -> - String.trim stdout - -let pkg_config flags = - let output = - if !is_homebrew then - Commands.command - "env PKG_CONFIG_PATH=%s/Cellar/libffi/%s/lib/pkgconfig %s/bin/pkg-config %s" - !homebrew_prefix (brew_libffi_version ()) !homebrew_prefix flags - else - Commands.command "pkg-config %s" flags - in - match output with - { Commands.status } when status <> 0 -> None - | { Commands.stdout } -> Some (split (String.trim stdout)) - -let pkg_config_flags name = - match (ksprintf pkg_config "--cflags %s" name, - ksprintf pkg_config "--libs %s" name) with - Some opt, Some lib -> Some (opt, lib) - | _ -> None - -let get_homebrew_prefix () = - match Commands.command "brew --prefix" with - { Commands.status } when status <> 0 -> raise Exit - | { Commands.stdout } -> String.trim stdout - -let search_libffi_header () = - match search_header "ffi.h" with - | Some (dir_i, dir_l) -> - (["-I" ^ dir_i], ["-L" ^ dir_l; "-lffi"]) - | None -> - ([], ["-lffi"]) - -let test_libffi setup_data have_pkg_config = - let get var = try Some (split (Sys.getenv var)) with Not_found -> None in - let opt, lib = - match get "LIBFFI_CFLAGS", get "LIBFFI_LIBS" with - | Some opt, Some lib -> (opt, lib) - | envopt, envlib -> - let opt, lib = - if not have_pkg_config then - search_libffi_header () - else match pkg_config_flags "libffi" with - | Some (pkgopt, pkglib) -> (pkgopt, pkglib) - | None -> search_libffi_header () - in - match envopt, envlib, opt, lib with - | Some opt, Some lib, _ , _ - | Some opt, None , _ , lib - | None , Some lib, opt, _ - | None , None , opt, lib -> opt, lib - in - setup_data := ("libffi_opt", opt) :: ("libffi_lib", lib) :: !setup_data; - let libffi_available = test_code opt lib libffi_stub_code libffi_caml_code in - setup_data := ("libffi_available", [string_of_bool libffi_available]) :: !setup_data; - libffi_available - -(* Test for pkg-config. If we are on MacOS X, we need the latest pkg-config - * from either Homebrew or MacPorts *) -let have_pkg_config is_homebrew is_macports homebrew_prefix macports_prefix = - if is_homebrew then begin - (* Look in `brew for the right pkg-config *) - homebrew_prefix := get_homebrew_prefix (); - test_feature "pkg-config" - (fun () -> - Commands.command_succeeds "%s/bin/pkg-config --version" !homebrew_prefix) - end - else if is_macports then begin - (* Look in macports for the right pkg-config *) - test_feature "macports" - (fun () -> - Commands.command_succeeds "%s/bin/port version" !macports_prefix) - end - else begin - test_feature "pkg-config" - (fun () -> - Commands.command_succeeds "pkg-config --version") -end - -let args = [ - "-ocamlc", Arg.Set_string ocamlc, " ocamlc"; - "-ext-obj", Arg.Set_string ext_obj, " C object files extension"; - "-exec-name", Arg.Set_string exec_name, " name of the executable produced by ocamlc"; - "-ccomp-type", Arg.Set_string ccomp_type, " C compiler type"; -] - -(* +-----------------------------------------------------------------+ - | Entry point | - +-----------------------------------------------------------------+ *) - -let () = - Arg.parse args ignore "check for external C libraries and available features\noptions are:"; - - (* Test for MacOS X Homebrew. *) - is_homebrew := - test_feature "brew" - (fun () -> - let out = Commands.command "brew ls --versions" in - out.status == 0 && out.stdout <> "" - ); - - (* Test for MacOS X MacPorts. *) - is_macports := - test_feature "MacPorts" - (fun () -> - Commands.command_succeeds "port info libffi"); - - let have_pkg_config = have_pkg_config !is_homebrew !is_macports homebrew_prefix macports_prefix in - - let setup_data = ref [] in - let have_libffi = test_feature "libffi" - (fun () -> test_libffi setup_data have_pkg_config) in - - if not have_pkg_config then - fprintf stderr "Warning: the 'pkg-config' command is not available.\n"; - - if not have_libffi then - fprintf stderr "Warning: libffi is not available.\n"; - - ListLabels.iter !setup_data - ~f:(fun (name, args) -> - Printf.printf "%s=%s\n" name (String.concat " " args)) diff --git a/tests/bench-micro/.merlin b/tests/bench-micro/.merlin deleted file mode 100644 index 8c21ac1bd..000000000 --- a/tests/bench-micro/.merlin +++ /dev/null @@ -1,6 +0,0 @@ -PKG ctypes -PKG core -PKG core_bench - -S . -B . diff --git a/tests/clib/dune b/tests/clib/dune new file mode 100644 index 000000000..94878ff4d --- /dev/null +++ b/tests/clib/dune @@ -0,0 +1,25 @@ +(library + (name test_functions) + (install_c_headers test_functions) + (foreign_stubs + (language c) + (names test_functions)) + (c_library_flags -pthread) + (libraries ctypes)) + +(rule + (target clib%{ext_dll}) + (deps + (source_tree ../../src/ctypes) + test_functions.h) + (action + (run + %{cc} + -I + ../../src/ctypes + -I + %{ocaml_where} + -o + %{target} + -shared + %{dep:test_functions.c}))) diff --git a/tests/clib/test_functions.h b/tests/clib/test_functions.h index 5022e9887..cb86632b1 100644 --- a/tests/clib/test_functions.h +++ b/tests/clib/test_functions.h @@ -165,7 +165,7 @@ struct one_int { int i; }; struct one_int return_struct_by_value(void); void matrix_mul(int, int, int, double *, double *, double *); double *matrix_transpose(int, int, double *); -int (*plus_callback)(int); +extern int (*plus_callback)(int); int sum_range_with_plus_callback(int, int); typedef int callback_t(void); void register_callback(callback_t *); diff --git a/tests/config/dune b/tests/config/dune new file mode 100644 index 000000000..f2c9c2b8f --- /dev/null +++ b/tests/config/dune @@ -0,0 +1,24 @@ +(executable + (name test_config) + (libraries dune.configurator)) + +(rule + (targets test-cflags) + (deps + test_config.exe + %{lib:ctypes:cstubs_internals.h} + %{lib:ctypes:ctypes_complex_compatibility.h} + %{lib:ctypes:ctypes_complex_stubs.h} + %{lib:ctypes:ctypes_cstubs_internals.h} + %{lib:ctypes:ctypes_ldouble_stubs.h} + %{lib:ctypes:ctypes_managed_buffer_stubs.h} + %{lib:ctypes:ctypes_primitives.h} + %{lib:ctypes:ctypes_raw_pointer.h} + %{lib:ctypes:ctypes_type_info_stubs.h}) + (action + (run + %{exe:test_config.exe} + -integers-dir + %{lib:integers:ocaml_integers.h} + -ctypes-dir + %{lib:ctypes:ctypes_cstubs_internals.h}))) diff --git a/tests/config/test_config.ml b/tests/config/test_config.ml new file mode 100644 index 000000000..e8fc25820 --- /dev/null +++ b/tests/config/test_config.ml @@ -0,0 +1,13 @@ +module C = Configurator.V1 + +let () = + let ifile = ref "" in + let cfile = ref "" in + let args = [ + "-integers-dir", Arg.Set_string ifile, "location of ocaml_integers.h"; + "-ctypes-dir", Arg.Set_string cfile, "location of ctypes_cstubs_internals.h"] in + C.main ~args ~name:"ctypes-tests" (fun _c -> + let idir = ["-I";Filename.dirname !ifile] in + let cdir = ["-I";Filename.dirname !cfile] in + C.Flags.write_lines "test-cflags" (idir @ cdir) + ) diff --git a/tests/flags/dune b/tests/flags/dune new file mode 100644 index 000000000..092c1a6a2 --- /dev/null +++ b/tests/flags/dune @@ -0,0 +1,7 @@ +(rule + (with-stdout-to + link-flags.sexp + (run ./gen.exe))) + +(executable + (name gen)) diff --git a/tests/flags/gen.ml b/tests/flags/gen.ml new file mode 100644 index 000000000..1d43e7dac --- /dev/null +++ b/tests/flags/gen.ml @@ -0,0 +1,9 @@ +let () = + let ocaml_version_str = Sys.ocaml_version in + let ocaml_version = + Scanf.sscanf ocaml_version_str "%u.%u" (fun a b -> (a, b)) + in + if ocaml_version >= (4, 6) then + print_endline ":standard" + else + print_endline "(:standard -ccopt -Wl,-E)" diff --git a/tests/flags/gen.mli b/tests/flags/gen.mli new file mode 100644 index 000000000..e790aeb70 --- /dev/null +++ b/tests/flags/gen.mli @@ -0,0 +1 @@ +(* empty *) diff --git a/tests/test-alignment/dune b/tests/test-alignment/dune new file mode 100644 index 000000000..73de5bb09 --- /dev/null +++ b/tests/test-alignment/dune @@ -0,0 +1,4 @@ +(test + (package ctypes-foreign) + (name test_alignment) + (libraries ounit2 ctypes ctypes-foreign)) diff --git a/tests/test-alignment/test_alignment.ml b/tests/test-alignment/test_alignment.ml index 07f234603..4f2af6316 100644 --- a/tests/test-alignment/test_alignment.ml +++ b/tests/test-alignment/test_alignment.ml @@ -8,6 +8,7 @@ open OUnit2 open Ctypes +[@@@warning "-32-34"] (* Test some relationships between the alignment requirements of primitive types. diff --git a/tests/test-arrays/dune b/tests/test-arrays/dune new file mode 100644 index 000000000..4a1cc7c43 --- /dev/null +++ b/tests/test-arrays/dune @@ -0,0 +1,15 @@ +(test + (name test_array) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_arrays_stubs + test_arrays_bindings + tests_common + stdlib-shims)) diff --git a/tests/test-arrays/stub-generator/dune b/tests/test-arrays/stub-generator/dune new file mode 100644 index 000000000..1bf30b152 --- /dev/null +++ b/tests/test-arrays/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_arrays_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_arrays_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-arrays/stubs/dune b/tests/test-arrays/stubs/dune new file mode 100644 index 000000000..ca8cbfc1a --- /dev/null +++ b/tests/test-arrays/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_arrays_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-arrays/test_array.ml b/tests/test-arrays/test_array.ml index 71de2ca25..620cff9cf 100644 --- a/tests/test-arrays/test_array.ml +++ b/tests/test-arrays/test_array.ml @@ -9,9 +9,7 @@ open OUnit2 module Float_ = struct let float = float end (*has to be above the module Ctypes*) open Ctypes - -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) - +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) (* Creating multidimensional arrays, and reading and writing elements. diff --git a/tests/test-bigarrays/dune b/tests/test-bigarrays/dune new file mode 100644 index 000000000..ca3417d29 --- /dev/null +++ b/tests/test-bigarrays/dune @@ -0,0 +1,14 @@ +(test + (name test_bigarrays) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_bigarrays_stubs + test_bigarrays_bindings + tests_common)) diff --git a/tests/test-bigarrays/stub-generator/dune b/tests/test-bigarrays/stub-generator/dune new file mode 100644 index 000000000..771db92cc --- /dev/null +++ b/tests/test-bigarrays/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_bigarrays_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_bigarrays_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-bigarrays/stubs/dune b/tests/test-bigarrays/stubs/dune new file mode 100644 index 000000000..9bb34b703 --- /dev/null +++ b/tests/test-bigarrays/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_bigarrays_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-bigarrays/stubs/functions.ml b/tests/test-bigarrays/stubs/functions.ml index edf03cb09..e07298cbc 100644 --- a/tests/test-bigarrays/stubs/functions.ml +++ b/tests/test-bigarrays/stubs/functions.ml @@ -8,7 +8,6 @@ (* Foreign function bindings for the bigarrays tests. *) open Ctypes -open Tests_common module Stubs (F: Ctypes.FOREIGN) = struct diff --git a/tests/test-bigarrays/test_bigarrays.ml b/tests/test-bigarrays/test_bigarrays.ml index 1ec923b76..fd047467f 100644 --- a/tests/test-bigarrays/test_bigarrays.ml +++ b/tests/test-bigarrays/test_bigarrays.ml @@ -8,6 +8,8 @@ module Std_array = Array type 'a std_array = 'a array +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) + open OUnit2 open Ctypes module BA = Bigarray_compat diff --git a/tests/test-bools/dune b/tests/test-bools/dune new file mode 100644 index 000000000..73476b889 --- /dev/null +++ b/tests/test-bools/dune @@ -0,0 +1,14 @@ +(test + (name test_bools) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_bools_stubs + test_bools_bindings + tests_common)) diff --git a/tests/test-bools/stub-generator/dune b/tests/test-bools/stub-generator/dune new file mode 100644 index 000000000..222152c48 --- /dev/null +++ b/tests/test-bools/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_bools_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_bools_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-bools/stubs/dune b/tests/test-bools/stubs/dune new file mode 100644 index 000000000..366c8b72c --- /dev/null +++ b/tests/test-bools/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_bools_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-bools/test_bools.ml b/tests/test-bools/test_bools.ml index 8b5bae256..453d2be94 100644 --- a/tests/test-bools/test_bools.ml +++ b/tests/test-bools/test_bools.ml @@ -6,14 +6,13 @@ *) open OUnit2 -open Ctypes +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = struct module M = Functions.Common(S) - open M (* Test passing bool values. diff --git a/tests/test-builtins/dune b/tests/test-builtins/dune new file mode 100644 index 000000000..b9940d434 --- /dev/null +++ b/tests/test-builtins/dune @@ -0,0 +1,11 @@ +(test + (name test_builtins) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_builtins_stubs + test_builtins_bindings + tests_common)) diff --git a/tests/test-builtins/stub-generator/dune b/tests/test-builtins/stub-generator/dune new file mode 100644 index 000000000..f9a6e83c1 --- /dev/null +++ b/tests/test-builtins/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_builtins_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_builtins_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-builtins/stubs/dune b/tests/test-builtins/stubs/dune new file mode 100644 index 000000000..22ac1bee9 --- /dev/null +++ b/tests/test-builtins/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_builtins_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-callback_lifetime/dune b/tests/test-callback_lifetime/dune new file mode 100644 index 000000000..516f955b4 --- /dev/null +++ b/tests/test-callback_lifetime/dune @@ -0,0 +1,14 @@ +(test + (name test_callback_lifetime) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_callback_lifetimes_stubs + test_callback_lifetimes_bindings + tests_common)) diff --git a/tests/test-callback_lifetime/stub-generator/dune b/tests/test-callback_lifetime/stub-generator/dune new file mode 100644 index 000000000..26b52078c --- /dev/null +++ b/tests/test-callback_lifetime/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_callback_lifetimes_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_callback_lifetimes_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-callback_lifetime/stubs/dune b/tests/test-callback_lifetime/stubs/dune new file mode 100644 index 000000000..bdc2ec495 --- /dev/null +++ b/tests/test-callback_lifetime/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_callback_lifetimes_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-callback_lifetime/test_callback_lifetime.ml b/tests/test-callback_lifetime/test_callback_lifetime.ml index 1af4a996c..6ccecf7d7 100644 --- a/tests/test-callback_lifetime/test_callback_lifetime.ml +++ b/tests/test-callback_lifetime/test_callback_lifetime.ml @@ -5,10 +5,12 @@ * See the file LICENSE for details. *) +[@@@warning "-9"] + open OUnit2 -open Ctypes open Foreign +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-closure-type-promotion/dune b/tests/test-closure-type-promotion/dune new file mode 100644 index 000000000..40698713c --- /dev/null +++ b/tests/test-closure-type-promotion/dune @@ -0,0 +1,14 @@ +(test + (name test_closure_type_promotion) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_closure_type_promotions_stubs + test_closure_type_promotions_bindings + tests_common)) diff --git a/tests/test-closure-type-promotion/stub-generator/dune b/tests/test-closure-type-promotion/stub-generator/dune new file mode 100644 index 000000000..c837892e2 --- /dev/null +++ b/tests/test-closure-type-promotion/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_closure_type_promotions_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_closure_type_promotions_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-closure-type-promotion/stubs/dune b/tests/test-closure-type-promotion/stubs/dune new file mode 100644 index 000000000..74757c4e2 --- /dev/null +++ b/tests/test-closure-type-promotion/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_closure_type_promotions_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-closure-type-promotion/test_closure_type_promotion.ml b/tests/test-closure-type-promotion/test_closure_type_promotion.ml index be3d96034..5936d6dee 100644 --- a/tests/test-closure-type-promotion/test_closure_type_promotion.ml +++ b/tests/test-closure-type-promotion/test_closure_type_promotion.ml @@ -3,9 +3,9 @@ * See the file LICENSE for details. *) -open Ctypes open OUnit2 -open Foreign + +let _testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) (* * Using the closure API of libffi is error prone due to differences diff --git a/tests/test-coercions/dune b/tests/test-coercions/dune new file mode 100644 index 000000000..0c3765d3d --- /dev/null +++ b/tests/test-coercions/dune @@ -0,0 +1,11 @@ +(test + (name test_coercions) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_coercionss_stubs + test_coercionss_bindings + tests_common)) diff --git a/tests/test-coercions/stub-generator/dune b/tests/test-coercions/stub-generator/dune new file mode 100644 index 000000000..a2f547217 --- /dev/null +++ b/tests/test-coercions/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_coercionss_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_coercionss_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-coercions/stubs/dune b/tests/test-coercions/stubs/dune new file mode 100644 index 000000000..5e2df7e29 --- /dev/null +++ b/tests/test-coercions/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_coercionss_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-coercions/test_coercions.ml b/tests/test-coercions/test_coercions.ml index d8eeffb80..ea61867dc 100644 --- a/tests/test-coercions/test_coercions.ml +++ b/tests/test-coercions/test_coercions.ml @@ -38,7 +38,7 @@ let test_pointer_coercions _ = ~f:(fun (T t1) -> ListLabels.iter types ~f:(fun (T t2) -> - let _ = coerce (ptr t1) (ptr t2) in ())) + let _fn = coerce (ptr t1) (ptr t2) in ())) (* Check that pointer coercions are value-preserving. *) let v = 10 @@ -57,7 +57,7 @@ let test_struct_first_member_coercions _ = let module M = struct let s = structure "s" let f = field s "f" double - let i = field s "i" int + let _i = field s "i" int let () = seal s let () = begin @@ -166,7 +166,7 @@ end Check that identity coercions are cost-free. *) let test_identity_coercions _ = - let f = fun x y -> x in + let f = fun x _y -> x in let fn = int @-> float @-> returning int in let f' = coerce_fn fn fn f in assert_bool "identity coercions are free" (f' == f) diff --git a/tests/test-complex/dune b/tests/test-complex/dune new file mode 100644 index 000000000..552f09e77 --- /dev/null +++ b/tests/test-complex/dune @@ -0,0 +1,14 @@ +(test + (name test_complex) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_complexs_stubs + test_complexs_bindings + tests_common)) diff --git a/tests/test-complex/stub-generator/dune b/tests/test-complex/stub-generator/dune new file mode 100644 index 000000000..7b32ee99d --- /dev/null +++ b/tests/test-complex/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_complexs_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_complexs_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-complex/stubs/dune b/tests/test-complex/stubs/dune new file mode 100644 index 000000000..702ada5e7 --- /dev/null +++ b/tests/test-complex/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_complexs_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-complex/test_complex.ml b/tests/test-complex/test_complex.ml index 4819d0cd9..c8d993fd2 100644 --- a/tests/test-complex/test_complex.ml +++ b/tests/test-complex/test_complex.ml @@ -8,9 +8,7 @@ open OUnit2 open Ctypes - -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) - +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-constants/dune b/tests/test-constants/dune new file mode 100644 index 000000000..fc5d77c89 --- /dev/null +++ b/tests/test-constants/dune @@ -0,0 +1,64 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_constants_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions)) + +(test + (name test_constants) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (modules test_constants) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_constants_stubs + test_functions + test_constants_bindings + tests_common)) diff --git a/tests/test-constants/stub-generator/dune b/tests/test-constants/stub-generator/dune new file mode 100644 index 000000000..6d37c6f78 --- /dev/null +++ b/tests/test-constants/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_constants_stubs tests_common)) diff --git a/tests/test-constants/stubs/dune b/tests/test-constants/stubs/dune new file mode 100644 index 000000000..ddbc20ae6 --- /dev/null +++ b/tests/test-constants/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_constants_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-constants/stubs/types.ml b/tests/test-constants/stubs/types.ml index 333fb61f2..c92cb2147 100644 --- a/tests/test-constants/stubs/types.ml +++ b/tests/test-constants/stubs/types.ml @@ -5,8 +5,6 @@ * See the file LICENSE for details. *) -open Ctypes - module Struct_stubs(S : Ctypes.TYPE) = struct open S diff --git a/tests/test-constants/test_constants.ml b/tests/test-constants/test_constants.ml index eeac8aea0..c9e1bf92e 100644 --- a/tests/test-constants/test_constants.ml +++ b/tests/test-constants/test_constants.ml @@ -9,8 +9,7 @@ open OUnit2 open Ctypes -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) - +let testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Constants = Types.Struct_stubs(Generated_struct_bindings) diff --git a/tests/test-cstdlib/dune b/tests/test-cstdlib/dune new file mode 100644 index 000000000..88d6bc844 --- /dev/null +++ b/tests/test-cstdlib/dune @@ -0,0 +1,12 @@ +(test + (name test_cstdlib) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_cstdlib_stubs + test_cstdlib_bindings + tests_common + stdlib-shims)) diff --git a/tests/test-cstdlib/stub-generator/dune b/tests/test-cstdlib/stub-generator/dune new file mode 100644 index 000000000..62ce849a4 --- /dev/null +++ b/tests/test-cstdlib/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_cstdlib_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_cstdlib_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-cstdlib/stubs/dune b/tests/test-cstdlib/stubs/dune new file mode 100644 index 000000000..99a2b8b00 --- /dev/null +++ b/tests/test-cstdlib/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_cstdlib_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-cstdlib/test_cstdlib.ml b/tests/test-cstdlib/test_cstdlib.ml index 85442918b..14f6ae687 100644 --- a/tests/test-cstdlib/test_cstdlib.ml +++ b/tests/test-cstdlib/test_cstdlib.ml @@ -95,7 +95,7 @@ struct assert_bool "memcmp(&10, &20) < 0" (memcmp (to_voidp p1) (to_voidp p2) (Size_t.of_int (sizeof int)) < 0); - let p = allocate_n uchar 12 in + let p = allocate_n uchar ~count:12 in let i = 44 in let u = UChar.of_int i in begin ignore (memset (to_voidp p) i (Size_t.of_int 12)); @@ -115,7 +115,6 @@ struct let sortby (type a) (typ : a typ) (f : a -> a -> int) (l : a list) = let open CArray in let open Size_t in - let open Infix in let arr = of_list typ l in let len = of_int (length arr) in let size = of_int (sizeof typ) in diff --git a/tests/test-custom_ops/dune b/tests/test-custom_ops/dune new file mode 100644 index 000000000..cae198e4d --- /dev/null +++ b/tests/test-custom_ops/dune @@ -0,0 +1,3 @@ +(test + (name test_custom_ops) + (libraries ounit2 ctypes)) diff --git a/tests/test-enums/dune b/tests/test-enums/dune new file mode 100644 index 000000000..ea4c474ce --- /dev/null +++ b/tests/test-enums/dune @@ -0,0 +1,47 @@ +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:struct-stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets struct-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(library + (name test_enums_generated) + (modules generated_bindings) + (foreign_stubs + (language c) + (names generated_stubs)) + (libraries test_functions) + (wrapped false)) + +(test + (name test_enums) + (modules test_enums) + (package ctypes-foreign) + (libraries ounit2 ctypes test_enums_generated test_enums_stubs)) diff --git a/tests/test-enums/struct-stub-generator/dune b/tests/test-enums/struct-stub-generator/dune new file mode 100644 index 000000000..fd1637f9d --- /dev/null +++ b/tests/test-enums/struct-stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_enums_struct_stubs tests_common)) diff --git a/tests/test-enums/struct-stubs/dune b/tests/test-enums/struct-stubs/dune new file mode 100644 index 000000000..a2f586378 --- /dev/null +++ b/tests/test-enums/struct-stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_enums_struct_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-enums/stub-generator/dune b/tests/test-enums/stub-generator/dune new file mode 100644 index 000000000..43a93b1c6 --- /dev/null +++ b/tests/test-enums/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_enums_stubs tests_common)) diff --git a/tests/test-enums/stubs/dune b/tests/test-enums/stubs/dune new file mode 100644 index 000000000..18a8bb2b6 --- /dev/null +++ b/tests/test-enums/stubs/dune @@ -0,0 +1,11 @@ +(library + (name test_enums_stubs) + (wrapped false) + (libraries ctypes.stubs test_enums_struct_stubs)) + +(rule + (targets generated_struct_bindings.ml) + (action + (with-stdout-to + %{targets} + (run %{exe:../struct-stub-generator.exe})))) diff --git a/tests/test-enums/test_enums.ml b/tests/test-enums/test_enums.ml index b6471e1b1..8d6ce1022 100644 --- a/tests/test-enums/test_enums.ml +++ b/tests/test-enums/test_enums.ml @@ -5,6 +5,8 @@ * See the file LICENSE for details. *) +[@@@warning "-33"] + open OUnit2 open Ctypes diff --git a/tests/test-finalisers/dune b/tests/test-finalisers/dune new file mode 100644 index 000000000..f78761258 --- /dev/null +++ b/tests/test-finalisers/dune @@ -0,0 +1,3 @@ +(test + (name test_finalisers) + (libraries ctypes ounit2)) diff --git a/tests/test-foreign-errno/dune b/tests/test-foreign-errno/dune new file mode 100644 index 000000000..409976d4f --- /dev/null +++ b/tests/test-foreign-errno/dune @@ -0,0 +1,4 @@ +(test + (name test_errno) + (package ctypes-foreign) + (libraries ounit2 ctypes ctypes-foreign)) diff --git a/tests/test-foreign_values/dune b/tests/test-foreign_values/dune new file mode 100644 index 000000000..47b35b9eb --- /dev/null +++ b/tests/test-foreign_values/dune @@ -0,0 +1,14 @@ +(test + (name test_foreign_values) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_foreign_values_stubs + test_foreign_values_bindings + tests_common)) diff --git a/tests/test-foreign_values/stub-generator/dune b/tests/test-foreign_values/stub-generator/dune new file mode 100644 index 000000000..60b41818a --- /dev/null +++ b/tests/test-foreign_values/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_foreign_values_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_foreign_values_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-foreign_values/stubs/dune b/tests/test-foreign_values/stubs/dune new file mode 100644 index 000000000..a8e78b004 --- /dev/null +++ b/tests/test-foreign_values/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_foreign_values_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-foreign_values/test_foreign_values.ml b/tests/test-foreign_values/test_foreign_values.ml index 497c0fa2f..76e478b9f 100644 --- a/tests/test-foreign_values/test_foreign_values.ml +++ b/tests/test-foreign_values/test_foreign_values.ml @@ -8,6 +8,7 @@ open OUnit2 open Ctypes +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-funptrs/dune b/tests/test-funptrs/dune new file mode 100644 index 000000000..ccfd53c69 --- /dev/null +++ b/tests/test-funptrs/dune @@ -0,0 +1,12 @@ +(test + (name test_funptrs) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes-foreign + test_funptrs_stubs + ctypes.stubs + tests_common + test_funptrs_bindings)) diff --git a/tests/test-funptrs/stub-generator/dune b/tests/test-funptrs/stub-generator/dune new file mode 100644 index 000000000..c38d3ac49 --- /dev/null +++ b/tests/test-funptrs/stub-generator/dune @@ -0,0 +1,24 @@ +(executable + (name driver) + (modules driver) + (libraries test_funptrs_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_funptrs_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (flags :standard -w -11) + (libraries ctypes test_functions)) diff --git a/tests/test-funptrs/stubs/dune b/tests/test-funptrs/stubs/dune new file mode 100644 index 000000000..4d481a412 --- /dev/null +++ b/tests/test-funptrs/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_funptrs_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-funptrs/test_funptrs.ml b/tests/test-funptrs/test_funptrs.ml index f21355bec..631ed8285 100644 --- a/tests/test-funptrs/test_funptrs.ml +++ b/tests/test-funptrs/test_funptrs.ml @@ -7,7 +7,8 @@ open OUnit2 open Ctypes -open Foreign + +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) (* Explicitly raise on leaked funptrs. *) diff --git a/tests/test-higher_order/dune b/tests/test-higher_order/dune new file mode 100644 index 000000000..f6fb75ef7 --- /dev/null +++ b/tests/test-higher_order/dune @@ -0,0 +1,14 @@ +(test + (name test_higher_order) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_higher_order_stubs + test_higher_order_bindings + tests_common)) diff --git a/tests/test-higher_order/stub-generator/dune b/tests/test-higher_order/stub-generator/dune new file mode 100644 index 000000000..b1ebfa8c9 --- /dev/null +++ b/tests/test-higher_order/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_higher_order_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_higher_order_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-higher_order/stubs/dune b/tests/test-higher_order/stubs/dune new file mode 100644 index 000000000..2ded01ffa --- /dev/null +++ b/tests/test-higher_order/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_higher_order_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-higher_order/test_higher_order.ml b/tests/test-higher_order/test_higher_order.ml index 199e2b50a..bf9426fcc 100644 --- a/tests/test-higher_order/test_higher_order.ml +++ b/tests/test-higher_order/test_higher_order.ml @@ -5,10 +5,9 @@ * See the file LICENSE for details. *) -open Ctypes open OUnit2 -open Foreign +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-integers/dune b/tests/test-integers/dune new file mode 100644 index 000000000..ceac20403 --- /dev/null +++ b/tests/test-integers/dune @@ -0,0 +1,14 @@ +(test + (name test_integers) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_integers_stubs + test_integers_bindings + tests_common)) diff --git a/tests/test-integers/stub-generator/dune b/tests/test-integers/stub-generator/dune new file mode 100644 index 000000000..426735a42 --- /dev/null +++ b/tests/test-integers/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_integers_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_integers_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-integers/stubs/dune b/tests/test-integers/stubs/dune new file mode 100644 index 000000000..7d196f99c --- /dev/null +++ b/tests/test-integers/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_integers_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-integers/test_integers.ml b/tests/test-integers/test_integers.ml index eaff6d061..2747d1a7f 100644 --- a/tests/test-integers/test_integers.ml +++ b/tests/test-integers/test_integers.ml @@ -8,7 +8,8 @@ open OUnit2 open Ctypes open Unsigned -open Foreign + +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-ldouble/dune b/tests/test-ldouble/dune new file mode 100644 index 000000000..96ef8ddfd --- /dev/null +++ b/tests/test-ldouble/dune @@ -0,0 +1,3 @@ +(test + (name test_ldouble) + (libraries ctypes ounit2)) diff --git a/tests/test-ldouble/test_ldouble.ml b/tests/test-ldouble/test_ldouble.ml index 852ed6d3a..57b65a46b 100644 --- a/tests/test-ldouble/test_ldouble.ml +++ b/tests/test-ldouble/test_ldouble.ml @@ -6,7 +6,6 @@ *) open OUnit2 -open Ctypes let flts = [ @@ -167,7 +166,7 @@ let test_complex _ = assert_bool name (chk_complex ?prec (opc a) (to_complex (opl (of_complex a)))) ) cplx in - let assert_chkf ?prec name opc opl = + let assert_chkf name opc opl = List.iter (fun a -> let open ComplexL in assert_bool name (chk_float (opc a) (LDouble.to_float (opl (of_complex a)))) @@ -260,12 +259,14 @@ let test_comparisons _ = let test_int_conversions _ = begin - assert_equal max_int (LDouble.to_int - (LDouble.of_int max_int)) + let max_ok = 1 lsr 53 in + let min_ok = -max_ok in + assert_equal max_ok (LDouble.to_int + (LDouble.of_int max_ok)) ~printer:string_of_int; - assert_equal min_int (LDouble.to_int - (LDouble.of_int min_int)) + assert_equal min_ok (LDouble.to_int + (LDouble.of_int min_ok)) ~printer:string_of_int; end diff --git a/tests/test-lifetime/dune b/tests/test-lifetime/dune new file mode 100644 index 000000000..b91198c0b --- /dev/null +++ b/tests/test-lifetime/dune @@ -0,0 +1,14 @@ +(test + (name test_lifetime) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_lifetime_stubs + test_lifetime_bindings + tests_common)) diff --git a/tests/test-lifetime/stub-generator/dune b/tests/test-lifetime/stub-generator/dune new file mode 100644 index 000000000..f8a1d6799 --- /dev/null +++ b/tests/test-lifetime/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_lifetime_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_lifetime_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-lifetime/stubs/dune b/tests/test-lifetime/stubs/dune new file mode 100644 index 000000000..2429fac13 --- /dev/null +++ b/tests/test-lifetime/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_lifetime_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-lifetime/stubs/functions.ml b/tests/test-lifetime/stubs/functions.ml index 902a0c625..01905b31c 100644 --- a/tests/test-lifetime/stubs/functions.ml +++ b/tests/test-lifetime/stubs/functions.ml @@ -8,7 +8,6 @@ (* Foreign function bindings for the lifetime tests. *) open Ctypes -open Foreign module Stubs (F: Ctypes.FOREIGN) = struct diff --git a/tests/test-lifetime/test_lifetime.ml b/tests/test-lifetime/test_lifetime.ml index bbe11fd02..a9a70db1d 100644 --- a/tests/test-lifetime/test_lifetime.ml +++ b/tests/test-lifetime/test_lifetime.ml @@ -5,10 +5,11 @@ * See the file LICENSE for details. *) +[@@@warning "-35"] open OUnit2 open Ctypes -open Foreign +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-lwt-jobs/dune b/tests/test-lwt-jobs/dune new file mode 100644 index 000000000..b69d70c28 --- /dev/null +++ b/tests/test-lwt-jobs/dune @@ -0,0 +1,65 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_lwt_jobs_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_lwt_jobs) + (package ctypes-foreign) + (modules test_lwt_jobs) + (action + (run %{test} -runner sequential)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_lwt_jobs_stubs + test_functions + test_lwt_jobs_bindings + tests_common)) diff --git a/tests/test-lwt-jobs/stub-generator/dune b/tests/test-lwt-jobs/stub-generator/dune new file mode 100644 index 000000000..c33272e08 --- /dev/null +++ b/tests/test-lwt-jobs/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_lwt_jobs_stubs tests_common)) diff --git a/tests/test-lwt-jobs/stubs/dune b/tests/test-lwt-jobs/stubs/dune new file mode 100644 index 000000000..f22435c94 --- /dev/null +++ b/tests/test-lwt-jobs/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_lwt_jobs_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-lwt-preemptive/dune b/tests/test-lwt-preemptive/dune new file mode 100644 index 000000000..ebccf0051 --- /dev/null +++ b/tests/test-lwt-preemptive/dune @@ -0,0 +1,65 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_lwt_preemptive_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_lwt_jobs) + (modules test_lwt_jobs) + (package ctypes-foreign) + (action + (run %{test} -runner sequential)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_lwt_preemptive_stubs + test_functions + test_lwt_preemptive_bindings + tests_common)) diff --git a/tests/test-lwt-preemptive/stub-generator/dune b/tests/test-lwt-preemptive/stub-generator/dune new file mode 100644 index 000000000..4d95c642c --- /dev/null +++ b/tests/test-lwt-preemptive/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_lwt_preemptive_stubs tests_common)) diff --git a/tests/test-lwt-preemptive/stubs/dune b/tests/test-lwt-preemptive/stubs/dune new file mode 100644 index 000000000..8f0bfc161 --- /dev/null +++ b/tests/test-lwt-preemptive/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_lwt_preemptive_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-macros/dune b/tests/test-macros/dune new file mode 100644 index 000000000..e12169398 --- /dev/null +++ b/tests/test-macros/dune @@ -0,0 +1,11 @@ +(test + (name test_macros) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_macros_stubs + test_macros_bindings + tests_common)) diff --git a/tests/test-macros/stub-generator/dune b/tests/test-macros/stub-generator/dune new file mode 100644 index 000000000..83d0c88f3 --- /dev/null +++ b/tests/test-macros/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_macros_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_macros_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-macros/stubs/dune b/tests/test-macros/stubs/dune new file mode 100644 index 000000000..f307beb97 --- /dev/null +++ b/tests/test-macros/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_macros_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-macros/test_macros.ml b/tests/test-macros/test_macros.ml index 11e877619..7b0130a6a 100644 --- a/tests/test-macros/test_macros.ml +++ b/tests/test-macros/test_macros.ml @@ -6,7 +6,6 @@ *) open OUnit2 -open Ctypes module Bindings = Functions.Stubs(Generated_bindings) diff --git a/tests/test-marshal/dune b/tests/test-marshal/dune new file mode 100644 index 000000000..4f7c1e6b5 --- /dev/null +++ b/tests/test-marshal/dune @@ -0,0 +1,3 @@ +(test + (name test_marshal) + (libraries ctypes ounit2)) diff --git a/tests/test-marshal/test_marshal.ml b/tests/test-marshal/test_marshal.ml index 7ff252eb3..27a6aa077 100644 --- a/tests/test-marshal/test_marshal.ml +++ b/tests/test-marshal/test_marshal.ml @@ -6,7 +6,6 @@ *) open OUnit2 -open Ctypes open Unsigned diff --git a/tests/test-oo_style/dune b/tests/test-oo_style/dune new file mode 100644 index 000000000..49c7975bc --- /dev/null +++ b/tests/test-oo_style/dune @@ -0,0 +1,14 @@ +(test + (name test_oo_style) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_oo_style_stubs + test_oo_style_bindings + tests_common)) diff --git a/tests/test-oo_style/stub-generator/dune b/tests/test-oo_style/stub-generator/dune new file mode 100644 index 000000000..a06e7907b --- /dev/null +++ b/tests/test-oo_style/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_oo_style_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_oo_style_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-oo_style/stubs/dune b/tests/test-oo_style/stubs/dune new file mode 100644 index 000000000..437fb9baa --- /dev/null +++ b/tests/test-oo_style/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_oo_style_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-oo_style/stubs/functions.ml b/tests/test-oo_style/stubs/functions.ml index 44343311e..84ded6f6f 100644 --- a/tests/test-oo_style/stubs/functions.ml +++ b/tests/test-oo_style/stubs/functions.ml @@ -8,7 +8,6 @@ (* Foreign function bindings for the OO-style tests. *) open Ctypes -open Foreign module Stubs (F: Ctypes.FOREIGN) = struct diff --git a/tests/test-oo_style/test_oo_style.ml b/tests/test-oo_style/test_oo_style.ml index 5bc3a77de..df7d18fd8 100644 --- a/tests/test-oo_style/test_oo_style.ml +++ b/tests/test-oo_style/test_oo_style.ml @@ -8,6 +8,9 @@ open OUnit2 open Ctypes +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) + +[@@@warning "-6-27-37"] module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = @@ -75,7 +78,7 @@ struct class chorse ~colour = object - inherit animalc (new_chorse (colour_num colour)) + inherit animalc (new_chorse(colour_num colour)) end let () = diff --git a/tests/test-passable/dune b/tests/test-passable/dune new file mode 100644 index 000000000..9274a3fc9 --- /dev/null +++ b/tests/test-passable/dune @@ -0,0 +1,4 @@ +(test + (name test_passable) + (package ctypes-foreign) + (libraries ctypes ctypes.stubs ctypes-foreign ounit2)) diff --git a/tests/test-passable/test_passable.ml b/tests/test-passable/test_passable.ml index 911cffe7e..7419e63f2 100644 --- a/tests/test-passable/test_passable.ml +++ b/tests/test-passable/test_passable.ml @@ -47,9 +47,9 @@ let test_unions_are_not_passable _ = let u : u union typ = union "u" let (-:) ty label = field u label ty - let c = int -: "c" - let f = double -: "f" - let p = ptr u -: "p" + let _c = int -: "c" + let _f = double -: "f" + let _p = ptr u -: "p" let () = seal u let _ = begin diff --git a/tests/test-passing-ocaml-values/dune b/tests/test-passing-ocaml-values/dune new file mode 100644 index 000000000..52b91a1c8 --- /dev/null +++ b/tests/test-passing-ocaml-values/dune @@ -0,0 +1,11 @@ +(test + (name test_passing_ocaml_values) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_passing_ocaml_values_stubs + test_passing_ocaml_values_bindings + tests_common)) diff --git a/tests/test-passing-ocaml-values/stub-generator/dune b/tests/test-passing-ocaml-values/stub-generator/dune new file mode 100644 index 000000000..23d265b4f --- /dev/null +++ b/tests/test-passing-ocaml-values/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_passing_ocaml_values_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_passing_ocaml_values_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-passing-ocaml-values/stubs/dune b/tests/test-passing-ocaml-values/stubs/dune new file mode 100644 index 000000000..1fd469bc3 --- /dev/null +++ b/tests/test-passing-ocaml-values/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_passing_ocaml_values_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml b/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml index 37c5afd72..c15b8a8c7 100644 --- a/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml +++ b/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml @@ -9,9 +9,6 @@ open OUnit2 open Ctypes open Foreign - -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) - module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = struct @@ -100,7 +97,7 @@ let test_ocaml_types_rejected_as_return_types _ = Test that pointers to OCaml values cannot be dereferenced. *) let test_pointers_to_ocaml_types_cannot_be_dereferenced _ = - let p = allocate_n char 10 in + let p = allocate_n char ~count:10 in let po = coerce (ptr char) (ptr ocaml_string) p in begin diff --git a/tests/test-pointers/dune b/tests/test-pointers/dune new file mode 100644 index 000000000..99cc25c45 --- /dev/null +++ b/tests/test-pointers/dune @@ -0,0 +1,15 @@ +(test + (name test_pointers) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_pointers_stubs + test_pointers_bindings + tests_common + stdlib-shims)) diff --git a/tests/test-pointers/stub-generator/dune b/tests/test-pointers/stub-generator/dune new file mode 100644 index 000000000..280b0c050 --- /dev/null +++ b/tests/test-pointers/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_pointers_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_pointers_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-pointers/stubs/dune b/tests/test-pointers/stubs/dune new file mode 100644 index 000000000..68d0583a5 --- /dev/null +++ b/tests/test-pointers/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_pointers_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-pointers/test_pointers.ml b/tests/test-pointers/test_pointers.ml index 756e839a9..d9ec45d3b 100644 --- a/tests/test-pointers/test_pointers.ml +++ b/tests/test-pointers/test_pointers.ml @@ -11,8 +11,9 @@ open OUnit2 open Ctypes open Foreign +[@@@warning "-6"] -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) +let testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/test-raw/dune b/tests/test-raw/dune new file mode 100644 index 000000000..35ef1152a --- /dev/null +++ b/tests/test-raw/dune @@ -0,0 +1,4 @@ +(test + (name test_raw) + (package ctypes-foreign) + (libraries ctypes ctypes-foreign ounit2)) diff --git a/tests/test-raw/test_raw.ml b/tests/test-raw/test_raw.ml index 08164fa5b..6f1a2f9f8 100644 --- a/tests/test-raw/test_raw.ml +++ b/tests/test-raw/test_raw.ml @@ -9,7 +9,8 @@ open OUnit2 open Ctypes_memory_stubs -open Ctypes_std_view_stubs + +[@@@warning "-6-33"] (* Tests for the low-level module on which the public high-level interface is based. diff --git a/tests/test-returning-errno-lwt-jobs/dune b/tests/test-returning-errno-lwt-jobs/dune new file mode 100644 index 000000000..76b051005 --- /dev/null +++ b/tests/test-returning-errno-lwt-jobs/dune @@ -0,0 +1,65 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_returning_errno_lwt_jobs_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_returning_errno) + (package ctypes-foreign) + (modules test_returning_errno) + (action + (run %{test} -runner sequential)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_returning_errno_lwt_jobs_stubs + test_functions + test_returning_errno_lwt_jobs_bindings + tests_common)) diff --git a/tests/test-returning-errno-lwt-jobs/stub-generator/dune b/tests/test-returning-errno-lwt-jobs/stub-generator/dune new file mode 100644 index 000000000..d3cd7fae1 --- /dev/null +++ b/tests/test-returning-errno-lwt-jobs/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_returning_errno_lwt_jobs_stubs tests_common)) diff --git a/tests/test-returning-errno-lwt-jobs/stubs/dune b/tests/test-returning-errno-lwt-jobs/stubs/dune new file mode 100644 index 000000000..7bc5fdcd0 --- /dev/null +++ b/tests/test-returning-errno-lwt-jobs/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_returning_errno_lwt_jobs_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-returning-errno-lwt-jobs/test_returning_errno.ml b/tests/test-returning-errno-lwt-jobs/test_returning_errno.ml index a6fded25a..6b238af8f 100644 --- a/tests/test-returning-errno-lwt-jobs/test_returning_errno.ml +++ b/tests/test-returning-errno-lwt-jobs/test_returning_errno.ml @@ -8,6 +8,7 @@ open OUnit2 open Ctypes +[@@@warning "-27"] module Bindings = Functions.Stubs(Generated_bindings) module Constants = Types.Struct_stubs(Generated_struct_bindings) diff --git a/tests/test-returning-errno-lwt-preemptive/dune b/tests/test-returning-errno-lwt-preemptive/dune new file mode 100644 index 000000000..079456149 --- /dev/null +++ b/tests/test-returning-errno-lwt-preemptive/dune @@ -0,0 +1,65 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_returning_errno_lwt_preemptive_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_returning_errno) + (modules test_returning_errno) + (package ctypes-foreign) + (action + (run %{test} -runner sequential)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_returning_errno_lwt_preemptive_stubs + test_functions + test_returning_errno_lwt_preemptive_bindings + tests_common)) diff --git a/tests/test-returning-errno-lwt-preemptive/stub-generator/dune b/tests/test-returning-errno-lwt-preemptive/stub-generator/dune new file mode 100644 index 000000000..de502a026 --- /dev/null +++ b/tests/test-returning-errno-lwt-preemptive/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_returning_errno_lwt_preemptive_stubs tests_common)) diff --git a/tests/test-returning-errno-lwt-preemptive/stubs/dune b/tests/test-returning-errno-lwt-preemptive/stubs/dune new file mode 100644 index 000000000..195fe0591 --- /dev/null +++ b/tests/test-returning-errno-lwt-preemptive/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_returning_errno_lwt_preemptive_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-returning-errno-lwt-preemptive/test_returning_errno.ml b/tests/test-returning-errno-lwt-preemptive/test_returning_errno.ml index a6fded25a..6b238af8f 100644 --- a/tests/test-returning-errno-lwt-preemptive/test_returning_errno.ml +++ b/tests/test-returning-errno-lwt-preemptive/test_returning_errno.ml @@ -8,6 +8,7 @@ open OUnit2 open Ctypes +[@@@warning "-27"] module Bindings = Functions.Stubs(Generated_bindings) module Constants = Types.Struct_stubs(Generated_struct_bindings) diff --git a/tests/test-returning-errno/dune b/tests/test-returning-errno/dune new file mode 100644 index 000000000..21b0b0120 --- /dev/null +++ b/tests/test-returning-errno/dune @@ -0,0 +1,65 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_returning_errno_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_returning_errno) + (modules test_returning_errno) + (action + (run %{test} -runner sequential)) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_returning_errno_stubs + test_functions + test_returning_errno_bindings + tests_common)) diff --git a/tests/test-returning-errno/stub-generator/dune b/tests/test-returning-errno/stub-generator/dune new file mode 100644 index 000000000..5cb7a4a82 --- /dev/null +++ b/tests/test-returning-errno/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_returning_errno_stubs tests_common)) diff --git a/tests/test-returning-errno/stubs/dune b/tests/test-returning-errno/stubs/dune new file mode 100644 index 000000000..af5633fd0 --- /dev/null +++ b/tests/test-returning-errno/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_returning_errno_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-roots/dune b/tests/test-roots/dune new file mode 100644 index 000000000..cf4d4831a --- /dev/null +++ b/tests/test-roots/dune @@ -0,0 +1,5 @@ +(test + (name test_roots) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (libraries ctypes ctypes-foreign ounit2)) diff --git a/tests/test-roots/test_roots.ml b/tests/test-roots/test_roots.ml index 57299b5bd..698e5badb 100644 --- a/tests/test-roots/test_roots.ml +++ b/tests/test-roots/test_roots.ml @@ -10,7 +10,7 @@ open Ctypes open Foreign -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) +let testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) (* diff --git a/tests/test-sizeof/dune b/tests/test-sizeof/dune new file mode 100644 index 000000000..a0c14bd2a --- /dev/null +++ b/tests/test-sizeof/dune @@ -0,0 +1,4 @@ +(test + (name test_sizeof) + (package ctypes-foreign) + (libraries ctypes ctypes-foreign ounit2)) diff --git a/tests/test-sizeof/test_sizeof.ml b/tests/test-sizeof/test_sizeof.ml index 3eafbd184..88d02210c 100644 --- a/tests/test-sizeof/test_sizeof.ml +++ b/tests/test-sizeof/test_sizeof.ml @@ -8,6 +8,7 @@ open OUnit2 open Ctypes +[@@@warning "-27-32"] (* Test some relationships between the sizes of primitive types. @@ -106,7 +107,7 @@ let test_sizeof_structs _ = let () = for i = 1 to 10 do let homogeneous : h structure typ = structure "h" in - for j = 1 to i do + for _j = 1 to i do ignore (field homogeneous "_" int); done; seal homogeneous; diff --git a/tests/test-structs/dune b/tests/test-structs/dune new file mode 100644 index 000000000..dde44e783 --- /dev/null +++ b/tests/test-structs/dune @@ -0,0 +1,68 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_structs_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_structs) + (modules test_structs) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (action + (run %{test} -runner sequential)) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_structs_stubs + test_functions + test_structs_bindings + tests_common)) diff --git a/tests/test-structs/stub-generator/dune b/tests/test-structs/stub-generator/dune new file mode 100644 index 000000000..1c8a2adaa --- /dev/null +++ b/tests/test-structs/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_structs_stubs tests_common)) diff --git a/tests/test-structs/stubs/dune b/tests/test-structs/stubs/dune new file mode 100644 index 000000000..9cf612671 --- /dev/null +++ b/tests/test-structs/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_structs_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-structs/test_structs.ml b/tests/test-structs/test_structs.ml index 8146b2b74..ad8889a6d 100644 --- a/tests/test-structs/test_structs.ml +++ b/tests/test-structs/test_structs.ml @@ -5,11 +5,12 @@ * See the file LICENSE for details. *) +[@@@warning "-32-33-34"] open OUnit2 open Ctypes -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) +let testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) module Build_foreign_tests(S : Cstubs.FOREIGN with type 'a result = 'a diff --git a/tests/test-stubs/dune b/tests/test-stubs/dune new file mode 100644 index 000000000..fd297a845 --- /dev/null +++ b/tests/test-stubs/dune @@ -0,0 +1,4 @@ +(test + (name test_stubs) + (package ctypes-foreign) + (libraries ctypes-foreign ounit2)) diff --git a/tests/test-stubs/test_stubs.ml b/tests/test-stubs/test_stubs.ml index 07ad8781c..fcc81f97d 100644 --- a/tests/test-stubs/test_stubs.ml +++ b/tests/test-stubs/test_stubs.ml @@ -13,11 +13,11 @@ let missing = "_60d2dd04_1b66_4b79_a2ea_8375157da563" let test_missing _ = let miss = foreign missing ~stub:true (int @-> int @-> (returning int)) in - begin try ignore (miss 2 3); assert_failure "should raise" with exn -> () end; + begin try ignore (miss 2 3); assert_failure "should raise" with _exn -> () end; try let _miss = foreign missing ~stub:false (int @-> int @-> (returning int)) in assert_failure "should raise" - with exn -> () + with _exn -> () let suite = diff --git a/tests/test-threads/dune b/tests/test-threads/dune new file mode 100644 index 000000000..d44766479 --- /dev/null +++ b/tests/test-threads/dune @@ -0,0 +1,14 @@ +(test + (name test_threads) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_threads_stubs + test_threads_bindings + tests_common)) diff --git a/tests/test-threads/stub-generator/dune b/tests/test-threads/stub-generator/dune new file mode 100644 index 000000000..8c70c5d8d --- /dev/null +++ b/tests/test-threads/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_threads_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_threads_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-threads/stubs/dune b/tests/test-threads/stubs/dune new file mode 100644 index 000000000..87bc19079 --- /dev/null +++ b/tests/test-threads/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_threads_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-threads/test_threads.ml b/tests/test-threads/test_threads.ml index 2f43fc0c9..eca420341 100644 --- a/tests/test-threads/test_threads.ml +++ b/tests/test-threads/test_threads.ml @@ -5,6 +5,7 @@ * See the file LICENSE for details. *) +[@@@warning "-33-35"] open Ctypes open OUnit2 open Foreign @@ -12,7 +13,7 @@ open Foreign let () = (* temporary workaround due to flexlink limitations *) if Sys.os_type = "Win32" then - ignore (Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW])) + ignore (Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW])) let callback_with_pointers = Foreign.foreign "passing_pointers_to_callback" @@ -136,7 +137,7 @@ let test_register_thread _ = else if Hashtbl.length htl_res <> succ n_threads then false else - Hashtbl.fold ( fun k v ac -> + Hashtbl.fold ( fun _k v ac -> if v = n_callback then ac else false ) htl_res true in diff --git a/tests/test-type_printing/dune b/tests/test-type_printing/dune new file mode 100644 index 000000000..e3c6b7377 --- /dev/null +++ b/tests/test-type_printing/dune @@ -0,0 +1,63 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_type_printing_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_type_printing) + (modules test_type_printing) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_type_printing_stubs + test_functions + test_type_printing_bindings + tests_common)) diff --git a/tests/test-type_printing/stub-generator/dune b/tests/test-type_printing/stub-generator/dune new file mode 100644 index 000000000..ad47493c0 --- /dev/null +++ b/tests/test-type_printing/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_type_printing_stubs tests_common)) diff --git a/tests/test-type_printing/stubs/dune b/tests/test-type_printing/stubs/dune new file mode 100644 index 000000000..9fa191643 --- /dev/null +++ b/tests/test-type_printing/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_type_printing_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-type_printing/stubs/types.ml b/tests/test-type_printing/stubs/types.ml index 233354bb6..7e75383bd 100644 --- a/tests/test-type_printing/stubs/types.ml +++ b/tests/test-type_printing/stubs/types.ml @@ -5,8 +5,6 @@ * See the file LICENSE for details. *) -open Ctypes - module Stubs(S : Ctypes.TYPE) = struct open S diff --git a/tests/test-unions/dune b/tests/test-unions/dune new file mode 100644 index 000000000..7465ac3fd --- /dev/null +++ b/tests/test-unions/dune @@ -0,0 +1,68 @@ +(rule + (targets generated_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:stub-generator/driver.exe} --ml-file %{targets}))) + +(rule + (targets generated_struct_stubs.c) + (action + (run %{exe:stub-generator/driver.exe} --c-struct-file %{targets}))) + +(rule + (targets ml-stub-generator.exe) + (deps + generated_struct_stubs.c + ../clib/test_functions.h + ../config/test-cflags) + (action + (run + %{cc} + %{read-lines:../config/test-cflags} + -I + ../clib + -I + %{ocaml-config:standard_library} + -o + %{targets} + generated_struct_stubs.c))) + +(rule + (targets generated_struct_bindings.ml) + (deps ml-stub-generator.exe) + (action + (with-stdout-to + %{targets} + (run %{deps})))) + +(library + (name test_unions_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings generated_struct_bindings) + (libraries ctypes test_functions lwt.unix)) + +(test + (name test_unions) + (modules test_unions) + (deps ../clib/clib%{ext_dll}) + (package ctypes-foreign) + (action + (run %{test} -runner sequential)) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_unions_stubs + test_functions + test_unions_bindings + tests_common)) diff --git a/tests/test-unions/stub-generator/dune b/tests/test-unions/stub-generator/dune new file mode 100644 index 000000000..24df84d10 --- /dev/null +++ b/tests/test-unions/stub-generator/dune @@ -0,0 +1,4 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_unions_stubs tests_common)) diff --git a/tests/test-unions/stubs/dune b/tests/test-unions/stubs/dune new file mode 100644 index 000000000..3803659a4 --- /dev/null +++ b/tests/test-unions/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_unions_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-unions/test_unions.ml b/tests/test-unions/test_unions.ml index 6d66ab725..54de9a780 100644 --- a/tests/test-unions/test_unions.ml +++ b/tests/test-unions/test_unions.ml @@ -10,7 +10,7 @@ open Ctypes open Unsigned -let testlib = Dl.(dlopen ~filename:"clib/libtest_functions.so" ~flags:[RTLD_NOW]) +let testlib = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) (* @@ -246,8 +246,8 @@ let test_adding_fields_through_views _ = let module M = struct let union_u = union "union_u" let u = typedef union_u "u" - let x = field u "x" int - let y = field u "y" float + let _x = field u "x" int + let _y = field u "y" float let () = seal u end in () @@ -300,8 +300,8 @@ let suite = "Union tests" >::: "test adding fields to tagless unions" >:: Struct_stubs_tests.test_tagless_unions; - (* "test layout of unions with missing fields" *) - (* >:: Struct_stubs_tests.test_missing_fields; *) + "test layout of unions with missing fields" + >:: Struct_stubs_tests.test_missing_fields; ] diff --git a/tests/test-value_printing/dune b/tests/test-value_printing/dune new file mode 100644 index 000000000..08bd535f7 --- /dev/null +++ b/tests/test-value_printing/dune @@ -0,0 +1,14 @@ +(test + (name test_value_printing) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries + ounit2 + ctypes + ctypes.stubs + ctypes-foreign + test_value_printing_stubs + test_value_printing_bindings + tests_common)) diff --git a/tests/test-value_printing/stub-generator/dune b/tests/test-value_printing/stub-generator/dune new file mode 100644 index 000000000..70dd564a7 --- /dev/null +++ b/tests/test-value_printing/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_value_printing_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_value_printing_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-value_printing/stubs/dune b/tests/test-value_printing/stubs/dune new file mode 100644 index 000000000..c0a1f7efb --- /dev/null +++ b/tests/test-value_printing/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_value_printing_stubs) + (wrapped false) + (libraries ctypes)) diff --git a/tests/test-value_printing/test_value_printing.ml b/tests/test-value_printing/test_value_printing.ml index 6d7c672e2..8b377c0c8 100644 --- a/tests/test-value_printing/test_value_printing.ml +++ b/tests/test-value_printing/test_value_printing.ml @@ -8,6 +8,7 @@ open OUnit2 open Ctypes +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) let strip_whitespace = Str.(global_replace (regexp "[\n ]+") "") diff --git a/tests/test-variadic/dune b/tests/test-variadic/dune new file mode 100644 index 000000000..9fd44be77 --- /dev/null +++ b/tests/test-variadic/dune @@ -0,0 +1,10 @@ +(test + (name test_variadic) + (package ctypes-foreign) + (libraries + ounit2 + ctypes + integers + test_variadic_stubs + test_variadic_bindings + tests_common)) diff --git a/tests/test-variadic/stub-generator/dune b/tests/test-variadic/stub-generator/dune new file mode 100644 index 000000000..d5db7d42d --- /dev/null +++ b/tests/test-variadic/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_variadic_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_variadic_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-variadic/stubs/dune b/tests/test-variadic/stubs/dune new file mode 100644 index 000000000..8cb664746 --- /dev/null +++ b/tests/test-variadic/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_variadic_stubs) + (wrapped false) + (libraries ctypes integers)) diff --git a/tests/test-variadic/test_variadic.ml b/tests/test-variadic/test_variadic.ml index eeab29bc6..1ab6c8ab4 100644 --- a/tests/test-variadic/test_variadic.ml +++ b/tests/test-variadic/test_variadic.ml @@ -11,7 +11,7 @@ open OUnit2 open Ctypes - +[@@@warning "-6"] module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = @@ -28,7 +28,7 @@ struct let bufsz = 128 in let write snprintf apply = let buf = allocate_n char bufsz in - ignore (apply (snprintf buf bufsz)); + let _ : int = apply (snprintf buf bufsz) in coerce (ptr char) string buf in begin diff --git a/tests/test-views/dune b/tests/test-views/dune new file mode 100644 index 000000000..db051f84d --- /dev/null +++ b/tests/test-views/dune @@ -0,0 +1,7 @@ +(test + (name test_views) + (package ctypes-foreign) + (deps ../clib/clib%{ext_dll}) + (link_flags + (:include ../flags/link-flags.sexp)) + (libraries ounit2 ctypes test_views_stubs test_views_bindings tests_common)) diff --git a/tests/test-views/stub-generator/dune b/tests/test-views/stub-generator/dune new file mode 100644 index 000000000..e7b4a2f02 --- /dev/null +++ b/tests/test-views/stub-generator/dune @@ -0,0 +1,23 @@ +(executable + (name driver) + (modules driver) + (libraries ctypes test_views_stubs tests_common)) + +(rule + (targets generated_stubs.c) + (action + (run %{exe:driver.exe} --c-file %{targets}))) + +(rule + (targets generated_bindings.ml) + (action + (run %{exe:driver.exe} --ml-file %{targets}))) + +(library + (name test_views_bindings) + (wrapped false) + (foreign_stubs + (language c) + (names generated_stubs)) + (modules generated_bindings) + (libraries ctypes test_functions)) diff --git a/tests/test-views/stubs/dune b/tests/test-views/stubs/dune new file mode 100644 index 000000000..319a9c3ac --- /dev/null +++ b/tests/test-views/stubs/dune @@ -0,0 +1,4 @@ +(library + (name test_views_stubs) + (wrapped false) + (libraries ctypes ctypes-foreign)) diff --git a/tests/test-views/test_views.ml b/tests/test-views/test_views.ml index 1ad1076e9..8205540ff 100644 --- a/tests/test-views/test_views.ml +++ b/tests/test-views/test_views.ml @@ -8,6 +8,9 @@ open OUnit2 open Ctypes +let _ = Dl.(dlopen ~filename:"../clib/clib.so" ~flags:[RTLD_NOW]) + +[@@@warning "-3-35"] module Common_tests(S : Cstubs.FOREIGN with type 'a result = 'a and type 'a return = 'a) = diff --git a/tests/tests-common/dune b/tests/tests-common/dune new file mode 100644 index 000000000..6ccdb52ff --- /dev/null +++ b/tests/tests-common/dune @@ -0,0 +1,3 @@ +(library + (name tests_common) + (libraries ctypes ctypes.stubs ctypes-foreign)) diff --git a/tests/tests-common/tests_common.ml b/tests/tests-common/tests_common.ml index 474e5a7f7..f28f8b168 100644 --- a/tests/tests-common/tests_common.ml +++ b/tests/tests-common/tests_common.ml @@ -7,9 +7,7 @@ (* Functions for test stub generation. *) -open Ctypes - -let filenames argv = +let filenames _argv = let usage = "arguments: [--ml-file $filename] [--c-file $filename]" in let ml_filename = ref "" and c_filename = ref "" @@ -55,7 +53,7 @@ let with_open_formatter filename f = close_channel (); raise e -let header = "#include \"clib/test_functions.h\"" +let header = "#include \"test_functions.h\"" let run ?concurrency ?errno ?(cheader="") argv ?structs specs = let ml_filename, c_filename, c_struct_filename = filenames argv